claude-code - 💡(How to fix) Fix Deny list does not override allow list — broader allow pattern defeats specific deny [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45511Fetched 2026-04-09 08:03:43
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Root Cause

git commit -m "..." executes successfully despite being on the deny list, because the allow list pattern Bash(git *) matches first and auto-approves the command.

Fix Action

Workaround

Replace Bash(git *) with specific subcommand patterns (Bash(git status *), Bash(git diff *), etc.) so no allow pattern matches the denied command.

RAW_BUFFERClick to expand / collapse

Bug

When Bash(git *) is in the allow list and Bash(git commit *) is in the deny list, git commit commands are auto-allowed. The deny entry has no effect.

Expected Behavior

Deny list entries should always take precedence over allow list entries. A specific deny pattern like Bash(git commit *) should block the command even when a broader allow pattern like Bash(git *) matches.

Observed Behavior

git commit -m "..." executes successfully despite being on the deny list, because the allow list pattern Bash(git *) matches first and auto-approves the command.

Reproduction

  1. Add Bash(git *) to the allow list in .claude/settings.json
  2. Add Bash(git commit *) to the deny list
  3. Ask Claude to run git commit -m "test"
  4. The command executes instead of being blocked

Impact

The deny list is the only mechanical enforcement that Claude cannot ignore. If allow overrides deny, there is no way to permit a broad category of commands while blocking specific dangerous subcommands within that category. Users must enumerate every safe subcommand individually to avoid the conflict — which is a viable workaround, but the precedence behavior is still wrong and surprising.

Workaround

Replace Bash(git *) with specific subcommand patterns (Bash(git status *), Bash(git diff *), etc.) so no allow pattern matches the denied command.

extent analysis

TL;DR

To fix the issue where deny list entries are overridden by allow list entries, replace broad allow patterns with specific subcommand patterns that do not match denied commands.

Guidance

  • Identify broad allow patterns (e.g., Bash(git *)) that may be overriding deny list entries.
  • Replace these broad patterns with specific allow patterns for safe subcommands (e.g., Bash(git status *), Bash(git diff *)).
  • Verify that the deny list entry (e.g., Bash(git commit *)) correctly blocks the corresponding command after updating the allow list.
  • Test various git subcommands to ensure the updated allow and deny lists behave as expected.

Example

No code snippet is provided as the issue is related to configuration settings in .claude/settings.json.

Notes

This solution assumes that the .claude/settings.json file is the correct location for configuring allow and deny lists. The effectiveness of this workaround depends on the ability to enumerate all safe subcommands for a given broad category.

Recommendation

Apply workaround: Replace broad allow patterns with specific subcommand patterns to ensure deny list entries take precedence. This approach allows for more fine-grained control over command permissions while avoiding the need to wait for a potential fix to the underlying precedence issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING