Skip to content

fix: harden shell approval classification#16

Merged
morganlinton merged 2 commits into
mainfrom
agent/harden-shell-approvals
Jul 16, 2026
Merged

fix: harden shell approval classification#16
morganlinton merged 2 commits into
mainfrom
agent/harden-shell-approvals

Conversation

@morganlinton

@morganlinton morganlinton commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What changed

  • replace the bypass-prone dangerous-command regex with a conservative non-destructive command classifier
  • require approval for destructive Git operations, redirects, interpreters, compound shell syntax, arbitrary executable paths, write-capable flags, and unknown commands
  • preserve approval-free use for common inspection commands and the normal Cargo test/check/clippy workflow
  • document the tightened dangerous-only behavior
  • update one equivalent hook-state expression for compatibility with the current GitHub stable clippy
  • bump Small Harness to 1.2.1

Why

The previous regex missed commands such as git reset --hard, git clean -fd, git restore, mv, sed -i, and ordinary file redirection. Because first-run setup recommends dangerous-only, those gaps could let an agent mutate or discard work without an approval prompt.

The first PR run also exposed a new Rust 1.97 clippy lint in pre-existing hook-state code. The follow-up commit applies clippy's behavior-preserving rewrite so the repository remains green on GitHub's current stable toolchain.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test — 549 passed
  • git diff --check

morganlinton and others added 2 commits July 15, 2026 20:23
Remove printenv from auto-run under dangerous-only, scrub hydrated
OPENAI/OPENROUTER keys from shell children, and cover common bypass
cases in tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@morganlinton
morganlinton force-pushed the agent/harden-shell-approvals branch from e160db8 to d507c5a Compare July 16, 2026 03:25
@morganlinton
morganlinton merged commit a6d08c7 into main Jul 16, 2026
5 checks passed
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