Skip to content

fix: Add PermissionRequest hook workaround for piped command permissions (#11775)#28294

Open
AnthonyMDev wants to merge 2 commits intoanthropics:mainfrom
AnthonyMDev:claude/fix-issue-11775-3ZNta
Open

fix: Add PermissionRequest hook workaround for piped command permissions (#11775)#28294
AnthonyMDev wants to merge 2 commits intoanthropics:mainfrom
AnthonyMDev:claude/fix-issue-11775-3ZNta

Conversation

@AnthonyMDev
Copy link

Summary

  • Adds a PermissionRequest hook 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 in settings.json
  • The hook intercepts Bash permission requests, checks if the command is a simple pipeline where each segment's base command is in a configurable allowed list, and auto-approves if all segments match
  • Includes safety checks to reject commands with dangerous patterns (&&, ||, $(, 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:

  1. FXq (pipe handler) correctly splits the piped command, validates each segment individually, and returns "allow"
  2. After FXq returns, jF (bash security checker) runs on the original compound command and flags the pipe operator
  3. This overrides the "allow" result back to "ask", causing the permission prompt

The proper source-level fix would be to skip the jF security check when FXq has already validated all pipe segments individually (i.e., when decisionReason.type === "subcommandResults"), since the security of each segment has already been verified.

Test plan

  • Install the hook in .claude/settings.json per the docstring instructions
  • Configure ALLOWED_PREFIXES to match your permissions.allow rules
  • Run a piped command like ls -lh *.webp | awk '{print $5, $9}' with both ls and awk whitelisted
  • Verify the Plan agent no longer prompts for permission on the piped command
  • Verify that piped commands with non-whitelisted commands still prompt for permission
  • Verify that commands with dangerous patterns (&&, ||, etc.) are not auto-approved

Fixes #11775

claude and others added 2 commits February 24, 2026 20:08
…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>
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.

[BUG] Plan agent requests permission for piped commands despite allowed settings (regression of #1271)

2 participants