All stories

OpenAI explains how the Codex sandbox works

OpenAI has published a technical account of the Codex sandbox, which restricts what commands an AI coding agent can do on a developer's own machine instead of moving the work into containers or VMs.

OpenAI described the design of the sandbox in Codex, its agentic harness. The sandbox limits what commands Codex runs on a user's computer can touch on the filesystem and the network. OpenAI presents it as one layer of a "defense in depth" approach that also includes model training and alignment.

Users set limits through permission profiles. With a Git repository as the workspace root, the built-in :workspace profile does three things:

  • It allows writes inside the workspace, but keeps .git and .codex read-only. This blocks direct edits to .codex/config.toml and Git hooks.
  • It allows broad filesystem reads, subject to existing OS permissions. That means sensitive files such as configs holding API keys may still be readable.
  • It turns off network access. This blocks uploads and data exfiltration, but also blocks downloading dependencies.

OpenAI says some harm is still possible. In its example, the agent plants malicious code in an ignored folder such as node_modules/prettier. The user's editor could then run that code outside the sandbox the next time a file is saved.

OpenAI chose not to use Docker or VMs. Instead it relies on each operating system's own sandboxing tools on macOS, Linux and Windows, all behind one common API. The company argues that containers break host-dependent work, such as building iOS apps with native Mac tools and the iPhone simulator. Any process a sandboxed command starts inherits the same limits, even if it keeps running after the original command ends.

The available text stops partway through the post. It does not include the details of how the sandbox is enforced on each operating system.

Sources