fix: sidebar prompt injection defense (v0.13.4.0)#611
Merged
Conversation
…t, arg plumbing Three security fixes for the Chrome sidebar: 1. XML-framed prompts with trust boundaries and escape of < > & in user messages to prevent tag injection attacks. 2. Bash command allowlist in system prompt — only browse binary commands ($B goto, $B click, etc.) allowed. All other bash commands forbidden. 3. Fix sidebar-agent.ts ignoring queued args — server-side --model and --allowedTools changes were silently dropped because the agent rebuilt args from scratch instead of using the queue entry. Also defaults sidebar to Opus (harder to manipulate). 12 new tests covering XML escaping, command allowlist, Opus default, trust boundary instructions, and arg plumbing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ML prompt injection defense design doc + P0 TODO for follow-up PR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
E2E Evals: ✅ PASS8/8 tests passed | $1.06 total cost | 12 parallel runners
12x ubicloud-standard-2 (Docker: pre-baked toolchain + deps) | wall clock ≈ slowest suite |
loadSession() was restoring worktreePath and claudeSessionId from prior crashes. The worktree directory no longer existed (deleted on cleanup) and --resume with a dead session ID caused claude to fail silently. Now validates worktree exists on load and clears stale claude session IDs on every server restart. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
arturmilachjr
pushed a commit
to arturmilachjr/gstack
that referenced
this pull request
Mar 30, 2026
VERSION was bumped to 0.13.4.0 in garrytan#611 but package.json was left at 0.13.3.0, causing the gen-skill-docs version-match test to fail. https://claude.ai/code/session_013TrjT8R7grdziMP1ffRivA
mathiasmora2232
pushed a commit
to mathiasmora2232/gstack
that referenced
this pull request
May 30, 2026
* fix: sidebar prompt injection defense — XML framing, command allowlist, arg plumbing Three security fixes for the Chrome sidebar: 1. XML-framed prompts with trust boundaries and escape of < > & in user messages to prevent tag injection attacks. 2. Bash command allowlist in system prompt — only browse binary commands ($B goto, $B click, etc.) allowed. All other bash commands forbidden. 3. Fix sidebar-agent.ts ignoring queued args — server-side --model and --allowedTools changes were silently dropped because the agent rebuilt args from scratch instead of using the queue entry. Also defaults sidebar to Opus (harder to manipulate). 12 new tests covering XML escaping, command allowlist, Opus default, trust boundary instructions, and arg plumbing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: bump version and changelog (v0.13.4.0) ML prompt injection defense design doc + P0 TODO for follow-up PR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: clear stale worktree and claude session on sidebar reconnect loadSession() was restoring worktreePath and claudeSessionId from prior crashes. The worktree directory no longer existed (deleted on cleanup) and --resume with a dead session ID caused claude to fail silently. Now validates worktree exists on load and clears stale claude session IDs on every server restart. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three security layers for the Chrome sidebar extension, which has bash access via Claude:
<user-message>tags, XML special chars escaped to prevent tag injection. System prompt explicitly instructs Claude to treat content as data.$B goto,$B click,$B snapshot). All other commands (curl,rm,cat) are forbidden. Prevents prompt injection from escalating to arbitrary code execution.Bug fix: sidebar-agent.ts was silently rebuilding its own Claude args from scratch, ignoring
--model,--allowedTools, and all other server-side arg changes. Fixed to use queued args from server.ts.Design doc:
docs/designs/ML_PROMPT_INJECTION_KILLER.mdcovers the follow-up ML classifier PR (DeBERTa via @huggingface/transformers, BrowseSafe-bench red team harness, and the ambitious Bun-native 5ms inference vision).Test Coverage
12 new tests in
browse/test/sidebar-security.test.ts:All existing tests pass. Zero regressions.
Pre-Landing Review
CEO review (SCOPE EXPANSION): 6 proposals, 5 accepted, 1 deferred.
Eng review: 1 issue (ONNX + compiled Bun compat), resolved with @huggingface/transformers v4.
Codex review: 15 findings, 4 critical, all resolved (command allowlist instead of removing Bash, arg plumbing fix, XML escaping, salted payload hashes).
Test plan
🤖 Generated with Claude Code