Codex sandbox: OpenAI maps the walls and the known leaks
OpenAI detailed how Codex sandboxes agent commands on macOS, Linux and Windows, including permission profiles and the gaps that remain.
If you let Codex run shell commands on your laptop, you can now see what fences it in and the gaps OpenAI acknowledges. OpenAI's Inside the Codex sandbox (Nov 18, 2026) explains how Codex constrains commands inside your existing environment instead of a VM or container. It uses Seatbelt on macOS and bubblewrap plus seccomp-bpf on Linux, with limits set by permission profiles in config.toml. On Windows, OpenAI says it is replacing its existing sandbox with one built on Microsoft's MXC library, which Codex supports on compatible Windows devices.
The built-in :workspace profile allows writes in the workspace but keeps .git and .codex read-only. It allows broad reads and turns the network off. OpenAI names the trade-off: config files holding API keys elsewhere on the machine may stay readable. You can define your own profiles with read, write or deny rules per path and route network traffic through a proxy that enforces domain allow and deny rules.
The post also says "harmful actions are still possible." Its example: the agent plants code in node_modules/prettier, git status doesn't show it, and the code runs outside the sandbox the next time your editor formats on save. Another gap is in the same post: Codex does not sandbox stdio MCP servers it launches, so OpenAI shows how to wrap them in codex sandbox --permission-profile yourself. In our reading, the sandbox only covers what Codex runs. Your editor, hooks and MCP servers are separate exposures to audit.
Independent checks add detail. A DEV Community write-up reports a check of CLI 0.170.0 that found two more gaps. On Windows, protection for .git, .codex, .agents and .aws covers only folders that already exist; the write-up doesn't say whether this was the existing Windows sandbox or the MXC-based one. Hard links created before a run let a sandboxed command change files in .git or outside the workspace. GetAgentTools confirmed the basic denials and the offline default on codex-cli 0.166.0, but tested only macOS. If you'd rather not trust the host sandbox at all, Beam describes running Codex with its sandbox off inside a disposable VM with an egress allowlist. That approach gives up the native toolchain access OpenAI's design is built around. It isn't clear yet whether OpenAI has responded to the reported Windows and hard-link gaps.
Try it: run a write you expect to be blocked through the helper, as GetAgentTools did: codex sandbox -P :read-only --log-denials -- touch s1.txt. It worked if you get Operation not permitted and no file appears. Then repeat the test against the profile you actually use.
Sources
- Inside the Codex sandbox · OpenAI
- Codex sandbox: read-only, workspace-write, danger-full-access, and what each one blocked in my test · GetAgentTools
- Your Coding Agent Runs Shell Commands on Your Laptop — Here's the Sandbox That Keeps It Honest · DEV Community
- Codex Sandbox: Modes, Approvals and Running Codex in a VM | Beam · Beam