← Claude Docs

Sandboxing - Claude Code Docs

Claude Docs · April 18, 2026
Claude Code features native sandboxing using OS-level primitives to enforce filesystem and network isolation, reducing the need for constant permission prompts while maintaining security boundaries. The sandbox restricts write access to the current working directory by default while allowing reads across most of the system, and controls network access through a proxy server that only permits approved domains. Users can enable sandboxing through the /sandbox command and customize behavior through settings to grant subprocess write access to specific paths outside the project directory.

Detailed Analysis

Claude Code's native sandboxing capability represents a significant architectural shift in how Anthropic's agentic coding tool manages security during automated task execution. Rather than relying on a continuous stream of user approval prompts for each bash command, sandboxing establishes predefined security boundaries at the operating system level before execution begins. The system uses platform-native primitives — Seatbelt on macOS and bubblewrap on Linux and WSL2 — to enforce both filesystem and network isolation at the kernel level. By default, sandboxed commands receive read access across the filesystem but restrict write operations to the current working directory and its subdirectories. Network access is routed through a proxy server that filters outbound traffic by domain, requiring user confirmation for new or unapproved hosts. Developers can extend these defaults through a `settings.json` configuration file, granting write access to specific paths such as `~/.kube` or `/tmp/build` via the `sandbox.filesystem.allowWrite` directive.

The design directly targets a well-documented problem in human-AI collaboration: approval fatigue. When agentic systems require constant per-command authorization, users tend to rubber-stamp requests rather than evaluate them critically, paradoxically weakening security through the very mechanism meant to enforce it. Claude Code's sandboxing reduces this friction by auto-approving commands that operate within defined boundaries, while still triggering prompts only when an action would breach the established perimeter. The tool offers two modes — auto-allow and regular permissions — giving teams flexibility to balance autonomy against oversight depending on their risk tolerance. For managed enterprise deployments, the `sandbox.failIfUnavailable` flag converts missing dependencies into a hard failure rather than a silent fallback, making sandboxing a genuine security gate rather than a best-effort feature.

Several practical limitations temper the security guarantees. The sandbox applies to bash commands and their subprocesses, but Claude Code's separate Read file tool operates outside the sandboxed bash environment, meaning `sandbox.denyRead` rules do not block reads performed through that tool. This distinction is not merely academic: in agentic workflows where Claude autonomously chains tool calls, a determined model or a prompt-injection payload could potentially exfiltrate data through the Read tool even when bash-level network access is blocked. Additionally, the default soft-fallback behavior — running commands without sandboxing when dependencies like bubblewrap are absent — means developers must actively configure stricter failure modes to avoid silently degrading to an unsandboxed state. These gaps align with a broader pattern in security engineering where layered defenses are necessary; for strictly regulated enterprise environments, third-party options such as Docker microVM isolation or Cloudflare Workers-based sandboxing provide additional containment that the native solution does not fully replicate.

The release of native sandboxing reflects a broader industry reckoning with the security implications of agentic AI systems. As coding assistants evolve from single-turn responders into multi-step autonomous agents capable of spawning subprocesses, invoking infrastructure tools like Terraform and kubectl, and making outbound network calls, the threat surface expands considerably. Prompt injection — where malicious content in a repository or web page hijacks an agent's subsequent actions — is an increasingly documented attack vector, and filesystem and network containment directly limit the blast radius of such exploits. Anthropic's use of OS-level primitives rather than application-layer restrictions is notable because it prevents the model itself from circumventing controls; the kernel enforces boundaries regardless of what instructions Claude receives. This approach mirrors security patterns established in browser isolation (Chrome's per-tab sandboxing) and container runtimes, applying them to the emerging category of AI developer agents.

The configuration merge behavior across settings scopes adds an enterprise-relevant detail that signals Anthropic's intent to support hierarchical deployment policies. When `allowWrite` paths are defined in both managed (organization-level) and user-level settings, the arrays are merged rather than overridden, allowing administrators to establish a baseline while individual developers extend it without duplicating corporate policy. This composable model is consistent with how modern infrastructure-as-code platforms handle policy layering and suggests Claude Code is being designed with enterprise governance requirements — including compliance frameworks like SOC 2 and HIPAA — as first-class concerns. As AI coding agents become standard components in production software development pipelines, the industry will increasingly demand exactly this kind of auditable, policy-driven security architecture rather than ad hoc permission prompts.

Read original article →