Skip to content

fix(approvals): stop env and find -exec escaping "Always allow" patterns - #707

Merged
alari76 merged 1 commit into
mainfrom
fix/approval-exec-prefixes
Oct 1, 2026
Merged

alari76 merged 1 commit into
mainfrom
fix/approval-exec-prefixes

Conversation

@alari76

@alari76 alari76 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the security audit (High #2 was fixed by #694's segment splitting). Some commands on the safe-to-pattern list could still run other programs or write files:

  • env was patternable → one "Always allow" saved env *, which auto-approved env sh -c '<anything>'.
  • find * matched find . -delete and find . -exec rm -rf . \; (no {}, so the splitter doesn't refuse it).
  • Read-only rules matched file-writing flags: sort -o, tree -o, git diff/log/show --output.

Changes

  • env moves from PATTERNABLE_PREFIXES to NEVER_PATTERN_PREFIXES.
  • New ESCALATING_ARGS + escapesPatternRules(): such commands never match a pattern or prefix rule (per-repo or cross-repo) and never derive a pattern. Exact "Always allow" matches still apply. Already-stored env * patterns stop matching.

Test plan

  • New escalating commands tests in server/approval-manager.test.ts
  • approval-manager, prompt-router, shell-command suites pass (117 tests)
  • Full suite: only the known environment failures (server/relay/* missing express-session locally; 4 utility-agent tests that fail identically on main)

🤖 Generated with Claude Code

`env` was on the safe-to-pattern list, so one "Always allow" saved `env *`
and auto-approved `env sh -c '<anything>'`. `find *` likewise matched
`find . -delete` / `find . -exec rm … \;`, and read-only rules matched
file-writing flags like `sort -o` and `git diff --output`.

- Move `env` from PATTERNABLE_PREFIXES to NEVER_PATTERN_PREFIXES.
- Add ESCALATING_ARGS: a command starting with `env`, or carrying
  find -exec/-execdir/-ok/-okdir/-delete/-fprint*/-fls, sort -o,
  tree -o, or git diff/log/show --output, never matches a pattern or
  prefix rule (repo or cross-repo) and never derives one. Exact
  "Always allow" matches still work. Stored `env *` patterns stop
  matching too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alari76
alari76 merged commit 007a6b7 into main Oct 1, 2026
2 checks passed
@alari76
alari76 deleted the fix/approval-exec-prefixes branch October 1, 2026 12:11
@alari76 alari76 mentioned this pull request Oct 18, 2026
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