fix(security): default to ask when no permission rule matches (#886)#981
Merged
fix(security): default to ask when no permission rule matches (#886)#981
Conversation
Previously, commands not in any deny/ask list were auto-allowed. This bypassed Claude Code's least-privilege default where unlisted commands should prompt the user for confirmation. Permission precedence is now: Deny > Ask > Allow (explicit) > Default (ask). Changes: - permissions.rs: load allow rules from settings.json, add Default variant - rewrite_cmd.rs: treat Default same as Ask (exit 3) - hook_cmd.rs: add permission checks to Copilot VS Code hook (ask/allow/deny), add deny check to Gemini hook (no ask mode available in Gemini CLI) Gemini CLI limitation: only supports allow/deny, no ask mode. Codex: ask is parsed but fails open. These tools document the limitation. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Contributor
|
Hey, Fix is correct and ready to go, just one thing, for the flow documentation (deny->allow->ask) , this should be documented in the root README.md of the hook folder. This is to be conform with how we document code, in the incoming coding practice, comment will only be used to specify edge case or issue fix, for the core documentation it goes in respective README.md of affected feature. Once this is done we can merge |
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
aeppling
approved these changes
Apr 2, 2026
Contributor
|
go |
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
permissions.allowrules from settings.json (previously only deny/ask were loaded)AllowtoDefault(treated as ask) when no rule matchespermissionDecisionon Allow to fix bypassPermissions mode (Hook updatedInput silently ignored when using bypassPermissions mode in Claude Code #893)Problem
Two related issues:
#886: RTK's PreToolUse hook auto-allowed every rewritten command that wasn't explicitly in a deny/ask list. This bypassed Claude Code's least-privilege default where unlisted commands should prompt for confirmation.
#893: In
bypassPermissionsmode, Claude Code discardsupdatedInputwhenpermissionDecisionis present. RTK rewrites were silently ignored.Fix
Permission precedence is now: Deny > Ask > Allow (explicit) > Default (ask)
For Allow verdict,
permissionDecisionis omitted from hook output. This is equivalent to allow by default, AND fixes bypassPermissions mode whereupdatedInputwas discarded.permissionDecision: "ask"+updatedInputupdatedInputonly (no permissionDecision)permissionDecision: "ask"+updatedInputPer-tool support
permissionDecision: "ask"— user promptedpermissionDecision: "ask"— user promptedFiles changed
src/hooks/permissions.rs— load allow rules, addDefaultvariant, 7 new testssrc/hooks/rewrite_cmd.rs— treatDefaultsame asAsk(exit 3)src/hooks/hook_cmd.rs— permission checks for Copilot VS Code + Gemini deny + omit permissionDecision on Allowsrc/hooks/README.md— document permission precedence model.claude/hooks/rtk-rewrite.sh— omit permissionDecision on Allow, add "ask" on exit 3Test plan
cargo fmt --all— cleancargo clippy --all-targets— no new warningscargo test permissions— 30 tests passed (7 new)cargo test hook_cmd— 14 tests passedFixes #886
Fixes #893