Claude Code Refuses Bash When the Sandbox Fails to Start and Clarifies Which Hook-Rewritten Commands Run Outside It

Claude CodeView original changelog

Claude Code 2.1.328 changes what happens when the Bash sandbox cannot start. Unless sandbox.failIfUnavailable is set, the next sandboxed Bash command is now refused and the message states that the sandbox is off for the session. Two hook changes also affect the trust boundary: a command rewritten by a PermissionRequest hook to a sandbox-excluded command now runs outside the sandbox, and managed PostToolUse hooks no longer fire for calls refused before they ran.

Key Takeaways

  • A sandbox that cannot start now causes the next sandboxed Bash command to be refused, unless sandbox.failIfUnavailable is set.
  • The refusal message states that the sandbox is off for the session, so a failure is no longer silent.
  • A command rewritten by a PermissionRequest hook to a sandbox-excluded command now runs outside the sandbox.
  • Managed PostToolUse hooks no longer fire for calls refused before they ran, so audit pipelines relying on them miss those calls.
  • PostToolBatch receives most refused calls, without marking them as refused.
  • Code Mode no longer runs UserPromptSubmit hooks on script output, so redaction needs a PostToolUse hook with updatedToolOutput.

When the sandbox cannot start

A sandbox that quietly fails to start is a risk, because a developer may believe commands are contained when they are not. Claude Code 2.1.328 changes how this is reported. Unless sandbox.failIfUnavailable is set, the next sandboxed Bash command is refused, and the message says that the sandbox is off for the session. The developer learns about the failure at the first command that would have relied on it, rather than running unconfined without notice.

Hook-rewritten commands and the sandbox

A second change affects commands that a PermissionRequest hook rewrites. When a hook rewrites a shell command into one that is excluded from the sandbox, the command now runs outside the sandbox. Teams that use PermissionRequest hooks to rewrite commands should review any rewrite that targets a sandbox-excluded command, since this is now where it executes.

Managed PostToolUse hooks and refused calls

Managed PostToolUse hooks no longer fire for calls that were refused before they ran. That means no log entry, rewrite, block or stop from those hooks for refused calls. PostToolBatch still receives most of them, and they are not marked as refused. Organizations that audit through PostToolUse should move refusal tracking to PostToolBatch.

Related Code Mode note

Code Mode also stops running UserPromptSubmit hooks, managed ones included, on scripts' output. To redact that output, Anthropic recommends a PostToolUse hook with updatedToolOutput.

Why it matters

All of these decide whether the agent acts inside or outside the boundary the user expects. The sandbox startup change makes a silent failure loud, and the hook changes spell out where rewritten and refused calls sit relative to that boundary.