ReadingResearchRadarInvestment framework
Sign in / Sign up
← Back to reading
NewsMaterial5 min readDisconfirmAI Editorial

OpenAI Technical Staff Member Michael Bolin Explains Why Codex Chooses OS-Native Sandboxes Over Containers

Codex does not use Docker or virtual machine isolation; instead, it calls upon macOS Seatbelt, Linux bubblewrap with seccomp-bpf, and Windows MXC to constrain command file system and network access within the user's existing environment. The article provides specific implementation mechanisms and configuration examples for all three platforms.

2026-11-18 16:00 GMT+8

AI coding agents need to execute commands on the user's local machine, which creates a core contradiction: the agent must have access to dependencies such as compilers, runtimes, and SDKs, yet be restricted from arbitrarily reading sensitive files or uploading data externally. In an article, Michael Bolin, a member of OpenAI's technical staff, presents Codex's solution: rather than moving computation into containers or virtual machines, Codex leverages each operating system's native sandboxing mechanisms to constrain commands running in the user's existing environment.

This design choice is driven by specific reasons. Bolin uses iOS development as an example: if Codex were running inside a Docker container, it would be unable to invoke the iOS build toolchain composed of native Mac executables, nor could it launch the iPhone simulator. Delegating builds and simulator operations to the host machine means these operations fall outside the container's sandbox and require separate restrictions. The Codex team's judgment was that, rather than maintaining two layers of isolation, it is better to invest resources in building native sandboxes for each platform, allowing commands to always run in the environment most suitable for the task.

On macOS, Codex utilizes Apple's Seatbelt mechanism, applying policies written in Sandbox Profile Language (SBPL) via the /usr/bin/sandbox-exec command. SBPL is a Scheme-based language; Codex's baseline policy begins with (deny default), blocking all outbound connections by default and only opening explicitly allowed ports. When a network proxy is enabled, rules are injected into the policy to allow connections to the local HTTP proxy (localhost:3128) and SOCKS proxy (localhost:8081). The article notes that SBPL is not documented by Apple for third-party use, and the sandbox-exec command is marked as deprecated in its man page. However, macOS still provides Seatbelt configuration files in /usr/share/sandbox, and software such as Google Chrome continues to rely on it, so Codex plans to continue using it.

Sign in / Sign up
ReadingResearchRadarInvestment framework

The implementation on Linux is more complex, requiring the combination of two mechanisms. bubblewrap (bwrap) creates a view reflecting the permission profile's file system rules within an independent mount namespace, using --bind to specify writable paths, --ro-bind for read-only paths, and a combination of --perms 000 --tmpfs to deny access to specific directories. seccomp-bpf further filters system calls within the sandbox created by bwrap. Codex uses the seccompiler crate to dynamically compile BPF programs and apply them to the launched process, ensuring constraints are inherited by the entire process tree. When networking is disabled, seccomp blocks system calls such as connect(2) and bind(2); when a network proxy is enabled, IP sockets are allowed to connect to a loopback listener within the sandbox, but the creation of standalone Unix domain sockets is blocked by default to prevent access to host resources through them.

The mechanism for connecting to a network proxy in the Linux sandbox is noteworthy. Since bwrap creates an isolated network namespace via --unshare-net, processes within the sandbox cannot directly access the host's proxy port. Codex's solution is as follows: codex-linux-sandbox creates a pair of Unix domain sockets as a control channel and forks itself before launching bwrap; the child process remains outside the sandbox to run run_host_bridge(), waiting to receive the listener's file descriptor; the parent process execs into bwrap, launching a second instance of codex-linux-sandbox within the sandbox. This instance creates a loopback TCP listener in its own network namespace and passes the file descriptor to the child process outside the sandbox via the control channel. The process outside the sandbox accepts connections from programs inside the sandbox and forwards them upstream to the proxy, thereby establishing a pathway without exposing the host's network namespace.

Regarding Windows, OpenAI is migrating from its proprietary sandbox implementation to Microsoft's newly released MXC (Microsoft eXecution Container) library. MXC defines execution requests through a JSON configuration schema, covering file system read/write paths, denied paths, network egress rules, and controls over Windows resources such as the desktop and clipboard. Codex translates file system rules from the permission profile into MXC's readwritePaths, readonlyPaths, and deniedPaths, and translates network rules into egress defaults of deny with loopback allowance. MXC resolves issues with the previous implementation, including the need for administrator privileges, slow ACL operations, and persistent state left on the host machine.

Above the architecture, Codex's default permission profile :workspace embodies a conservative yet usable design philosophy: it allows writing within the workspace while keeping .git and .codex read-only, allows broad file system reads (subject to the user's existing OS permissions), and disables network access. Bolin explicitly points out the cost of this trade-off: sensitive files outside the workspace (such as configuration files containing API keys) can still be read. The article also provides a specific attack scenario: the agent could inject malicious code into node_modules/prettier. Since node_modules is typically ignored by Git, git status would not show changes; if the user's editor runs that copy of Prettier upon saving, the malicious code executes outside the Codex sandbox.

This is precisely why the Codex team emphasizes defense in depth: the sandbox limits what commands can access, while training and alignment help the model use that access according to the user's intent. For developers wishing to reuse this mechanism, the Codex CLI provides a sandbox command, which can constrain commands launched by their own tools using the same configuration language and platform-specific execution. The article provides a complete example of wrapping an MCP server in a sandbox, using codex sandbox --permission-profile memory-mcp to limit the npx-launched memory server to write only to the npm cache and data directory, with network access disabled.

Sources

  • openai.comOpenAI↗
Continue researching →