fix(pre-tool-scope-guard): apply quote-strip to all destructive-command checks (v6.1.4)#48
Merged
Conversation
…nd checks (v6.1.4) The force-push, history-rewrite, locked-plan-push, and default-branch-push checks were scanning the raw tool_input.command instead of the quote-stripped cmd_no_quotes form (which was already computed for the SUPERPOWERS_ self- bypass detector). The SUPERPOWERS_ check was correct; the four destructive- command checks were not. Real-world false positive encountered during v6.1.3 release: the PR body heredoc for PR #47 quoted the force-push command verbatim as an example in the changelog text. The hook scanned the full Bash command (including the --body arg) and matched the example as a real force push, blocking the very PR meant to ship the v6.1.3 fix. Worked around with --body-file that release. Now fixed at the regex level. Trade-off: an attacker who hides a destructive command inside quoted args would slip through quote-strip. Acceptable edge case vs the much more common false-positive on PR bodies and inline documentation. Same trade-off the SUPERPOWERS_ check already accepted. Added regression test in tests/hook-contracts.sh that asserts no block fires when force-push appears inside a quoted string. Version bump 6.1.3 -> 6.1.4 across all four manifests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hooks/pre-tool-scope-guard: the force-push, history-rewrite, locked-plan-push, and default-branch-push checks now usecmd_no_quotes(the quote-stripped form already computed for the SUPERPOWERS_ self-bypass check). Previously they scanned the raw Bash command and produced false-positive blocks when a destructive command appeared as a documentation example inside a quoted heredoc body.--body-file; this PR fixes the regex.eval "...") would slip through. Acceptable edge case vs the much more common false-positive on PR bodies and inline documentation.tests/hook-contracts.sh.Test plan
tests/hook-contracts.sh— 50 assertions PASS, including the new false-positive regressiontests/version-check.sh— manifests agree on 6.1.4Release validation context
User adjusted the enterprise ruleset earlier this session to unblock marketplace auto-merge. This is the first release after that tweak; the cascade is a test of whether the chain now completes end-to-end without admin override.
🤖 Generated with Claude Code