Skip to content

[BUG] Bypass permission mode resets after a PreToolUse hook returns "ask" #37420

@awakia

Description

@awakia

Description

When a PreToolUse hook returns permissionDecision: "ask", the user is prompted for confirmation as expected. However, after the user approves (or denies) the action, the bypass permission mode is permanently lost for the rest of the session. All subsequent tool calls then require manual approval, even though the session was started in bypass permission mode.

The expected behavior is that bypass permission mode should be restored after the hook-triggered confirmation dialog is resolved.

Steps to Reproduce

  1. Configure a PreToolUse hook that returns permissionDecision: "ask" for specific patterns (e.g., reading credential files):
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Read",
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/credential-guard.sh",
            "timeout": 5
          }
        ]
      }
    ]
  }
}

Where the hook script returns:

{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"ask","permissionDecisionReason":"Security check: confirm this read is intentional."}}
  1. Start a Claude Code session with bypass permission mode enabled
  2. Trigger the hook (e.g., ask Claude to read a .env file)
  3. Approve the action in the confirmation dialog
  4. Observe: All subsequent tool calls now prompt for permission, even though bypass mode was active before

Expected Behavior

After the user responds to the hook-triggered ask dialog, the session should return to its previous permission mode (bypass permissions). The hook's ask should be a one-time override for that specific tool call, not a permanent mode change.

Actual Behavior

Bypass permission mode is permanently disabled after the ask dialog is shown. The session effectively switches to a manual approval mode for all remaining tool calls.

Use Case

This is a common pattern for security-focused hooks: allow most operations to proceed automatically in bypass mode, but force an explicit user confirmation for sensitive operations (e.g., reading credential files, sending data over the network). The hook is designed to be a targeted safety check, not a global permission mode change.

Environment

  • Claude Code CLI (macOS)
  • Tested with PreToolUse hooks using permissionDecision: "ask"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions