Max Narditdata & ai systems
← Articles
8 mindev

Codex sandbox permission profiles vs the Claude Code sandbox: what each one walls off

On Ubuntu, a Codex profile with a one-host allowlist refused an unlisted site with a 403. Delete two lines that look like an unrelated feature switch and the same site answers 200, with no warning. Claude Code's network filter cannot go inert that way; it is off until you turn it on, and one permission mode walks through it.

Contents

On 18 November OpenAI published Inside the Codex sandbox, Michael Bolin’s account of how Codex walls off what it runs: Seatbelt on macOS, bubblewrap plus seccomp on Linux, and a newer Windows backend on Microsoft’s MXC library. Claude Code’s sandbox sits on the same two mechanisms on macOS and Linux, so the obvious question is whether the two walls are the same wall.

They are not, and the difference sits away from the shell. I ran Codex’s side on Ubuntu 24.04 with codex-cli 0.169.0 through codex sandbox, the wrapper that applies a permission profile to any command; that shares the OS enforcement with an agent session but not its approvals, so every result below is a wrapper result. The Claude Code side comes from my test of the Claude Code sandbox and srt a month ago. The result worth the whole exercise: a Codex domain allowlist can sit in your config, look complete, and not be enforced at all. Claude Code’s network filter can’t go inert like that. Its risks are a sandbox that starts switched off and one permission mode that walks through it.

What does the Codex :workspace profile wall off?

Writes outside the workspace and the temp directories, a short list of control paths at the workspace root, and the network. Per Bolin’s post and the permissions docs, :workspace keeps .git, .codex, .agents and .aws at each workspace root read-only, so a command cannot rewrite the project’s Codex config or plant a Git hook, and it leaves reads broad.

Whether you get it by default depends on how you start Codex. The approvals docs say the interactive CLI recommends workspace-write with on-request approvals for a version-controlled folder and can start read-only until you trust it; codex exec starts read-only. default_permissions itself has no default. So I selected the profile explicitly, with default_permissions = ":workspace" as the only line in a fresh config, and ran one codex sandbox command per row:

ProbeCodex :workspacesrt, October
touch ~/codex-probeRead-only file systemRead-only file system
write in the working directoryallowedallowed
write .git/hooks/pre-commitRead-only file systemRead-only file system
write .codex/config.tomlRead-only file systemnot tested
write to /tmpallowedRead-only file system
list ~/.sshallowedallowed
curl https://example.comCould not resolve hostblocked at the proxy
curl a server on the host’s 127.0.0.1Couldn't connect to serverCouldn't connect to server
UDP packet to 1.1.1.1:53socket: Operation not permittedNetwork is unreachable
git init sub, write its hook, same commandallowedallowed
write that hook again, next commandallowedRead-only file system

The last row is where they part. Under srt the next command rebuilt its deny list, found the new repository and protected it. Under Codex the nested repository’s hooks stayed writable, because the protection is defined for the workspace root’s .git, and sub was never a root. That is the rule as written, but a vendored clone or a scratch repo inside your project is not covered by it. The /tmp row follows the same logic: Codex counts the system temp directories as workspace, srt opened only its own temp directory. And listing ~/.ssh worked, which Bolin states himself:

The tradeoff is that sensitive files elsewhere on the machine may also remain readable (such as config files containing API keys).

How do you write a Codex permission profile?

In config.toml, as a [permissions] table that extends a built-in profile, selected with default_permissions. Built-in names start with a colon: :read-only, :workspace, :danger-full-access. Paths take read, write or deny, and the docs say deny wins over an equally specific read or write. Before copying one into an existing setup, check for a legacy sandbox_mode, in the file, in a selected config profile or from --sandbox on the command line: the docs say to configure one system or the other, and an effective sandbox_mode wins over default_permissions unless managed requirements say otherwise. A profile that never takes effect fails as quietly as anything below.

This is the profile I tested, in its own CODEX_HOME:

toml
default_permissions = "lab"
 
[features]
network_proxy = true
 
[permissions.lab]
description = "Workspace plus one allowed host, no ssh keys"
extends = ":workspace"
 
[permissions.lab.filesystem]
"~/.ssh" = "deny"
 
[permissions.lab.filesystem.":workspace_roots"]
"**/*.env" = "deny"
 
[permissions.lab.network]
enabled = true
 
[permissions.lab.network.domains]
"example.com" = "allow"
ProbeResult under lab
list ~/.sshPermission denied
read an existing app.envPermission denied
create new.env and read it, same commandallowed
read new.env, next commandPermission denied
curl https://example.com200
curl https://www.wikipedia.orgCONNECT tunnel failed, response 403
curl --noproxy '*' to the allowed hostCould not resolve host

A denied path fails loudly here; under srt a denied directory looked empty, because bubblewrap mounted an empty tmpfs over it. The .env pair is the gap Bolin and the docs both describe: on Linux, deny globs are expanded into concrete paths when a process starts, so a file created later stays readable to that process. One command is a short window. A long-lived process inside one sandbox, a wrapped server for instance, keeps it open for its whole life. My app.env sat at the top level; how deep a glob is expanded is bounded on some platforms (glob_scan_max_depth), so probe the depth your secrets actually sit at.

The 403 is the wrapper’s answer. In an agent session, Bolin writes, a domain the rules don’t match goes to an approval, either your prompt or auto-review, while the command stays sandboxed. That is a different thing from require_escalated, which asks to run the command outside the sandbox altogether.

Why does a Codex domain allowlist need an active network proxy?

Because the domain list is enforced by the proxy, and nothing in a profile starts the proxy. network.enabled = true opens the network; whether that network goes through a filter is decided by [features] network_proxy = true or by an admin’s managed network settings. I deleted the two [features] lines from the profile above and ran the same command:

shell
codex sandbox -- curl -sS -o /dev/null -w "%{http_code}\n" https://www.wikipedia.org
# with network_proxy = true:   403
# with [features] deleted:     200

The ~/.ssh deny still held. Codex printed no warning and started as usual; the domain list just stopped being enforced. The permissions page does document this, in a list of combinations: network off is off whatever the proxy says, network on with the proxy off is direct, unrestricted access, and adding domain rules does not turn the proxy on. It is still the easiest mistake in this config to make, because the allowlist looks like the control and the switch looks like an unrelated feature toggle. The only check that tells them apart is a request to a host you never allowed, plus one to a host you did, so that an offline machine can’t pass by refusing everything.

With the proxy on, Bolin lists what it still doesn’t solve: programs that ignore proxy variables (they fail, since direct connections are blocked), and DNS-based exfiltration through broad wildcards. Add the plainer one: whatever a command prints goes back to the model as tool output, network or not. That is the inventory problem from every way out of the sandbox, and here a vendor is naming some of its own entries.

How does the Codex sandbox compare with the Claude Code sandbox?

On the shell they enforce similar things. The differences are in what else passes through the wall, and in how each one’s network filter fails:

CodexClaude Code
Shell sandbox out of the boxinteractive: workspace-write recommended for a Git folder; codex exec: read-onlyoff until /sandbox or sandbox.enabled
File reads and edits by the agentthrough the same sandbox infrastructure, per BolinRead, Edit, Write run outside, under permission rules
Linux mechanismbubblewrap + seccompbubblewrap + socat, seccomp filter optional
Read-only inside the workspaceroot .git, .codex, .agents, .aws.claude settings, .mcp.json, .git/hooks, .git/config, among others
Reads by defaultmost of the machinemost of the machine, ~/.ssh included
Network, sandbox onoff unless the profile enables itthrough the built-in proxy, allowlist starts empty
Domain rules enforced whena proxy is active (feature flag or managed)always, while the sandbox is on
Unlisted hostwrapper: refused; session: approval or auto-reviewprompt in default mode, allowed in bypassPermissions unless strict
Leaving the sandboxrequire_escalated, subject to approval policyunsandboxed retry, unless allowUnsandboxedCommands is false
WindowsMXC: preferred by the desktop app, opt-in for the CLIunsandboxed natively, use WSL2

The file-tools row is the one I would underline. Bolin says the Codex harness reuses its sandbox for operations such as reading and modifying local files, while Claude Code’s sandbox docs say its file tools follow permission rules instead, so a denyRead entry doesn’t stop the Read tool. A credential you deny in a Codex profile is denied to the agent’s file access too. In Claude Code you need a permission rule as well.

The network rows carry the asymmetry. In my October test, with the sandbox on, an empty allowlist and the unsandboxed retry turned off, a curl to an unlisted host was blocked in default mode and returned 200 in bypassPermissions, while a write to the home directory still failed. The docs confirm that mode allows unlisted hosts unless sandbox.network.strictAllowlist or allowManagedDomainsOnly is on, and with the retry left at its default, a failed command can also rerun unsandboxed without a prompt. So Claude Code’s filter fails because of a mode you chose, and Codex’s because of a switch you never set.

What do the Codex and Claude Code sandboxes leave outside?

Stdio MCP servers, in both. Bolin says the Codex harness does not sandbox the command that starts one, because it cannot infer what the server needs; the docs add that the command proxy does not cover MCP connections, web search, connectors or the model’s own requests. Claude Code’s docs put local MCP servers, hooks, the status line and LSP servers outside with full access. You can pull a server in yourself, with codex sandbox --permission-profile as the server’s command in Codex (add --include-managed-config in 0.169.0 if admin requirements should apply, since an explicit profile skips them otherwise) or srt around it for Claude Code. Either way you write its policy, including the reads it needs: Bolin’s own npm example limits writes and cuts the network but still reads broadly.

Bolin adds one exit no command sandbox closes: a write the workspace permits, say to a formatter under node_modules, that your editor later runs with your full access. Willison’s external sandboxes note describes the other way to draw the line: the agent stays outside and sends code to a VM or container behind a localhost API, and he names Codex and Claude Code among the agents that can use one.

Which Codex and Claude Code sandbox settings should you check first?

In Codex, whether your profile is in effect at all (no sandbox_mode left over), and whether a proxy is active wherever a profile turns the network on. In Claude Code, whether the sandbox is on; then sandbox.network.strictAllowlist if you ever use bypassPermissions, sandbox.allowUnsandboxedCommands: false so a failed command can’t retry outside, sandbox.failIfUnavailable so a missing dependency stops startup instead of running unsandboxed, and a look at sandbox.excludedCommands. For keys, both need explicit read denies, and Claude Code needs a Read permission rule next to the sandbox entry.

My read: Codex starts from the stronger position, with the wall on, the network off and the agent’s own file access inside the boundary. But its network control has a failure mode Claude Code’s lacks, an allowlist that is never enforced and never says so. So for Codex I would trust the profile only after two probes the docs won’t run for you: an unlisted host and an allowed host under the profile you actually use, and a hook write into a nested repository if your project contains one. In Claude Code, ask the agent to run the same network pair rather than typing them after !, which runs outside the sandbox, and decline any offer to retry unsandboxed.

01 / Discussion

No comment section here — all discussions happen on X.

Max Nardit@mnardit

02 / More articles