You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Chained bash commands silently bypass the tool permission allowlist #36637
The permissions.allow allowlist evaluates the first token of a bash command. Compound commands (cmd1 && cmd2, cmd1; cmd2, cmd1 | cmd2) only present the first segment to the matcher — the remaining segments execute without evaluation.
The allowlist sees git status (allowed), runs the whole chain, and rm executes without hitting the deny rule.
Impact
Agents that default to chained commands (common pattern) can unintentionally or maliciously escape permission boundaries
The user sees Bash(git:*) in the allow log and has no indication that subsequent chain segments were unevaluated
Particularly dangerous in agentic/long-running sessions where compound commands accumulate
Expected Behavior
Each segment of a compound command should be evaluated independently against the allowlist. If any segment would be denied, the entire command should be blocked.
Suggested Fix
Parse compound bash commands and evaluate each segment against the allowlist before execution. Segments joined by &&, ;, ||, or | should each be checked independently.
Filed a reference implementation as a PreToolUse hook plugin in #36645. The approach:
Shell-aware compound splitter (respects single quotes, double quotes, backticks — operators inside strings are not treated as separators)
Reads Bash(...) deny patterns from all three settings files (~/.claude/settings.json, .claude/settings.json, .claude/settings.local.json)
Evaluates each segment independently with prefix + glob matching that mirrors the built-in rule semantics
Strips leading VAR=value env-var assignments before matching (closes the X=1 rm -rf / env-prefix bypass)
Fail-open: hook exits 0 on any parse error so legitimate commands are never silently blocked by a hook crash
34 unit tests
I've been running this as a PreToolUse hook in production on my own installation — it's working correctly and hasn't produced false positives on normal development workflows.
The PR can serve as a reference implementation or test suite for the core fix in the bundle.
Update with fresh receipts from an independent Windows session on Claude Code 2.1.78:
git clean -fd is blocked by disallowedTools as expected
git status && git clean -fd is also blocked
git status; git clean -fd is also blocked
with --dangerously-skip-permissions, the command executes (expected)
Conclusion: I can no longer reproduce a chain-operator bypass (&&, ;, ||, |) on 2.1.78.
To keep findings accurate, I opened a separate issue focused on nested/wrapped forms that still appear problematic ($(), backticks, subshell, eval, PowerShell wrapper): #39601
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
Pro777 commentedon Mar 20, 2026
Filed a reference implementation as a
PreToolUsehook plugin in #36645. The approach:Bash(...)deny patterns from all three settings files (~/.claude/settings.json,.claude/settings.json,.claude/settings.local.json)VAR=valueenv-var assignments before matching (closes theX=1 rm -rf /env-prefix bypass)I've been running this as a
PreToolUsehook in production on my own installation — it's working correctly and hasn't produced false positives on normal development workflows.The PR can serve as a reference implementation or test suite for the core fix in the bundle.
Pro777 commentedon Mar 27, 2026
Update with fresh receipts from an independent Windows session on Claude Code 2.1.78:
git clean -fdis blocked bydisallowedToolsas expectedgit status && git clean -fdis also blockedgit status; git clean -fdis also blocked--dangerously-skip-permissions, the command executes (expected)Conclusion: I can no longer reproduce a chain-operator bypass (
&&,;,||,|) on 2.1.78.To keep findings accurate, I opened a separate issue focused on nested/wrapped forms that still appear problematic (
$(), backticks, subshell,eval, PowerShell wrapper): #39601Pro777 commentedon Mar 27, 2026
Public thread redaction update: details that could be used as ready-to-run abuse payloads were removed.
Claim status remains unchanged:
Full reproducible artifacts are available privately for maintainer/security review on request.
claude commentedon Apr 17, 2026
This issue was fixed as of version 2.1.78.
github-actions commentedon Apr 25, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.