Inside the Codex sandbox
Codex sandboxes agent-run commands in the user's own environment by using each OS's native sandboxing facilities rather than VMs or containers, so native toolchains like Xcode and the iOS simulator keep working. The default :workspace profile allows writes inside the workspace but keeps .git and .codex read-only, allows broad reads, and disables network access. That still leaves risks such as tampering with ignored node_modules, which is why OpenAI treats the sandbox as one layer of defense in depth. The post covers the cross-platform spawn API, per-command permission escalation in the exec_command tool, TOML permission profiles with filesystem and domain rules, a network proxy, and layered enterprise managed requirements, before describing enforcement on macOS, Linux and Windows.
Related posts
- Running Codex safely at OpenAI
OpenAI mediumAdept
OpenAI runs Codex internally inside a bounded environment. A sandbox limits where it can write and whether it can reach the network, approval policies make higher-risk actions stop for review, and an auto-review subagent approves routine low-risk requests so users are not constantly interrupted. Admin-enforced requirements files cover network allow/deny lists through a proxy, Starlark prefix rules for shell commands, and OS-keyring credential storage pinned to an enterprise ChatGPT workspace. OpenTelemetry export of prompts, approval decisions, tool results and proxy events feeds a SIEM and an AI security triage agent that explains why the agent did something, not just what happened.
- Sandboxing
Zed mediumAdeptZed's agent panel now sandboxes the terminal and fetch tools by default (from 1.14) using OS-enforced restrictions: Seatbelt on macOS, Bubblewrap namespaces on Linux, and WSL on Windows. Default rules block writes outside project directories, writes to .git (which could plant hooks that run unsandboxed), and network access, and agents must request escalation with a stated reason. Instruction-following and command-matching rules like banning `git .*` are trivially bypassed via shells, env vars or other interpreters, and a symlink-swap TOCTOU race between user approval and bwrap bind mounting could grant write access to arbitrary readable directories, which Zed detects and fails closed on. The sandbox is one defense layer and does not cover the edit tool, ACP agents, LSP/MCP servers, build.rs, proc macros or git hooks run outside it.
- Making Claude Code safer with sandboxing
Anthropic Engineering mediumAdeptClaude Code now sandboxes its bash tool using OS-level primitives (Linux bubblewrap, macOS seatbelt) to enforce filesystem isolation (writes limited to the working directory) and network isolation (traffic forced through a Unix domain socket to an external proxy that allowlists domains), covering all spawned subprocesses. Both boundaries are required, since without network isolation a prompt-injected agent can exfiltrate secrets and without filesystem isolation it can escape the sandbox. Internally this cut permission prompts by 84%, and the runtime is open-sourced for sandboxing other agents and MCP servers. Claude Code on the web runs sessions in cloud sandboxes that never hold real credentials. A git proxy validates a scoped credential and the push target before attaching the GitHub token.
- Building a safe, effective sandbox to enable Codex on Windows
OpenAI hardMaster
Codex on Windows lacked an OS-level sandbox, so OpenAI built one from Windows primitives after rejecting AppContainer (too narrowly scoped for open-ended dev workflows), Windows Sandbox (separate VM, unavailable on Home SKUs) and Mandatory Integrity Control labels (turns the workspace into a low-integrity sink). The first unelevated prototype used synthetic SIDs plus write-restricted tokens and ACLs to confine writes to the workspace. Its network blocking relied only on poisoned proxy environment variables and PATH stubs, which any process could bypass. The current elevated design runs commands as dedicated local users (CodexSandboxOffline/Online) so Windows Firewall rules can block outbound traffic per principal, at the cost of an admin-required setup step that creates users, stores DPAPI-encrypted credentials and installs firewall rules.
- Why AI Agents Need Isolation
Docker easyNoviceAI coding agents that run commands, install packages and handle credentials should execute behind an isolation boundary rather than directly on the developer's host. Docker Sandboxes (sbx) runs agents in microVMs instead of plain containers, because containers share the host kernel. Docker built its own VMM rather than using Firecracker so the same model works on macOS and Windows as well as Linux. Credentials stay on the host: the agent sees a sentinel placeholder, and a proxy swaps in the real auth header on outbound requests. Sandbox Kits package tools, network rules, credentials, files, startup commands and agent memory (e.g. AGENTS.md) into reusable specs, either as stackable Mixin Kits that extend an existing agent or as Agent Kits that define a full agent environment from scratch.