How OpenAI’s Codex sandbox runs commands with user-controlled limits

On November 18, 2026, OpenAI described the design and configuration of the Codex sandbox, a mechanism that limits what commands generated by Codex can access on macOS, Linux, and Windows. The sandbox enforces filesystem and network rules set by named permission profiles defined in config.toml.

Sandbox defaults and tradeoffs

OpenAI says the built-in :workspace profile aims for conservative defaults that still allow common developer tasks. For example, :workspace allows writes within a repository workspace while keeping directories such as .git and .codex read-only. It also permits broad filesystem reads to avoid breaking builds that depend on SDKs and libraries outside the workspace.

Those choices create tradeoffs: allowing broad reads can leave sensitive files elsewhere readable, while disabling network access (the :workspace default) blocks both exfiltration and legitimate downloads. OpenAI highlights a concrete risk: modifying a package under node_modules may not appear in git status, and an editor that runs that package could execute malicious code outside the sandbox.

How the harness enforces permissions

The Codex harness uses OS-specific sandboxing through a common API. A spawn_command_under_sandbox(program_and_args, cwd, env, permission_profile, network_proxy) call starts the process in a sandbox; child processes inherit those constraints. The exec_command shell tool is the primary consumer of this API.

Per-command options let the model request different permissions, but the harness decides whether to grant them. The ExecCommandToolCall includes sandbox_permissions with values “use_default”, “with_additional_permissions”, and “require_escalated”. OpenAI states the harness evaluates such requests against user preferences or an auto-review workflow before executing the command.

Configuration, enterprise controls and testing

Permission profiles are reusable and can extend built-in profiles. OpenAI shows a dev profile that extends :workspace and adds entries like “~/build-cache” = “write”, “.vscode” = “read”, and “**/*.env” = “deny”. Network configuration can disable access, enable full direct access (for example via :danger-full-access), or require a proxy enforcing domain rules such as “*.openai.com” = “allow” and “evil.example” = “deny”.

Settings merge across layered config.toml files and administrators can supply managed requirements in requirements.toml to restrict allowed_permission_profiles. The Codex CLI provides a sandbox command for testing profiles; OpenAI gives this example:

codex sandbox --permission-profile dev -- bash -c 'cat > .vscode/settings.json'

Original source: OpenAI News

Leave a Comment