Skip to content

feat(security): bash command security + auto-allow hardening#22

Merged
nnemirovsky merged 4 commits into
mainfrom
bash-security-auto-allow
Apr 17, 2026
Merged

feat(security): bash command security + auto-allow hardening#22
nnemirovsky merged 4 commits into
mainfrom
bash-security-auto-allow

Conversation

@nnemirovsky
Copy link
Copy Markdown
Owner

Summary

  • Harden Bash command matching by splitting compound commands and matching each segment independently, mirroring Claude Code's splitCommand() approach. Deny on ANY segment, allow requires ALL segments covered.
  • Auto-allow read-only Bash commands (cat, head, tail, ls, etc.) with path validation. Absolute paths must be inside cwd or allowed dirs. Blocks traversal (../), tilde expansion (~/, ~user), and redirects (>, <).
  • Auto-allow Agent, Skill, Glob, and WebSearch as internal tools (explicit allow, not passthrough). No more native permission prompts for these.
  • Anchor overlay-proposed Bash regexes with CC's safe character class to prevent compound command injection.
  • Support allowed_dirs in passthru.json schema. Bootstrap imports CC's additionalAllowedWorkingDirs.
  • Add overlay queue lock so concurrent permission prompts serialize instead of falling through to CC's native dialog.
  • Send OSC 777 desktop notification before overlay prompt (works in Ghostty, iTerm2).

Test plan

  • 855 bats tests pass (up from 749 baseline, +106 new)
  • 5-agent comprehensive review (quality, implementation, testing, simplification, documentation)
  • Code smells review
  • 5 iterations of adversarial codex review catching 10+ security bypasses (redirect stripping, path traversal, tilde expansion, bash 3.2 compat, find -fprint, quote-aware splitting)
  • Critical-only final review pass: clean
  • Manual: test overlay dialog with compound Bash command
  • Manual: test Agent/Skill/WebSearch no longer show CC native prompt
  • Manual: test cat src/file.txt auto-allows, cat /etc/passwd does not
  • Manual: test concurrent permission prompts queue through overlay
  • Manual: verify Ghostty notification on overlay prompt

Compound command splitting: add split_bash_command() in Perl that
tokenizes Bash commands respecting quotes, subshells, and backticks,
then splits by unquoted |, &&, ||, ;, & operators. Redirections are
stripped from each segment. For deny rules, ANY segment match denies the
whole command. For allow rules, ALL segments must be covered.

Read-only auto-allow: mirror CC's readonly command list and safety regex
pattern. Simple commands (cat, head, tail, wc, stat, etc.) and custom
regex commands (echo, ls, find, cd, jq, etc.) are auto-allowed when all
path arguments resolve inside cwd or allowed directories.

Internal tool auto-allow: Agent, Skill, and Glob now get explicit allow
decisions (permissionDecision: allow) instead of passthrough, preventing
CC's native confirmation dialogs.

Overlay proposal anchoring: Bash proposals changed from ^<cmd>\s to
^<cmd>(\s[safe-chars]*)?$ using CC's safe character class to block
compound operator injection in proposed rules.

Additional allowed directories: new optional allowed_dirs field in
passthru.json v2. Bootstrap imports additionalAllowedWorkingDirs from
CC settings. Path validation for Read/Edit/Write/Grep auto-allow and
readonly Bash commands checks cwd plus all allowed dirs.
@nnemirovsky nnemirovsky merged commit 5176e72 into main Apr 17, 2026
2 checks passed
@nnemirovsky nnemirovsky deleted the bash-security-auto-allow branch April 17, 2026 10:35
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.

1 participant