fix: Add PermissionRequest hook workaround for piped command permissions (#11775)#28294
Open
AnthonyMDev wants to merge 2 commits intoanthropics:mainfrom
Open
fix: Add PermissionRequest hook workaround for piped command permissions (#11775)#28294AnthonyMDev wants to merge 2 commits intoanthropics:mainfrom
AnthonyMDev wants to merge 2 commits intoanthropics:mainfrom
Conversation
…ons (anthropics#11775) Add a PermissionRequest hook that works around the regression where the Plan agent requests permission for piped commands even when both commands are individually whitelisted in settings.json. Root cause: In the Bash permission checker (cFA), after FXq successfully validates each pipe segment individually and returns "allow", the code runs jF (bash security checker) on the original piped command. Since the v2.1.7 security fix tightened jF to flag commands containing shell operators, piped commands that were individually approved get overridden back to "ask". In plan mode without bypass permissions available, this "ask" propagates to the user as an unnecessary permission prompt. The proper source code fix would be to skip the jF security check when FXq has already verified each pipe segment individually (i.e., when FXq returns "allow" with decisionReason.type === "subcommandResults"). This hook provides an immediate workaround by intercepting the PermissionRequest event, splitting piped commands into segments, checking each segment's base command against a configurable allowed list, and auto-approving when all segments match. Fixes anthropics#11775 https://claude.ai/code/session_01CDRJETAE5tKKudwBqkVdro
… config The hook now automatically parses Bash() permission rules from all Claude settings files (user and repo-level) instead of requiring a manually maintained ALLOWED_PREFIXES set. Co-Authored-By: Claude Opus 4.6 <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
PermissionRequesthook example (examples/hooks/piped_command_permission_fix.py) that works around the regression where the Plan agent prompts for permission on piped commands even when both individual commands are whitelisted insettings.json&&,||,$(, backticks,;,<<)Root Cause Analysis
The regression was introduced in v2.1.7's security fix ("Fixed security vulnerability where wildcard permission rules could match compound commands containing shell operators"). In the permission checking flow:
FXq(pipe handler) correctly splits the piped command, validates each segment individually, and returns"allow"FXqreturns,jF(bash security checker) runs on the original compound command and flags the pipe operator"allow"result back to"ask", causing the permission promptThe proper source-level fix would be to skip the
jFsecurity check whenFXqhas already validated all pipe segments individually (i.e., whendecisionReason.type === "subcommandResults"), since the security of each segment has already been verified.Test plan
.claude/settings.jsonper the docstring instructionsALLOWED_PREFIXESto match yourpermissions.allowrulesls -lh *.webp | awk '{print $5, $9}'with bothlsandawkwhitelisted&&,||, etc.) are not auto-approvedFixes #11775