A coding agent that can run shell commands is only as safe as whatever sits between a command and your machine. On 18 November 2026 OpenAI published an engineering post, "Inside the Codex sandbox" by Michael Bolin, describing how Codex confines the commands it runs on a user's own computer.[1] It is unusually specific about mechanisms and unusually frank about gaps. This article reads it alongside the documentation of the components it relies on, and turns it into a checklist you can apply to any agent tool. For the wider threat model, see how AI agents work and how to secure them and prompt injection defences that work by design.
What the default profile allows
Codex is designed to work in the user's existing environment rather than inside a container or virtual machine, and the sandbox restricts what the commands it launches can touch.[1] OpenAI describes it as one layer of "defense in depth" next to training and alignment. For the built-in :workspace profile, with a Git repository as the workspace root, the post gives these defaults:[1]
| Resource | Default in the workspace profile |
|---|---|
| Filesystem writes | Allowed inside the workspace; .git and .codex stay read-only |
| Filesystem reads | Broad, subject to normal OS permissions |
| Network | Disabled |
Making .codex read-only matters because it prevents a sandboxed command from editing .codex/config.toml or Git hooks, two ways a process could otherwise widen its own future permissions.[1] The broad read default is the notable choice: the post acknowledges that sensitive files elsewhere on the machine may remain readable.
How the harness hands out permission
One API, spawn_command_under_sandbox(), takes a command, a permission profile and an optional network proxy, and works across macOS, Linux and Windows. Child processes inherit the restrictions.[1] The main consumer is the exec_command shell tool. For each command the model can request one of three levels, and the harness decides whether to grant it:[1]
use_default: the turn's default sandbox configuration applies.with_additional_permissions: expanded filesystem or network access, still inside the sandbox.require_escalated: run outside the sandbox, with a justification shown to the user.
The harness evaluates these requests against user preferences. Codex may prompt the user or route the request to auto-review; the post does not define named approval modes beyond this.[1] The design point to take away is that the model asks and the harness decides, so a manipulated model can request more, but cannot grant itself more.
Profiles live under [permissions] in config.toml and can extend built-in ones. Filesystem entries use read, write or deny, with glob support such as **/*.env. Tables merge recursively with higher-precedence sources winning, arrays are replaced whole, and managed requirements.toml policy, including cloud-provided policy, can restrict which profiles users may choose.[1]
Three operating systems, three mechanisms
The enforcement layer differs per platform, and the differences matter when you assess a tool.
| Platform | Mechanism | Notes from the post |
|---|---|---|
| macOS | Seatbelt via /usr/bin/sandbox-exec, policies in SBPL | Base policy starts with (deny default). Apple has deprecated the interface; OpenAI plans to keep using it for now. |
| Linux | codex-linux-sandbox using bubblewrap, then seccomp-bpf | Separate network namespace; seccomp blocks connect(2) and bind(2) when networking is off; no_new_privs set. |
| Windows | Moving to Microsoft's MXC library | The earlier sandbox needed elevated setup and left persistent host state such as ACLs and firewall rules. |
All three rows are from OpenAI's post.[1] Two companion projects are worth reading directly. Bubblewrap's own documentation says it "is not a complete, ready-made sandbox with a specific security policy": protection "is entirely determined by the arguments passed to bubblewrap," and "everything mounted into the sandbox can potentially be used to escalate privileges."[3] In other words, bubblewrap supplies the primitives (user, PID, network and mount namespaces, and PR_SET_NO_NEW_PRIVS to neutralise setuid binaries) and Codex supplies the policy. Microsoft's MXC describes itself as a "sandboxed code execution system" for untrusted code such as model output, builds on Bubblewrap by default on Linux and Seatbelt on macOS, and says some of its backends "are experimental."[4] The Windows migration is therefore a move onto a young component, which is a reasonable thing to watch.
The network proxy: where policy actually lives
When the network is neither fully off nor fully open, Codex runs codex-network-proxy, with HTTP and SOCKS5 listeners whose addresses reach sandboxed processes through variables such as HTTP_PROXY and ALL_PROXY. Programs that ignore those variables are stopped by the OS sandbox, which blocks direct connections.[1] The proxy's README describes the rules:[2]
- Allowlist first: "if
domainshas noallowentries, requests are blocked until an allowlist is configured." - Deny wins: entries marked
deny"always override the allowlist." - HTTPS CONNECT targets, including WebSocket tunnels, face the same host checks.
- Matching is ASCII case-insensitive and does not convert between Unicode and Punycode, so internationalised domains must be written in Punycode.
- Allowlisted hostnames that resolve to local or private addresses are still blocked, on a best-effort lookup.
For a domain with no matching rule the proxy can hold the request while the harness asks for approval, and the post says DNS resolution happens only after a request is allowed or approved, because a hostname lookup can itself leak data.[1] The README is candid that DNS rebinding "is not fully preventable at this layer" and advises enforcing egress lower down, in a firewall, VPC or corporate proxy, if hostile DNS is in your threat model.[2]
The limits OpenAI lists itself
This is the most useful part of the post. Its stated limits include:[1]
- Broad reads leave sensitive files outside the workspace readable.
- Harmful actions remain possible within allowed writes. The example is tampering with a locally installed
node_modules/prettierthat later runs when an editor formats on save, outside the sandbox. - Wildcard rules and DNS access can still permit DNS-based exfiltration.
- Deny globs are expanded to concrete paths at launch, so files created later that match them are not restricted during that command.
- Stdio MCP servers are not sandboxed by default, because "Codex cannot reliably infer which files or network services that server needs."
- Seatbelt depends on a deprecated interface with undocumented SBPL, and the Windows sandbox is mid-migration.
Our interpretation: items 2 and 5 are the pattern to internalise. A sandbox bounds the process it wraps, but a project directory is also an input to other tools, and an agent's helper servers are separate processes. Both are paths around the boundary that no OS rule can close without knowing your workflow.
A checklist for any agent sandbox
This list is our synthesis, not OpenAI's. It uses the Codex design as a reference.
- Is enforcement done by the operating system or by prompts to the model?
- What can it read, not only write? Many tools restrict writes and leave reads open.
- Are the files that control the agent's own permissions, such as config and hooks, protected?
- Is the network off by default, and if proxied, do deny rules beat allow rules and does an empty allowlist block?
- What happens on DNS? Broad wildcards can leak data through lookups.
- Do helper processes, such as MCP servers, run inside the same boundary?
- Can you test a profile? Codex provides
codex sandbox --permission-profile <name> -- <command>, and the post shows a write to.vscode/settings.jsonfailing with "Operation not permitted" under a restrictive profile.[1]
What we have not verified
We read the post and the three linked projects' own pages. We did not run Codex, test the profiles or audit the source, so every behaviour above is as documented by OpenAI, bubblewrap and Microsoft, not as we observed it. The post is the vendor's own description of its design.




