Skip to main content
search

Coding agents don’t just suggest code anymore. They run commands on your computer. On November 18, 2026, OpenAI published Inside the Codex sandbox, a detailed engineering post on how the Codex sandbox limits what its agent can read, write and reach online, and where those limits stop.

If you read our guide to AI agent verification, you know a check only helps when the agent can’t quietly change it. The Codex sandbox applies that idea to your files and your network. Here is what it does by default, what it leaves open, and how to tighten it in a few minutes.

Watch the 2-minute version

Made by Momentum Hub. Prefer vertical video? Watch the Short, or find more on our YouTube channel.

Key takeaways

  • The Codex sandbox uses your operating system’s own isolation instead of a virtual machine or container: Seatbelt on macOS, bubblewrap and seccomp on Linux, and Microsoft’s MXC on compatible Windows devices.
  • The default :workspace profile lets Codex edit your project, keeps .git and .codex read-only, and turns the network off.
  • Reads are broad by design, so secrets elsewhere on your machine can stay readable. OpenAI says so itself.
  • MCP servers you add start outside the sandbox unless you wrap them with the codex sandbox command.

3

Network modes in the Codex sandbox: off (the :workspace default), a proxy with per-domain rules, or full access (the :danger-full-access default), per OpenAI’s post.

What the Codex Sandbox Does by Default

It works on your real machine

OpenAI chose each platform’s own sandboxing over virtual machines and containers for a practical reason. A Codex running inside Docker couldn’t use the native Mac toolchain to build an iOS app or launch the iPhone simulator. So the sandbox constrains commands in the environment you already use, and every child process inherits the same limits, even processes that outlive the original command.

The workspace profile

With a Git repository as the workspace root, the built-in :workspace profile:

  • lets Codex edit files in the workspace without asking every time
  • keeps .git, .codex, .agents and .aws read-only, which blocks direct edits to Git hooks or Codex’s own config
  • allows broad reads across your machine, within your normal OS permissions
  • turns network access off, which blocks uploads and dependency downloads alike

When Codex needs more, it can ask for extra permissions inside the sandbox or for a command to run outside it. The harness then asks you, or routes the request to auto-review, depending on your settings.

Where the Codex Sandbox Stops

OpenAI is candid about the gaps. Because reads are broad, sensitive files elsewhere, such as config files holding API keys, “may also remain readable.” The post also describes a sneakier path: an agent could plant code in a locally installed package like node_modules/prettier. Git often ignores that folder, so the change may not show up, and your editor could run it outside the sandbox the next time you save a file.

Two more limits are worth knowing:

  • MCP servers start unsandboxed. For a stdio MCP server in config.toml, Codex doesn’t sandbox the start command, because it can’t infer which files or services the server needs.
  • Domain rules need the proxy. Allow and deny rules only apply when the network proxy is on, and broad wildcards or DNS access can still leak data, OpenAI notes.

Coding With Chuck’s explainer is a clear walkthrough of how sandbox modes differ from approval policy:

How to Tighten the Codex Sandbox

Add deny rules for secrets

Permission profiles live in config.toml. This profile, adapted from OpenAI’s example, builds on :workspace and blocks env files and a secrets folder:

default_permissions = "dev"

[permissions.dev]
extends = ":workspace"

[permissions.dev.filesystem.":workspace_roots"]
".vscode" = "read"
"**/*.env" = "deny"
"secrets" = "deny"

Turn on the proxy before trusting domain rules

Set network_proxy = true under [features], then list the allowed and denied domains for the profile. Deny rules win over allow rules. Requests to other domains wait for your approval or for auto-review, and the proxy only resolves a hostname after the request is allowed, so the lookup itself can’t leak it first.

Diagram of the three Codex sandbox network modes: off, a proxy with domain rules, and full access
Based on OpenAI’s post on the Codex sandbox, Nov. 18, 2026. Chart by Momentum Hub.

Wrap your MCP servers

OpenAI’s own example runs the memory MCP server through the sandbox command, with a profile that turns the network off and limits writes to the npm cache and the server’s data folder:

[mcp_servers.memory]
command = "codex"
args = ["sandbox", "--permission-profile", "memory-mcp", "--",
        "npx", "--offline", "@modelcontextprotocol/server-memory@1.0.0"]

Test the profile and lock it for teams

The same command runs any program under a profile, so you can check that a rule blocks what it should. In OpenAI’s test, writing to a read-only .vscode folder fails on macOS with an Operation not permitted error. Admins can go further with requirements.toml, for example limiting users to :read-only and switching :danger-full-access off.

If you’re new to Codex itself, OpenAI’s own Getting started with Codex video covers the basics. This is the maker’s video:

Why the Codex Sandbox Matters Beyond Codex

Agents that run commands are spreading fast: browser agents like agent-browser, desktop apps made agent-ready by CLI-Anything, and teams of agents like Replit Missions. The Codex sandbox is a useful reference for all of them, because it treats permissions as configuration you can read, test and enforce, not as a promise from the model. OpenAI also lets developers reuse the sandbox in their own tools through the same command.

Quick Questions, Answered

Does the Codex sandbox stop the agent from reading my files? Not by default. It allows broad reads so builds and tools keep working. Add deny rules for anything sensitive.

Is network access on? Not in the :workspace profile. You can turn it on fully, or route it through the proxy with per-domain rules.

Are MCP servers protected? Not automatically. Stdio servers start outside the sandbox unless you wrap them yourself.

Final Thoughts: Defaults Help, Your Config Decides

The Codex sandbox blocks a large class of mistakes and attacks, and OpenAI documents the rest honestly, which is rarer than it should be. Treat the defaults as a floor. Add deny rules, turn on the proxy, wrap your MCP servers, and test the profile before you give an agent more freedom.

Obada Kraishan

A Computational Social Scientist, Research Scholar, and Software Engineer specializing in machine learning, computational methods, and full-stack development. He leverages these skills to advance research and create innovative web solutions.