Skip to content

fix(core): match deny_shell_prefixes through wrappers like the fixed stops - #508

Merged
lg2m merged 2 commits into
mainfrom
fix/deny-prefixes-see-wrappers
Oct 30, 2026
Merged

lg2m merged 2 commits into
mainfrom
fix/deny-prefixes-see-wrappers

Conversation

@lg2m

@lg2m lg2m commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Change

deny_shell_prefixes now match each command the same way the fixed stops see it, so a prefix like "cargo publish" also refuses env A=b cargo publish, timeout 9 cargo publish, nice/nohup/command …, sh -c 'cargo publish' and bash -lc "cd x && cargo publish". Git global options before the subcommand are dropped, so "git push origin main" also refuses git -C . push origin main and git -c a=b push origin main. Goal-check denial uses the same matcher. echo cargo publish and cargo build are still allowed.

Commands are now normalized by the stops' collector (wrapper peeling and sh -c reparsing) instead of a separate raw-node walk. Prefixes are still read literally, so an existing entry such as "env A=b cargo publish" keeps matching. The collector also now finds $(…) inside redirections and here-strings, so echo hi > "$(cargo publish)" is refused. The git global-option skip is shared between the force-push stop and prefix matching.

The force-push stop now treats abbreviated long options the way git does: --force-w, --forc, --mirr, --del, --pru are refused. Options that only abbreviate non-force options, like --follow-tags, --fol, --force-if-includes and --prog, are still allowed. The option table comes from git push -h (git 2.54).

docs/guide/permissions.md and docs/guide/running-unattended.md now list what the stops and prefixes see through. They also say that scripts, aliases and commands built at run time ($CMD, eval) are still not caught.

This gap isn't new in v0.1.10. v0.1.9's managed_shell_denied had it too. It matters more now because v0.1.10 makes managed prefixes the documented guard for unattended runs.

Verification

  • New rows in shell_prefix_denies_match_literal_commands_without_classifying_unknown_programs, force_pushes_and_remote_deletions_stop and the new goal_check_denies_wrapped_prefixes failed on origin/main (env A=b cargo publish, git push --force-w) and pass now.
  • shell_prefix_denial_precedes_auto_and_full_and_allows_continuation runs env A=b timeout 9 sh -c 'cd x && managed-tool --dangerous' through the session approval gate in Auto and Full and gets the prefix denial.
  • Checked the abbreviations against a real git push to a local bare repo. For example, --forc and --d are ambiguous in git but are refused here because one of their candidates is force-like.
  • cargo nextest run -p qq-core -E 'test(/approval|stops|prefix|goal_check/)': 169 passed.
  • cargo xtask check: passed.

Known impact

When deny prefixes are configured, a command that expands to more than 256 simple commands, or that overflows env -S expansion, is now refused, the same as goal checks. Empty prefix lists are unaffected.

…stops

Prefix denial and goal-check denial now compare against the commands the fixed stops see, after peeling env, timeout, nice, nohup, command and sh -c, and after dropping git global options. The force-push stop also accepts the abbreviated long options git accepts.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T03:59:06.614416Z f0f1533 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb814f3022

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/approval/classify.rs Resolved
Comment thread crates/qq-core/src/approval/classify.rs Resolved
Comment thread crates/qq-core/src/approval/stops.rs Resolved
@lg2m
lg2m merged commit 8b381fc into main Oct 30, 2026
11 checks passed
@lg2m
lg2m deleted the fix/deny-prefixes-see-wrappers branch October 30, 2026 04:04
@lg2m lg2m mentioned this pull request Oct 30, 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