Repository navigation
fix: strip scoped allow rules for guarded tools from allowed_tools (#244) - #246
Open
FrundlesTian wants to merge 1 commit into
Open
FrundlesTian wants to merge 1 commit into
FrundlesTian wants to merge 1 commit into
Conversation
ClaudeSDKManager.execute_command strips GUARDED_TOOLS (and approval-gated tools) from the allowed_tools it hands the SDK so their calls reach can_use_tool (overwirehq#219). It compared entries by exact name, so a scoped rule such as Bash(mkdir:*), Read(//etc/**) or Write(*) in CLAUDE_ALLOWED_TOOLS was passed through. The CLI pre-approves the calls a scoped rule matches, so those calls skipped the APPROVED_DIRECTORY / Bash boundary checks and the interactive approval prompt. Match allow rules by the tool they name instead. Verified against a live session (bundled CLI 2.1.277) with CLAUDE_ALLOWED_TOOLS=Read,Bash(mkdir:*): before the fix `mkdir -p sub` ran without can_use_tool being consulted; after it, the call reached the callback. Co-Authored-By: Claude Opus 5.5 <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.
Description
Scoped allow rules for guarded tools are now stripped from the
allowed_toolshanded to the SDK, so their calls reachcan_use_tooland its boundary checks.execute_commandstrippedGUARDED_TOOLS(and approval-gated tools) by exact name. A scoped rule such asBash(mkdir:*),Read(//etc/**)orWrite(*)inCLAUDE_ALLOWED_TOOLSwas therefore passed through to the CLI, which pre-approves the calls it matches. Those calls skipped theAPPROVED_DIRECTORY/ Bash boundary checks and the interactive approval prompt. The fix matches each allow rule by the tool it names (the part before().Related Issue
Closes #244
This is a follow-up to #219, whose strip it completes, and it was found while working on #221 (whose PR, from
fix/221-enforce-allowed-tools, enforcesCLAUDE_ALLOWED_TOOLS). This PR is independent of that one and branches frommain. The two touch neighbouring code, so whichever merges second may need a trivial rebase.Type of Change
Behaviour
can_use_tool, which allows them only if they pass validation (and, if gated, after the Allow/Deny prompt). Nothing becomes more permissive.Grep(foo)) are left alone.SecurityValidator, orDISABLE_TOOL_VALIDATION=true: no change.Testing
CLAUDE_ALLOWED_TOOLS=Read,Bash(mkdir:*), prompt "runmkdir -p sub":gated_tools=['Read']. TheBashcall ran andcan_use_toolwas never consulted.gated_tools=['Read', 'Bash(mkdir:*)']. TheBashcall reachedcan_use_tool(allowed, since it was inside the boundary).Checklist
make formathas been runSECURITY.md,CLAUDE.md)🤖 Generated with Claude Code