Tools

OpenAI details how the Codex sandbox limits commands on your machine

An OpenAI engineering post explains Codex permission profiles, the codex sandbox command, and how limits are enforced on macOS, Linux and Windows.

Published Updated

Grayscale glass terrarium box with one red latch on its lid
AI-generated image

TL;DR

  • Codex runs commands in the user's own environment, limited by permission profiles that set filesystem and network rules [1].
  • The built-in :workspace profile allows writes in the workspace, keeps .git and .codex read-only, and disables network access [1].
  • The codex sandbox command can wrap other tools, such as a stdio MCP server, in the same limits [1].

OpenAI published an engineering post on 18 November 2026 that explains how the Codex sandbox works [1]. The sandbox lets Codex run commands in the user’s existing environment, within filesystem and network limits the user controls [1].

Why it matters

Running commands on the user’s computer is one of the most common things Codex does and can carry risks [1]. The post shows developers how the built-in profile behaves, how to change them, and how to reuse the same sandbox for their own tools [1].

The built-in workspace profile

Users configure the sandbox through permission profiles, which set the filesystem and network rules for a session [1]. With a Git repository as the workspace root, the built-in :workspace profile [1]:

  • allows writes inside the workspace but keeps .git and .codex read-only [1];
  • allows broad reads, subject to the user’s OS permissions, so files outside the repository, such as configs that hold API keys, may stay readable [1];
  • disables network access, which also blocks tasks like downloading dependencies [1].

OpenAI notes that harm is still possible: for example, the agent could plant code in a package under node_modules that an editor later runs outside the sandbox [1]. This is why it pairs the sandbox with model training and alignment [1].

Custom profiles and network rules

Profiles live under [permissions] in config.toml, can extend a built-in profile, and mark paths as read, write or deny [1]. Network access can be off, fully on, or routed through a proxy that checks domain rules, where explicit deny rules win over allow rules [1]. The proxy resolves a hostname only after the request is allowed or approved, because a DNS lookup itself can leak data [1]. Administrators can use requirements.toml to limit which profiles users may pick [1].

The codex sandbox command runs any command under a profile [1]. OpenAI’s example wraps the @modelcontextprotocol/server-memory MCP server so it can write only to its data folder and the npm cache, with no network access [1]. For a stdio MCP server configured in config.toml, the Codex harness does not sandbox the command that starts the server [1].

How each OS enforces it

  • macOS: Seatbelt, called through /usr/bin/sandbox-exec [1].
  • Linux: bubblewrap plus seccomp-bpf, coordinated by a helper named codex-linux-sandbox [1].
  • Windows: OpenAI is replacing its earlier sandbox with one built on Microsoft’s MXC library, which Codex supports on compatible devices [1].

Limits

On Linux and Windows, deny globs are expanded to concrete paths before launch, so new matching files are not added while a command runs [1]. Broad wildcard rules or DNS access can still allow DNS-based exfiltration [1].

Sources

Written and checked by AI from the sources below

  1. Inside the Codex sandboxOpenAI ·

Fact-checked by gpt-6.1-sol on · Editorial policy