Inside the Codex Sandbox: Permissions, Proxies, and Platforms
Codex often runs shell commands on a user's own machine, which is both its main source of usefulness and a serious risk. OpenAI's answer is a sandbox that constrains those commands to filesystem and network limits the user sets, rather than moving work into a separate container or VM.
Codex often runs shell commands on a user's own machine, which is both its main source of usefulness and a serious risk. OpenAI's answer is a sandbox that constrains those commands to filesystem and network limits the user sets, rather than moving work into a separate container or VM.
The author's central choice is to sandbox commands inside the developer's existing environment instead of relocating them. A Docker container would break workflows like building an iOS app on a Mac, where native toolchains and the simulator must run on the host. So Codex uses each operating system's own isolation facilities through one shared API that takes a command and a permission profile. The built-in `:workspace` profile allows writes inside the workspace but keeps `.git` and `.codex` read-only, permits broad reads subject to existing OS permissions, and disables network access by default. That default blocks data exfiltration but also blocks legitimate dependency downloads, and the author concedes it does not stop everything: an agent could tamper with an installed package such as `node_modules/prettier`, which Git may ignore, and a later editor save could execute it outside the sandbox. Hence the defense-in-depth framing, where training and alignment complement the sandbox. Network limits are enforced by a proxy that checks each request against domain rules and resolves hostnames only after approval, since even a DNS lookup can leak information. On macOS the sandbox uses Seatbelt via `sandbox-exec`; on Linux it uses bubblewrap with a separate network namespace and a relay process outside the sandbox; on Windows OpenAI is replacing its earlier sandbox with Microsoft's MXC library to avoid admin setup and persistent host state. The `codex sandbox` command exposes the same mechanism outside an agent session, and the author shows using it to wrap an MCP server's `npx` launch in a restrictive profile, after pre-caching the package so the server can run offline.
OpenAI's position is that agent safety comes from layered limits, not a single boundary: conservative sandbox defaults plus model training, with escape hatches that the harness, not the model, decides to grant. Builders running agents on developer machines should expect to define explicit permission profiles and to wrap their own tools and MCP servers with `codex sandbox` rather than trusting default execution.