Skip to content

fix(claude): prevent forged Bash approval prompts - #415

Merged
mbektas merged 1 commit into
plmbr:mainfrom
herikwebb:security/fix-bash-approval-fence-injection-20260903123826-40
Sep 9, 2026
Merged

fix(claude): prevent forged Bash approval prompts#415
mbektas merged 1 commit into
plmbr:mainfrom
herikwebb:security/fix-bash-approval-fence-injection-20260903123826-40

Conversation

@herikwebb

Copy link
Copy Markdown
Contributor

Why

Notebook Intelligence asks people to approve Bash commands based on what is shown in chat. A model-supplied command could previously alter that display by closing its Markdown code fence or by using invisible bidirectional Unicode controls, making a dangerous command appear harmless immediately above the approval button.

What

This change keeps the displayed approval prompt aligned with the command that would run. Commands can no longer escape their code block, descriptions cannot create a second Markdown block, and commands containing hidden bidirectional controls are blocked before an approval prompt is offered. The blocked diagnostic shows those controls as visible ASCII markers.

Technical summary

  • Size the backtick fence beyond the longest run contained in the command.
  • Fold untrusted descriptions to a single line and visibly escape bidi controls.
  • Reject all Unicode Bidi_Control code points before Bash confirmation.
  • Validate the fenced-block info string as a trusted ASCII identifier.
  • Add handler-level regression coverage for the Bash Trojan Source pattern, all 12 bidi-control code points, embedded fences, ordinary RTL text, and shell whitespace.

Validation

  • python -m pytest -q tests: 1,829 passed.
  • Focused Bash approval and permission tests: 66 passed.
  • git diff --check: passed.
  • Cora exact-range security-sensitive review: approved by Codex/high and Fable/high with no blocker, major, or minor findings.

@herikwebb
herikwebb force-pushed the security/fix-bash-approval-fence-injection-20260903123826-40 branch from 92ae2db to 3c97fd7 Compare September 3, 2026 18:16
Render Bash approval commands with collision-resistant Markdown fences so command text cannot escape the displayed code block.

Reject bidirectional-control characters before requesting approval, escape them in diagnostic descriptions, and add regression coverage for fence injection, Trojan Source payloads, and benign multiline or RTL text.
@herikwebb
herikwebb force-pushed the security/fix-bash-approval-fence-injection-20260903123826-40 branch from 3c97fd7 to 9ecfa36 Compare September 3, 2026 19:11

@mbektas mbektas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mbektas
mbektas merged commit e269b07 into plmbr:main Sep 9, 2026
3 of 4 checks passed
herikwebb added a commit to herikwebb/notebook-intelligence that referenced this pull request Sep 9, 2026
…ings

Pass A: manifests byte-identical to the prior scan (the f0e73e1..e269b07
delta touches only claude.py and a new test file); pip-audit clean on the
Python runtime closure and the npm advisory set is unchanged from baseline.

Pass B: upstream merged plmbr#415, fixing NBI-2026-008 (forged Bash approval
prompts) -- verified adversarially against six fence-escape variants and
marked fixed_upstream. Class sweep for a second instance came back empty.
Corrected two stale memory notes: NBI-2026-007 is still unfixed, and
NBI-2026-005's remediation is now a one-line call to a guard upstream
already added in the same file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LFfuPbzPnBYVLDTibzjZn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants