OpenAI shows how the Codex sandbox restricts agent commands on your computer
An agent that runs commands on your laptop needs boundaries, and OpenAI has shown how the Codex sandbox sets them. Instead of Docker, it uses the built-in sandboxing tools of macOS, Linux and Windows, so the agent works in your familiar environment. By default, writes are allowed only in the working folder, and the network is off. So it makes sense to create a separate permissions profile for each task rather than hand out full access.
AI-processed from OpenAI Blog; edited by Hamidun News
The riskiest thing a coding agent does is run commands on your computer. One bad rm or a quiet upload of files to someone else's server, and you feel the consequences immediately. OpenAI engineer Michael Bolin has broken down how the Codex sandbox works. It limits what the agent's commands can access, and it does so without virtual machines.
Why not Docker
The usual way to isolate a program is a container or a virtual machine. OpenAI took a different path: Codex uses the operating system's own sandboxing tools and restricts commands within your normal environment.
The team's argument is practical. A developer's laptop is a collection of personal settings and tools, and reproducing it in Docker is not easy. The article gives an example: you are writing an iOS app on a Mac.
Inside a container, Codex cannot run a native build or the iPhone simulator. You can hand those operations to the host, but then they run outside the sandbox and need their own restrictions. So OpenAI is investing in system-level isolation for each platform.
macOS, Linux and Windows share a single programming interface: you pass it a command and a permissions profile, and, if restricted network access is allowed, a network proxy as well. All child processes inherit the parent's restrictions, even those that outlive the original command.
What is allowed by default
The built-in :workspace profile picks cautious defaults that still let the agent do its job:
- Writing is allowed only in the project's working folder. The .git and .codex directories stay read-only, so the agent cannot tamper with Git hooks or the Codex config.
- Reading is allowed almost everywhere, within normal OS permissions. Compilers and build tools need libraries outside the repository. The article is upfront about the downside: files with API keys in other locations may also end up readable.
- The network is off. This blocks direct data exfiltration, but it also prevents downloading dependencies.
OpenAI openly admits that the protection is incomplete. In theory, an agent could slip malicious code into a local package, such as node_modules/prettier. Git usually ignores such folders, and if your editor runs that Prettier when you save a file, the code executes outside the sandbox. That is why the company calls its approach "defense in depth": the sandbox limits access, while model training and alignment govern how the model uses it.
How to configure profiles
Permissions are defined in config.toml as named profiles. Each path gets read, write or deny, and a profile can inherit from a built-in one. In the example, the dev profile extends :workspace: it grants write access to ~/build-cache, makes .vscode and .devcontainer read-only, and fully blocks .env files and the secrets folder.
The network has three options: off entirely (the default), fully open (the :danger-full-access profile), or traffic routed through a proxy with per-domain rules. The rules support exact names and wildcards, and an explicit deny takes precedence over allow. Requests to all other domains are either blocked or require confirmation.
Companies get layered configuration. Tables from different config.toml files are merged recursively, while arrays are replaced wholesale. Through requirements.toml, an administrator sets a list of permitted profiles, for example allowing :read-only and forbidding :danger-full-access. Cloud requirements take priority over the local /etc/codex/requirements.toml file, and users cannot bypass the ban.
The model can also ask for more permissions for an individual command: expanded access inside the sandbox, or running outside it. The model does not make that call; the harness does. It will either ask the user or send the request to automatic review.
A sandbox for your own tools
The codex sandbox command is useful in its own right. It runs any process under a profile from the Codex config, and it is a handy way to test your own rules. In the example, an attempt to write a malicious .vscode/settings.json under the dev profile on macOS fails with "Operation not permitted".
The second idea is to isolate MCP servers. Codex does not try to restrict them itself: it does not know which files and networks a server needs. As a result, a server launched through npx runs with the user's full permissions. OpenAI suggests wrapping the command in codex sandbox with a memory-mcp profile: write access only to ~/mcp-data and ~/.npm, no network, the package pinned to a version and launched through npx --offline. The data directory and the npm cache must be prepared in advance.
The takeaway for teams: don't leave the agent with full access. Create a profile for each task, lock down secrets with deny, and test the rules against known-bad commands. If this setup seems like overkill, remember Prettier: the sandbox reduces the risk, but does not eliminate it entirely.
- Nov 29, 2026Stargate Data Center in Abilene Is Poaching Electricians: Paying at Least Three Times More
- Nov 29, 2026Google Is Not Banning Your Entire Account Over T3 Code: Only Antigravity Gets Shut Off for Gray-Area Plugins
- Nov 29, 202632 free skills for Claude from 9 GitHub repositories with 252K stars
- Nov 29, 2026Claude Code, Codex and OpenCode Wire Up MCP Differently: The Registry Holds 50,000 Servers
Key Questions Answered
Why not Docker?
The usual way to isolate a program is a container or a virtual machine. OpenAI took a different path: Codex uses the operating system's own sandboxing tools and restricts commands within your normal environment. The team's argument is practical. A developer's laptop is a collection of personal settings and tools, and reproducing it in Docker is not easy. The article gives an example: you are writing an iOS app on a Mac. Inside a container, Codex cannot run a native build or the iPhone simulator.
What is allowed by default?
The built-in :workspace profile picks cautious defaults that still let the agent do its job: Writing is allowed only in the project's working folder. The .git and .codex directories stay read-only, so the agent cannot tamper with Git hooks or the Codex config. Reading is allowed almost everywhere, within normal OS permissions. Compilers and build tools need libraries outside the repository. The article is upfront about the downside: files with API keys in other locations may also end up readable.
How to configure profiles?
Permissions are defined in config.toml as named profiles. Each path gets read, write or deny, and a profile can inherit from a built-in one. In the example, the dev profile extends :workspace: it grants write access to ~/build-cache, makes .vscode and .devcontainer read-only, and fully blocks .env files and the secrets folder. The network has three options: off entirely (the default), fully open (the :danger-full-access profile), or traffic routed through a proxy with per-domain rules.
Free 2-Day Vibecoding & AI Agents Intensive
Day 1: the autonomous Hermes + DeepSeek AI agent — vibecoding and development on par with Claude Code / Codex / Gemini. Led by Jemal Hamidun, Head of AI at Alpina Digital and academic supervisor at MIPT. Right after you register with our bot Nika: the recording + 11 materials from the previous intensive.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
