Permission deny rules not enforced for Bash commands

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 5 comments · opened Feb 17, 2026 · closed Feb 18, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Bug Description

Claude Code is not respecting the deny rules configured in .claude/settings.json for Bash commands.

Steps to Reproduce

  1. Configure .claude/settings.json with a deny rule for gcloud:
{
  "permissions": {
    "deny": [
      "Bash(*gcloud*)"
    ]
  }
}
  1. Ask Claude to run a gcloud command (e.g., run gcloud -h or gcloud)
  2. Claude executes the command despite it being in the deny list

Expected Behavior

Commands matching patterns in the deny list should be blocked and never execute.

Actual Behavior

Claude successfully executed gcloud -h and gcloud commands even though Bash(*gcloud*) is explicitly denied in settings.json. The deny rules simply don't deny anything.

Configuration

{
  "defaultMode": "dontAsk",
  "permissions": {
    "allow": [...],
    "deny": [
      "Bash(*kubectl*)",
      "Bash(*terraform*)",
      "Bash(*aws*)",
      "Bash(*gcloud*)",
      "Bash(*sudo*)",
      "Bash(*rm*)",
      ...
    ],
    "ask": [...]
  },
  "sandbox": {
    "enabled": false,
    "autoAllowBashIfSandboxed": false,
    "allowUnsandboxedCommands": false
  },
  "disableBypassPermissionsMode": "enforce"
}

Impact

This is a security issue as it allows bypassing user-configured safety restrictions for dangerous commands like kubectl, terraform, aws, gcloud, sudo, rm, etc.

Environment

  • Claude Code version: [unknown from session]
  • Platform: macOS (Darwin 25.1.0)
  • Model: claude-sonnet-4-5-20250929

View original on GitHub ↗

5 Comments

github-actions[bot] · 8 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/25621
  2. https://github.com/anthropics/claude-code/issues/18846
  3. https://github.com/anthropics/claude-code/issues/8961

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

bcherny collaborator · 8 months ago

This is a bug in the settings.json -- you want "disableBypassPermissionsMode": "disable". You should have gotten a warning about invalid settings.json on startup, did you not see it?

jharshman · 8 months ago

Sorry that was actually set to "disable". Bug exists and deny rules are not enforced. Can you please reopen the issue?
I've had to write a Hook in order to actually enforce deny rules.

jharshman · 7 months ago

@bcherny Can you reopen this issue? It was closed prematurely.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.