Safety & Security

Codex sandbox spans 3 systems as OpenAI moves Windows to MXC

OpenAI detailed Codex’s permission profiles and OS-level sandboxing across macOS, Linux, and Windows, including an MXC transition that removes administrator setup and persistent host state.

Inside the Codex sandbox
Inside the Codex sandboxAI-generated
By Marcus Bennett9 min read

Why it matters

  • Codex exposes one sandbox API across three operating systems: macOS, Linux, and Windows.
  • The :workspace profile permits workspace writes, keeps .git and .codex read-only, and disables network access.
  • Codex network controls have three modes: disabled, full direct access, or proxy-filtered access.
  • OpenAI is moving Windows execution from its existing sandbox to Microsoft's MXC library.
  • The MXC transition targets administrator setup, slow ACL operations, and persistent host state.

OpenAI’s Codex sandbox spans three operating systems—macOS, Linux, and Windows—and the company is replacing its Windows implementation with Microsoft’s MXC execution container. According to OpenAI, the design matters because Codex often runs shell commands on a user’s computer, where broad file reads and network access can expose API keys or exfiltrate data. OpenAI uses “defense in depth” because, in its words, “the sandbox limits what commands can access, while training and alignment help the model use that access in accordance with the user’s intent.”

What does the Codex sandbox actually restrict?

OpenAI defines a sandbox as a runtime boundary around a program. Named permission profiles set the filesystem and network limits for each Codex session.

Under the built-in :workspace profile, OpenAI applies three defaults:

  • Allows writes within the workspace while keeping .git and .codex read-only. Codex can edit source code without requesting approval for every change, but cannot directly alter .codex/config.toml or Git hooks under .git/hooks.
  • Allows broad filesystem reads, subject to the user’s existing operating-system permissions. OpenAI says compilers, runtimes and build tools need SDKs, libraries and configuration outside the repository, though sensitive files elsewhere may remain readable.
  • Disables network access. OpenAI says this blocks direct uploads and data exfiltration, but also prevents legitimate operations such as downloading dependencies.

These controls still leave one important failure mode, OpenAI says: Codex could inject malicious code into an ignored local package such as node_modules/prettier. An editor running that copy of Prettier on save could execute the code outside the sandbox, and the change might not appear in git status.

OpenAI says it avoids virtual machines and Docker because laptops often contain host-specific tools. In an iOS example, Docker cannot run native Mac build tools or the iPhone simulator; delegating those steps to the Mac would execute them outside the container and require separate controls.

How does Codex decide what a command may do?

OpenAI exposes one API across macOS, Linux and Windows. It accepts a command and a permission profile, while limited network access also requires a network proxy.

Each child process inherits its parent’s sandbox constraints throughout the spawned process tree, including descendants that remain alive after the original process ends, according to OpenAI.

For coding tasks, OpenAI routes the model’s exec_command shell tool through spawn_command_under_sandbox() rather than subprocess.Popen(). Once the harness authorizes execution, it calls perform_exec_command_with_sandboxing() with the original command arguments.

The model can request use_default, with_additional_permissions or require_escalated. OpenAI says the harness evaluates each request against user preferences, then prompts the user or routes the request to auto-review; require_escalated places execution outside the sandbox.

OpenAI also reuses the infrastructure when Codex reads or modifies local files. The separate codex sandbox command exposes the same controls to developers building other tools.

How do users and enterprises set permissions?

Named profiles in config.toml make rules reusable across projects. OpenAI’s example dev profile extends :workspace, adds write access to ~/build-cache and makes .vscode read-only.

Path entries support read, write and deny. The :workspace_roots table applies each rule to every project root; OpenAI sets the Codex CLI working directory as its sole root and the ChatGPT desktop app’s source folders as its roots.

OpenAI documents three network configurations:

  • Disable all network access, the default for :workspace.
  • Enable full, direct network access, the default for :danger-full-access.
  • Restrict access through a proxy that applies domain rules.

Domain rules accept exact names and wildcard patterns, with explicit deny rules taking precedence over allows. Requests to unmatched domains require approval or receive an error, according to OpenAI.

OpenAI merges settings from multiple config.toml files recursively for tables and replaces arrays wholesale. Project and enterprise layers can therefore add individual rules while inheriting other entries from an organization’s base configuration.

Administrators can supply managed requirements through requirements.toml, including system files and cloud-provided policy. OpenAI says cloud requirements outrank /etc/codex/requirements.toml, while unspecified entries can come from another layer; profiles set to false or left absent become unavailable.

Individual users can set defaults across projects and override them for a trusted project. Administrators can supply their own defaults while constraining which settings users may change.

Can developers run Codex outside an agent session?

The codex sandbox command runs an arbitrary command under a profile from the Codex configuration. OpenAI positions it as a way to test that a profile blocks the writes and network access it was designed to prevent.

In OpenAI’s example, the dev profile blocks a VS Code auto-formatter write because .vscode is read-only. The write fails on macOS, and codex sandbox treats the current working directory as a workspace root by default.

Codex does not sandbox the startup command for a stdio MCP server because it cannot reliably infer which files or network services the server requires. OpenAI says an npx command therefore runs with the same broad permissions as the user.

To restrict the @modelcontextprotocol/server-memory example, OpenAI defines a memory-mcp profile and wraps the original command with codex sandbox --permission-profile memory-mcp. Users first create the server’s data directory and cache the pinned package, allowing npx --offline to start without network access and limit writes to the npm cache and data directory.

How does the network proxy enforce web access?

OpenAI implements network policy in the codex-network-proxy crate. The harness loads it as a library, and developers can build it as a standalone command-line tool.

By default, OpenAI’s proxy starts HTTP and SOCKS5 servers. It passes their addresses to sandboxed processes through HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and application-specific variables such as PIP_PROXY.

OpenAI acknowledged one limitation: “Admittedly, not all programs honor these environment variables.” Its fallback is the operating system’s block on direct connections to external hosts.

For OpenAI’s dev profile, *.openai.com is allowed and evil.example is denied. An unmatched request pauses while the harness considers approval, which may produce a direct user prompt or an auto-review decision.

The proxy resolves a hostname only after approving it because DNS lookups can encode information in hostnames. OpenAI warns, however, that broad wildcard rules or access to DNS services can still permit DNS-based exfiltration.

How does macOS enforce the sandbox?

On macOS, OpenAI uses Seatbelt, Apple’s kernel-enforced sandbox, and writes its restrictions in Sandbox Profile Language, a Scheme-based policy format.

Codex invokes /usr/bin/sandbox-exec with an SBPL profile and command. Its base policy starts with (deny default), explicit rules grant access, and (param) placeholders receive values through -Dkey=value arguments.

OpenAI’s proxy integration opens only the required local ports. One example policy makes /dev/null and /dev/zero readable and writable within the sandbox.

OpenAI says Apple does not document SBPL for third-party use and marks sandbox-exec and sandbox_init() deprecated. macOS still ships profiles under /usr/share/sandbox, and Google Chrome and Chromium rely on Seatbelt.

OpenAI therefore plans to continue using Seatbelt for the foreseeable future.

How does Linux enforce the sandbox?

On Linux, OpenAI combines bubblewrap, which constructs isolated environments, with seccomp-bpf, which filters system calls. Its codex-linux-sandbox helper coordinates both layers.

OpenAI vendors its own bubblewrap copy but prefers a compatible executable found on PATH. It also notes that some Linux distributions disable user namespaces while granting an exception for the system bwrap.

Codex uses --bind, --ro-bind, --perms 000 --tmpfs DIR --remount-ro DIR and --perms 000 --ro-bind-data FD FILE to model writable, read-only and denied paths. It expands deny globs before launch, so new matching files do not automatically join a running command’s restrictions.

Codex also uses --unshare-ipc and --unshare-pid, and it creates a network namespace when networking is disabled or proxied. The seccompiler crate dynamically compiles BPF filters for the launcher, allowing the restrictions to cover the entire process tree.

The launcher sets Linux’s no_new_privs flag to prevent privilege gains through programs such as setuid. OpenAI blocks calls including connect and bind when networking is off, permits IP sockets for its proxy listener and blocks standalone Unix-domain sockets by default.

One proxy can serve multiple codex-linux-sandbox invocations within a Codex thread. OpenAI bridges the isolated network namespace to the host through a loopback TCP listener, a Unix socket-pair control channel and an outside relay process that forwards traffic to the shared proxy.

On Linux, the command reaches that listener inside its own namespace. On macOS, OpenAI says Seatbelt instead permits direct connections to specified host loopback ports.

What changes with Microsoft MXC on Windows?

OpenAI says Microsoft released MXC alongside new Windows process-isolation features earlier this year. Codex is transitioning from its existing Windows sandbox to an MXC-based implementation.

MXC, Microsoft eXecution Container, supports several containment backends across Windows, Linux and macOS. On compatible Windows devices, OpenAI uses native process isolation, the MXC SDK and a JSON schema containing the command, working directory, environment and permissions.

The transition targets three drawbacks of OpenAI’s previous design: elevated or administrator setup, slow and expensive access-control-list operations, and persistent host state comprising ACLs, firewall rules, sandbox users and control-plane files.

Codex permits registry reads and retains Win32k and desktop access for PowerShell startup. It disables clipboard access, input injection, desktop and system-settings controls, and prevents MXC from falling back to changes to host filesystem permissions.

In OpenAI’s drive example, C:\, D:\ and Z:\ are the local roots, the workspace is C:\work\demo, the home directory is D:\Users\dev, and two files under config match the deny glob.

MXC denies filesystem access by default, so Codex adds recursive read-only grants for drive roots. Writable root grants do not extend recursively, and Codex expands them to include each drive’s existing immediate children.

More-specific paths override ancestor grants. When aliases refer to the same file, OpenAI applies the strictest rule: deny takes precedence over read-only, which takes precedence over read-write.

Codex expands deny globs before launch, so later files do not inherit the restriction automatically. Its shared proxy still filters domains, while MXC blocks direct external connections but allows host-loopback connections, including the proxy, and other local services.

What happens next?

OpenAI says it will make sandboxing practical for more tools and environments, simplify permission configuration and adopt stronger operating-system protections as they arrive. “Our goal is to expand what agents can do while keeping people in control of what they can access.”

Source: OpenAI News

Share this article:

More from Marcus Bennett

Marcus Bennett

Show full bio

Senior reporter covering companies, deals and strategy in artificial intelligence and machine learning at AI In Context.

745 articles

Related articles

  1. OpenAI built a Windows sandbox for Codex from scratch
  2. OpenAI details how it runs Codex safely in production
  3. OpenAI's GPT-5.1-Codex-Max Flags Coming Cybersecurity Threshold
  4. OpenAI details codex-1: an o3 variant tuned for real coding work
  5. OpenAI Ships Codex Desktop App as Agent Command Center

« Previous articleNext article »