fix: Bash permission rules should only match Bash tool calls

Previously, a Bash(...) permission rule would incorrectly match against
any tool. The code checked if the rule was a Bash rule, but didn't verify
that the tool being invoked was actually the Bash tool.

This caused Bash rules like `Bash(./inbox:*)` to inadvertently allow
Edit/Write operations on files matching the pattern, since the rule's
argument would be interpreted as a glob pattern against file paths.

The fix adds a check to ensure Bash rules only apply when the tool
being called is mcp__acp__Bash.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Elle Najt
2026-02-03 13:45:55 -08:00
parent 6b68ddf00e
commit d471ccfd9c

View File

@@ -156,7 +156,7 @@ function matchesRule(rule: ParsedRule, toolName: string, toolInput: unknown, cwd
// - "Claude will make a best-effort attempt to apply Read rules to all built-in tools
// that read files like Grep, Glob, and LS."
const ruleAppliesToTool =
rule.toolName === "Bash" ||
(rule.toolName === "Bash" && toolName === acpToolNames.bash) ||
(rule.toolName === "Edit" && FILE_EDITING_TOOLS.includes(toolName)) ||
(rule.toolName === "Read" && FILE_READING_TOOLS.includes(toolName));