Skip to content
RESEARCH INDEX BREACHROAD / INTELLIGENCE NOTE

Codex Sandbox: Securing AI Agent Command Execution

OpenAI disclosed the Codex sandbox architecture. We analyse permission profiles, network isolation, MXC, bubblewrap, Seatbelt and unsandboxed MCP risk.

PUBLIC RESEARCH
AUTHOR
/ CEO Breachroad · OSCP · PNPT
PUBLISHED
18 November 2026
READING TIME
25 min read
TOPIC
AI Security
Codex Sandbox: Securing AI Agent Command Execution

OpenAI published a technical description of the Codex sandbox on 18 November 2026. The layer constrains commands an agent runs on a user’s computer. The article explains how a common permission profile becomes operating-system controls on macOS, Linux and Windows, how network access is mediated and where deliberate trade-offs remain.

This matters because coding-agent security is not simply model-response quality. An agent executes commands, reads configuration, launches compilers, modifies dependencies and may contact external services. Prompt injection or a mistaken decision becomes dangerous when the execution system provides enough privilege. A sandbox is a technical boundary on impact, but it cannot guarantee that every permitted effect matches the user’s intent.

What the Codex sandbox is

According to the official architecture description, the sandbox runs commands in the user’s existing environment while restricting filesystem and network access through permission profiles. It preserves local SDKs, libraries and toolchains rather than moving every task into a separate virtual machine or container.

That distinguishes isolation from full environment reproduction. A developer can keep using native platform tools — a system compiler or device simulator, for example — while the operating system enforces limits around the process.

The decision chain is approximately:

  1. the model proposes a tool call or command;
  2. the Codex harness interprets the request;
  3. a permission profile defines filesystem and network access;
  4. the sandbox launches a constrained process;
  5. descendants inherit the boundaries;
  6. results return to the agent;
  7. any permission expansion is decided by the control layer.

The model may request more access, but it does not grant that access to itself. This separation between proposal and authorisation is foundational to a secure agent harness.

:workspace is a trade-off, not a sealed capsule

OpenAI describes a built-in :workspace profile intended to support practical work with conservative defaults:

  • writes are allowed inside project workspace roots;
  • directories such as .git, .codex, .agents and .aws remain read-only;
  • reads outside the workspace are broad but still constrained by the user’s OS permissions;
  • network access is disabled by default.

Protecting .git prevents direct modification of hooks and some repository metadata. Protecting .codex makes it harder for the agent to rewrite its own configuration. No network limits direct exfiltration and accidental code uploads, but also blocks dependency and documentation downloads.

The most important compromise is read access. Compilers, interpreters and package managers rely on files outside the repository, so confining all reads to one directory would break ordinary work. The consequence is that an agent may read configuration or secrets available to the user unless a profile adds an explicit deny rule.

Workspace writes can still become execution

Writing only inside a repository sounds safe, but projects contain files that other processes execute automatically. A malicious change could target:

  • editor configuration and tasks invoked when a project opens;
  • a local package under Git-ignored node_modules;
  • package.json scripts, build hooks or code generators;
  • a test-runner configuration;
  • a dev-container or CI pipeline definition;
  • an artefact the user later executes outside the sandbox.

OpenAI gives the example of replacing a local formatter. The modification may not appear in git status, while saving a file in the editor launches the altered program with the user’s full permissions. The agent process was constrained, but a trusted tool later executed the prepared artefact outside that boundary.

This is deferred execution. Security review must ask not only what the agent ran directly but which files may become code during a later step.

read, write and deny rules

Codex profiles assign three basic access levels to paths:

  • read — read without modification;
  • write — read and modify;
  • deny — no access.

An organisation can extend :workspace by allowing a build cache, making IDE settings read-only and denying *.env files and a secrets directory. Rules relative to :workspace_roots apply across every source root in a project.

A practical coding-agent profile should explicitly protect at least:

  • environment files and secret stores;
  • .git, agent configuration and security requirements;
  • editor settings capable of launching processes;
  • high-impact automation manifests;
  • SSH keys, cloud credentials and kubeconfig;
  • directories containing customer data or production exports.

Not every resource must be invisible. Read access may be required for analysis. It should follow from a specific task rather than silently inherit the user’s broad permissions.

Three network-access models

Codex supports three broad options:

  1. all network access disabled;
  2. full direct access;
  3. proxy-mediated access with domain rules.

The proxy model is particularly useful for enterprises. A profile can allow selected domains, deny others and route unmatched requests for approval. The proxy exposes HTTP and SOCKS5 endpoints and injects variables such as HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and package-manager-specific settings.

Not every program honours proxy variables. Operating-system isolation therefore blocks direct connections to external hosts. The proxy is not the only wall; it is a controlled passage through the system boundary.

DNS, wildcards and misleading allowlists

OpenAI notes that even a DNS query can leak data encoded in a hostname. The proxy resolves a destination only after policy decides that it is allowed or approved. The ordering is correct: authorise first, then perform the operation that might disclose information.

A domain allowlist is not automatically safe. A broad wildcard may include user-controlled services, upload endpoints or open redirects. Access to a public resolver can restore a DNS channel. localhost may expose an administration panel or service with privileges beyond the sandbox.

Network policy should describe a business purpose. “Read vendor documentation” is a stronger basis than *.example.com when subdomains have different owners. Write operations — publishing packages, uploading artefacts or changing cloud state — need additional approval independent of the destination hostname.

Layered configuration and managed requirements

An individual can set a default profile and override it for a trusted project. An enterprise also needs boundaries that repository owners cannot relax. Codex merges configuration from several sources and supports managed requirements.toml policy.

An administrator can constrain available profiles and disable :danger-full-access. Cloud requirements may outrank a system file, while project settings inherit organisational limits. That separates two objectives:

  • the team tailors a profile to its toolchain;
  • the organisation preserves a non-bypassable maximum privilege.

Without that separation, a central template may be secure while one repository turns networking back on or allows an agent to modify its own controls.

codex sandbox as a policy test tool

The codex sandbox command can launch an arbitrary program under a chosen profile, independently of an ordinary agent session. That enables negative policy testing:

  • a write to a read-only directory should fail;
  • a denied file should not be readable;
  • direct egress should be blocked;
  • an allowed domain should work through the proxy;
  • a child process should not regain broader rights;
  • loss of a control should close access rather than open it.

This is analogous to testing a firewall or IAM policy. A configuration file is not evidence. An observable rejection of an operation the policy was meant to prevent is evidence.

MCP servers are a critical boundary outside defaults

The most operationally important warning concerns Model Context Protocol. OpenAI explains that the harness does not automatically sandbox the command launching a stdio MCP server. Codex cannot reliably infer which files and network services each server requires, and a restrictive default could break valid configurations.

The result is that a local MCP server may run with the user’s authority even while agent shell commands are sandboxed. The agent does not need to read a secret directly if a connector exposes a function that can do so. This is a classic confused-deputy path.

OpenAI demonstrates wrapping an MCP launch in codex sandbox with a dedicated profile, disabled networking and writes limited to the server’s data directory. For every MCP server, an organisation should establish:

  • package origin and pinned version;
  • exact writable directories;
  • required network destinations;
  • exposed tool list;
  • process identity and secrets;
  • update and logging process;
  • consequences of server compromise.

Our MCP and Model Context Protocol security guide explores this boundary in more depth.

macOS: Seatbelt and deny by default

On macOS, Codex uses the kernel-enforced Seatbelt mechanism and SBPL profiles invoked through sandbox-exec. The base policy starts with deny default and then grants specific access to files, devices and local proxy ports.

OpenAI also identifies a limitation: Apple marks sandbox-exec and related APIs as deprecated and does not document SBPL for third-party developers, although the operating system and software such as Chromium still rely on Seatbelt. That creates maintenance cost and a need for regression testing after OS updates.

Linux: bubblewrap, namespaces and seccomp-bpf

On Linux, isolation combines bubblewrap with seccomp-bpf. Bubblewrap creates a separate filesystem view in a mount namespace, mapping paths as writable, read-only or inaccessible. Additional namespaces limit process and IPC visibility, while seccomp filters system calls before the target command begins.

OpenAI describes a subtle glob limitation: deny patterns are expanded to concrete paths that exist before each command launches. A new file matching the pattern is not necessarily added to an already running sandbox’s restrictions. That is why policy testing must cover newly created files and long-lived processes.

Windows: moving to Microsoft eXecution Container

On Windows, Codex is transitioning to MXC — Microsoft eXecution Container. The library provides native process isolation and policy for files, networks, desktop, clipboard and other OS resources. OpenAI says the new design addresses limitations in the previous implementation: administrator privileges for setup, expensive ACL changes and persistent host state such as firewall rules, sandbox users and control files.

In the disclosed configuration, registry reads and part of Win32k remain available for PowerShell compatibility, while clipboard access, input injection, desktop control and system-settings changes are disabled. MXC is prevented from falling back to host filesystem permission modification.

For conflicting paths, a more specific rule overrides its ancestor, and stricter access wins: deny before read-only, read-only before read-write. The behaviour is particularly important for junctions and alternative spellings of the same path.

A sandbox does not replace change review

A sandbox controls where a process can act, not whether a change is correct. Inside an allowed directory, an agent may still:

  • introduce a business-logic vulnerability;
  • weaken authorisation;
  • alter a test to hide a regression;
  • add a dependency with poor provenance;
  • commit a secret;
  • prepare configuration that later executes in CI/CD.

Code review, secret scanning, signed commits or artefacts, branch protection, security tests and an independent pipeline remain necessary. Prompt injection against CI/CD agents is especially dangerous because untrusted content from an issue, documentation or log can steer an agent towards release-process changes.

A practical enterprise baseline

A strong starting point includes:

  1. :workspace instead of full access;
  2. explicit deny for secrets, cloud configuration and environment files;
  3. read-only access to .git, IDE settings and pipeline definitions;
  4. network disabled by default;
  5. a short proxy allowlist for documentation tasks;
  6. a separate profile for every MCP and local tool;
  7. organisational blocking of :danger-full-access;
  8. human approval for publishing, deployment and IAM changes;
  9. negative profile tests in CI;
  10. complete logs of tool calls, permission decisions and effects.

The profile should be versioned and tested periodically on every supported platform. The same profile name does not guarantee identical edge-case behaviour across Seatbelt, bubblewrap and MXC.

Source facts and Breachroad conclusions

OpenAI confirms permission profiles, :workspace defaults, proxy-based network control, layered requirements, the lack of automatic MCP-server sandboxing and the Seatbelt, bubblewrap/seccomp and MXC platform implementations. It also documents trade-offs including broad reads and deferred execution through a modified local tool.

The proposed baseline, negative-test list and MCP blast-radius review are Breachroad conclusions. We are not claiming that every MCP server is malicious or that sandboxing removes the need for code review.

The key takeaway

A secure coding agent requires two separate questions: should the model take an action, and is it technically allowed to achieve that action’s effects? A sandbox answers the second question. Narrow profiles, independent policy and strong telemetry reduce the cost of model error and prompt injection.

Our AI agent sandbox architecture guide covers the broader design patterns. AI security training helps developers and administrators understand agent boundaries, while AI red teaming can test whether an agent can bypass a profile, abuse MCP or cause execution outside its intended scope.

SHARE / COPY