What is a sandbox?

A sandbox is an operating-system boundary on what the commands an agent runs can read, write and reach on the network. It is separate from approval, which decides whether a command runs at all. Claude Code sandboxes Bash with Seatbelt on macOS and bubblewrap on Linux and WSL2; Codex offers --sandbox read-only, workspace-write and danger-full-access.

Last updated
By
Published
In Polish
Sandbox
First set up at
Level 2, free guide
Also searched as
sandboxing, sandbox policy, OS sandbox

$59.99 once for 12 months of access. Nothing renews on its own. 30-day refund on a first purchase.

On this page Why it mattersThree layers every agent run needsHow each tool does itQuestions

Why it matters.

Approval and the sandbox answer different questions. Approval decides whether a command runs and who says yes; the sandbox limits what a running command can read, write and reach. A deny rule on Bash(curl *) stops curl, not python -c opening a socket; the sandbox stops both. A reviewer model such as auto mode judges intent and does not contain a process, so run it inside the sandbox, not instead of it.

One connection, two layers

A deny rule on Bash(curl *) and an OS sandbox, each facing a socket opened with python -c.

  • Judges the command text
  • A process or boundary that runs
  • What you can rely on

Approval rule Reads the command

  1. The rule

    Bash(curl *) in permissions.deny

    The approval layer judges the command string before it runs.

  2. The command

    python -c opens a socket

    No curl in the text. sh -c 'curl …' slips past the same rule.

  3. The check

    No pattern matches

    The rule stops curl. It does not stop the socket.

  4. What you can rely on

    The spellings the rule matches

    Treat command rules as a first filter; the network allowlist is the egress control.

OS sandbox Enforced by the OS

  1. The boundary

    Sandbox with a domain allowlist

    The operating system enforces it on the running process: Seatbelt on macOS, bubblewrap on Linux and WSL2.

  2. The command

    python -c opens a socket

    The same command, to a host that is not on the allowlist.

  3. The check

    The sandbox proxy stops the connection

    An unlisted host is stopped at the proxy: its first use prompts, or the classifier decides in auto mode, and strictAllowlist denies it outright.

  4. What you can rely on

    Both are stopped

    In Claude Code it covers shell commands only: Read, Edit and Write obey permission rules, not the sandbox.

Unattended runs need both, plus a network allowlist. A reviewer model such as Claude Code’s auto mode judges intent; it does not contain a process. Source: Permissions and sandboxes guide, Claude Code 2.1.283, 2026-09-26.

Three layers every agent run needs

The vendors use different words for the same three questions. A strong answer to one does not cover the others.

The three layers of an agent run, and what Claude Code, Codex and Cursor call each.
LayerThe question it answersClaude CodeCodexCursor
Approval Does this action run, and who says yes? Permission modes and allow/ask/deny rules Approval policy and auto-review Run modes: Auto-review, Allowlist and Run Everything
OS sandbox What can a running command read and write? Sandboxed Bash tool Sandbox or permission profile Sandbox for shell commands
Network egress Where can a running command connect? Sandbox proxy with a domain allowlist Profile network setting Not verified

Outside all three sits the outer boundary: the laptop, container, VM or cloud environment the agent runs in, and its credentials. Source: Permissions and sandboxes guide, 2026-09-26.

How each tool does it.

Cursor, Claude Code and Codex each name this their own way. Each note carries the date it was checked.

Cursor

Cursor’s Run modes page lists Auto-review (the recommended default since Cursor 3.6), Allowlist and Run Everything, and says Auto-review is not a security boundary (checked 2026-10-12). Sandboxing can be switched on per run through the SDK (local.sandboxOptions), and /sandbox is listed among the CLI slash commands. The default write boundary and network are not verified.

Permissions and sandboxes guide (Cursor), 2026-09-26

Claude Code

Sandboxed Bash: Seatbelt on macOS, bubblewrap on Linux and WSL2, not native Windows. It covers shell commands only; Read, Edit and Write follow permission rules.

If bubblewrap or socat is missing, Claude Code warns and runs commands unsandboxed unless sandbox.failIfUnavailable is true in managed settings. Run /sandbox in a session: if it shows only a Dependencies tab, the sandbox is not running.

Permissions and sandboxes guide, Claude Code 2.1.283, 2026-09-26

Codex

--sandbox read-only, workspace-write or danger-full-access; permission profiles (beta) are preferred, and the two systems do not compose.

Approval is a separate setting: codex exec always runs with approval never unless you pass --approve-for-me, and the :workspace profile writes the workspace but grants no network.

Permissions and sandboxes guide, Codex 0.157.1, 2026-09-26

Questions about the sandbox.

Is a sandbox the same as an approval mode?

No. Approval, meaning Claude Code’s permission modes or Codex’s approval policy, decides whether an action runs and who says yes. The sandbox limits what a running command can read, write and reach. Setting approval_policy = "never" in Codex removes the prompts but does not widen or narrow the sandbox, so set both explicitly.

Does a sandbox cover everything the agent does?

No. Claude Code’s sandbox covers shell commands only; the Read, Edit and Write tools obey permission rules instead. Outside every layer sits the environment itself: the container or VM the agent runs in and the credentials it holds.

Does a sandbox matter in a headless run?

Yes, because nobody can answer a prompt. codex exec always runs with approval never, so a command that needs approval outside the sandbox is refused. claude -p starts in Manual mode (auto mode on third-party providers or with telemetry off, from v2.1.285), so pass --permission-mode dontAsk to deny whatever would prompt on every provider, and you turn its sandbox on explicitly, for example with --settings '{"sandbox":{"enabled":true,"allowUnsandboxedCommands":false}}'.

Is --full-auto still a Codex flag?

Not in 0.157.1: it is gone from codex --help. -a accepts only on-request and never, and the sandbox is a separate choice: --sandbox read-only, workspace-write or danger-full-access.

Does this page answer your questions?

One tap, no sign-in.

not at all fully

Read the guides in the same words.

Open every guide with the Toolkit. Each term is defined once here, and the guides use it the same way.

$59.99 once for 12 months of access. Nothing renews on its own. 30-day refund on a first purchase.