2026-11-26 15:48 UTC

OpenAI details Codex’s cross-platform command sandbox

state: significantheat: lowuncertainty: mediumrelevance: highcoding-agent-sandbox agent-security codexOpenAIMichael Bolin

What is this?

On November 18, 2026, OpenAI published “Inside the Codex sandbox,” a technical account by Michael Bolin, a member of technical staff, of how Codex limits commands run on a user’s existing machine. It describes configurable filesystem and network permission profiles, enterprise controls, a reusable `codex sandbox` command, and OS-specific enforcement on macOS, Linux, and Windows. OpenAI says the approach aims to preserve access to native development tools while placing limits around agent-launched commands. This is a first-party description; the supplied sources provide no independent validation of its implementation or security effectiveness.

Why it matters

The published implementation details clarify how coding agents can use developers’ existing tools while limiting command permissions, with a reusable sandbox command that may extend the approach to other tools. The documented caveats and lack of independent validation keep its real-world security implications unsettled.

Current assessment

On November 18, 2026, OpenAI published Michael Bolin’s account of Codex’s sandbox: configurable filesystem and network permission profiles, OS-specific enforcement for macOS, Linux, and Windows, enterprise controls, and a `codex sandbox` CLI for applying profiles to arbitrary commands. OpenAI says the default permits workspace writes and broad reads while blocking network access, and documents risks including exposure of secrets through broad reads, possible exfiltration when network or DNS access is allowed, and platform-specific caveats; it also says the Windows implementation is being replaced with MXC. This first-party design disclosure is consequential, but independent security validation, adoption, and consistent behavior across platforms and configurations remain unknown. Subsequent discussion has added no material evidence; attention is low.

Measured heat

now 0 pts/hpeak 7 pts/hcomments 0/hpeers p10momentum: steady3 platformsage 218h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

11-17 13:00⭐ origin echo-reconstructedOpenAI's original engineering article explains how Codex runs commands in users' existing environments with configurable filesystem and netw
OpenAI (by Michael Bolin, Member of Technical Staff) on blog (echo) · attributed from hn.story.50549758
—
11-18 08:00first on openai · published · +19.0hInside the Codex sandbox
OpenAI
—
11-18 18:04first on hacker news · published · +29.1hThe Codex Sandbox
bolinfest
—
11-18 18:04amplified on hacker news 👑hn.story.50549758
bolinfest
peak 15 · 4 comments · 82% of case engagement
11-19 08:49amplified on hacker newshn.story.50557618
giuliomagnifico
peak 2 · 0 comments · 9% of case engagement
11-19 18:49amplified on hacker newshn.story.50564390
gmays
peak 2 · 0 comments · 9% of case engagement
11-18 18:21our radar first saw it · +29.4hdiscovery anchor: hn.story.50549758—
pace: p62 vs 2096 stories at the 168h mark (now 218h old) — ahead of anthropic-oss-scanner-pion-cves (1.1x), behind agent-bridge-headless-cli-api (0.9x)

Evidence (5) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnThe Codex Sandbox
Retrieved article excerpt

Open article · Retrieved 2026-11-18T18:39:13.137173+00:00

November 18, 2026

[Engineering](https://openai.com/news/engineering/)

# Inside the Codex sandbox

How Codex runs commands on your machine with limits you control.

By Michael Bolin, Member of Technical Staff

Share

At OpenAI, we take a [defense in depth⁠(opens in a new window)](https://en.wikipedia.org/wiki/Defense_in_depth_(computing)) approach when it comes to safeguarding agents. While our investments in training and alignment are fundamental to this effort, we also implement features in our agentic harness, [Codex⁠(opens in a new window)](https://github.com/openai/codex), to provide additional protections. Because one of the most common (and potentially risky) things Codex does is run commands on your computer, we built the *Codex sandbox* so Codex can work in your existing environment within filesystem and network limits you control.

A [⁠(opens in a new window)](https://en.wikipedia.org/wiki/Sandbox_(computer_security))[*sandbox*⁠(opens in a new window)](https://en.wikipedia.org/wiki/Sandbox_(computer_security)) limits what a program can access while it runs. For a photo-organizing task, you might configure the Codex sandbox to let commands read and modify files in `~/Pictures` while blocking network access to prevent uploads. For code review, you might allow access to online documentation while keeping source files read-only. Users configure the Codex sandbox through [⁠(opens in a new window)](https://learn.chatgpt.com/docs/permissions)[*permission profiles*⁠(opens in a new window)](https://learn.chatgpt.com/docs/permissions), which define the filesystem and network restrictions for a Codex session.

In this article, we’ll start with the tradeoffs behind Codex’s sandbox defaults, then explain the sandbox’s design and how the harness uses it to run commands. We’ll show how end users and enterprises can tailor its permissions to their needs and how developers can reuse the sandbox in their own tools. Finally, we’ll examine how these restrictions are enforced on macOS, Linux, and Windows.

## Choosing the sandbox boundaries

In Codex, our philosophy is to specify conservative defaults for the sandbox that still enable meaningful work. For example, with a Git repository as the workspace root, the built-in `:workspace` permission profile:

- **Allows writes within the workspace, while keeping directories such as** `.git` **and** `.codex` **read-only.** This lets Codex edit source code without seeking permission for every change, while preventing direct changes to `.codex/config.toml` or Git hooks under `.git/hooks`.
- **Allows broad filesystem reads, subject to the user’s existing OS permissions.** Compilers, runtimes, and build tools depend on SDKs, libraries, and configuration outside the repository. Restricting reads to the workspace would break many ordinary workflows. The tradeoff is that sensitive files elsewhere on the machine may also remain readable (such as config files containing API keys).
- **Disables network access.** This blocks direct uploads to external services, including attempts to exfiltrate data the command can read. It also prevents legitimate operations such as downloading dependencies, which require additional access.

These restrictions prevent a large class of bad behavior, but harmful actions are still possible. For example, the agent could inject malicious code into a locally installed package such as `node_modules/prettier`. Such a change might not appear in `git status` because `node_modules` is often ignored by Git. If the user’s editor runs that copy of Prettier on save, simply saving a file could execute the malicious code outside the Codex sandbox. This is why we take a defense in depth approach: the sandbox limits what commands can access, while training and alignment help the model use that access in accordance with the user’s intent.

For guidance on tailoring sandbox permissions and combining them with other protections in an enterprise environment, see the [Codex security cookbook⁠(opens in a new window)](https://learn.chatgpt.com/docs/enterprise/security-cookbook).

## Designing the sandbox

Virtual machines and [containers⁠(opens in a new window)](https://opencontainers.org/) are two popular mechanisms used for sandboxing, but we take a different approach with the Codex sandbox. Instead of moving computation to a separate environment to provide isolation, Codex uses each platform’s sandboxing facilities to constrain commands running in the user’s existing environment.  
  
For many developers, their laptop serves as a bespoke dev environment that they can change on a whim. Reproducing that environment in a Docker container can take work, and some workflows still depend on tools that run on the host.

For example, consider using Codex to develop an iOS app on a Mac. If you decided to sandbox Codex by running it inside Docker, Codex would not be able to run the iOS build toolchain composed of native Mac executables, nor could it launch the iPhone simulator to run the code. A Docker-based workflow could delegate builds and simulator operations to the Mac host, but those operations would execute outside the container’s sandbox and would need their own restrictions. For Codex, we prefer to keep things simple by investing heavily in OS-specific sandboxing so Codex can run in the environment that is most appropriate to the task at hand.

The harness exposes these OS-specific sandboxing mechanisms through a common API across macOS, Windows, and Linux. This API takes a command and a permission profile. If the permission profile allows limited network access, the caller must supply a network proxy to enforce those limits:

#### Python

```` ```
1

# This is a simplified version of the actual API.



2

def spawn_command_under_sandbox(



3

program_and_args: list[str],



4

cwd: Path,



5

env: dict[str, str],



6

permission_profile: PermissionProfile,



7

network_proxy: NetworkProxy | None,



8

) -> Child:
``` ````

This function starts the process in a sandbox and returns a `Child` handle the harness can use to wait for it to finish. Each child process inherits its parent’s sandbox constraints, so those restrictions apply throughout the process tree initiated by the command, even to descendants that outlive the original process.

The following diagram shows how these pieces fit together, from configuration to running a sandboxed command. The sections that follow explain each stage.

Flow diagram: configuration and managed requirements define a session permission profile; the Codex harness launches commands under platform-specific sandbox restrictions on macOS, Linux, or Windows. Child processes inherit those restrictions, and an optional network proxy enforces domain rules.

## How the harness leverages the sandbox

As explained in [Unrolling the Codex Agent Loop](https://openai.com/index/unrolling-the-codex-agent-loop/), the Codex harness is responsible for executing tool calls generated by the model. For coding tasks, the most commonly used tool is a *shell tool*, which runs commands much as a user would in an interactive shell such as Bash. Here we’ll examine the [one-shot ⁠(opens in a new window)](https://github.com/openai/codex/blob/60947e234156ac12bdb7fba2477d3965f166bd34/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs#L483-L512)[`exec_command`⁠(opens in a new window)](https://github.com/openai/codex/blob/60947e234156ac12bdb7fba2477d3965f166bd34/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs#L483-L512) [shell tool⁠(opens in a new window)](https://github.com/openai/codex/blob/60947e234156ac12bdb7fba2477d3965f166bd34/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs#L483-L512) to illustrate how the harness employs the sandbox to achieve the desired protections.  
  
This is a simplified version of how the `exec_command` tool call would be honored by the Codex harness *without sandboxing*:

#### Python

```` ```
1

# Illustrative implementation of the exec_command tool call.



2



3

class ExecCommandToolCall:



4

cmd: str



5

workdir: str | None = None



6

shell: str | None = None



7

login: bool = True



8

timeout_ms: int = 10_000



9



10



11

def perform_exec_command(tool_call: ExecCommandToolCall):



12

program_and_args = [



13

tool_call.shell or os.environ.get("SHELL") or "/bin/sh",



14

"-lc" if tool_call.login else "-c",



15

tool_call.cmd,



16

]



17

child = subprocess.Popen(



18

program_and_args,



19

# workdir defaults to the turn's cwd, assumed here to be the process cwd.



20

cwd=Path(tool_call.workdir or ".").absolute(),



21

stdout=subprocess.PIPE,



22

stderr=subprocess.STDOUT,



23

)



24

output, exit_code = collect_output(child, timeout_ms=tool_call.timeout_ms)



25

return {"output": output, "exit_code": exit_code}
``` ````

To sandbox the command, the harness replaces the call to `subprocess.Popen()` with `spawn_command_under_sandbox()`. The harness supplies the permission profile and, when needed, the network proxy:

#### Python

```` ```
1

# Honoring the exec_command tool call while enforcing sandbox constraints.



2



3

def perform_exec_command_with_sandboxing(



4

tool_call: ExecCommandToolCall,



5

permission_profile: PermissionProfile,



6

network_proxy: NetworkProxy | None,



7

):



8

# ...build program_and_args as in the previous example...



9

child = spawn_command_under_sandbox(



10

program_and_args=program_and_args,



11

cwd=Path(tool_call.workdir or ".").absolute(),



12

env=os.environ.copy(),



13

permission_profile=permission_profile,



14

network_proxy=network_proxy,



15

)



16

output, exit_code = collect_output(child, timeout_ms=tool_call.timeout_ms)



17

return {"output": output, "exit_code": exit_code}
``` ````

The `exec_command` tool also lets the model request different permissions for an individual command, but the harness decides whether to grant the request:

#### Python

```` ```
1

class ExecCommandToolCall:



2

# ...command-related fields...



3



4

# Per-command sandbox override. Defaults to "use_default".



5

sandbox_permissions: Literal[



6

"use_default",



7

"with_additional_permissions",



8

"require_escalated",



9

] = "use_default"



10



11

# User-facing approval question; only for "require_escalated".



12

justification: str | None = None



13



14

# Expand network or filesystem access; only for "with_additional_permissions".



15

# AdditionalPermissions supports fine-grained options.



16

additional_permissions: AdditionalPermissions | None = None
``` ````

When `use_default` is specified, the harness uses the default sandbox config for the turn. `with_additional_permissions` requests expanded access within the sandbox, while `require_escalated` requests execution outside it. The harness evaluates the request based on the user’s preferences before executing the command. (For example, Codex may prompt the user directly, or it might route the request to [auto-review⁠(opens in a new window)](https://learn.chatgpt.com/docs/sandboxing/auto-review).) If execution is authorized, Codex will pass the appropriate `permission_profile` and `network_proxy` to `perform_exec_command_with_sandboxing()` with the command arguments from the original `ExecCommandToolCall`.

The shell tool is the primary consumer of `spawn_command_under_sandbox()`, and the harness also reuses its sandboxing infrastructure for operations such as reading and modifying local files. This reuse extends beyond the harness: the `codex sandbox` command lets you incorporate sandboxed command execution into your own tools, as we’ll see later. Next, we’ll look at how permission profiles are defined.

## Configuring the sandbox

A named permission profile lets you reuse the same filesystem and network restrictions across projects. You can define your own profiles under `[permissions]` in `config.toml`. For example, the following defines a profile named `dev` that [ext
bolinfest154
🟧 echo.blog ⭐OpenAI's original engineering article explains how Codex runs commands in users' existing environments with configurable filesystem and netwOpenAI (by Michael Bolin, Member of Technical Staff)——
🟧 openaiInside the Codex sandbox
Retrieved article excerpt

Open article · Retrieved 2026-11-18T18:39:13.137173+00:00

November 18, 2026

[Engineering](https://openai.com/news/engineering/)

# Inside the Codex sandbox

How Codex runs commands on your machine with limits you control.

By Michael Bolin, Member of Technical Staff

Share

At OpenAI, we take a [defense in depth⁠(opens in a new window)](https://en.wikipedia.org/wiki/Defense_in_depth_(computing)) approach when it comes to safeguarding agents. While our investments in training and alignment are fundamental to this effort, we also implement features in our agentic harness, [Codex⁠(opens in a new window)](https://github.com/openai/codex), to provide additional protections. Because one of the most common (and potentially risky) things Codex does is run commands on your computer, we built the *Codex sandbox* so Codex can work in your existing environment within filesystem and network limits you control.

A [⁠(opens in a new window)](https://en.wikipedia.org/wiki/Sandbox_(computer_security))[*sandbox*⁠(opens in a new window)](https://en.wikipedia.org/wiki/Sandbox_(computer_security)) limits what a program can access while it runs. For a photo-organizing task, you might configure the Codex sandbox to let commands read and modify files in `~/Pictures` while blocking network access to prevent uploads. For code review, you might allow access to online documentation while keeping source files read-only. Users configure the Codex sandbox through [⁠(opens in a new window)](https://learn.chatgpt.com/docs/permissions)[*permission profiles*⁠(opens in a new window)](https://learn.chatgpt.com/docs/permissions), which define the filesystem and network restrictions for a Codex session.

In this article, we’ll start with the tradeoffs behind Codex’s sandbox defaults, then explain the sandbox’s design and how the harness uses it to run commands. We’ll show how end users and enterprises can tailor its permissions to their needs and how developers can reuse the sandbox in their own tools. Finally, we’ll examine how these restrictions are enforced on macOS, Linux, and Windows.

## Choosing the sandbox boundaries

In Codex, our philosophy is to specify conservative defaults for the sandbox that still enable meaningful work. For example, with a Git repository as the workspace root, the built-in `:workspace` permission profile:

- **Allows writes within the workspace, while keeping directories such as** `.git` **and** `.codex` **read-only.** This lets Codex edit source code without seeking permission for every change, while preventing direct changes to `.codex/config.toml` or Git hooks under `.git/hooks`.
- **Allows broad filesystem reads, subject to the user’s existing OS permissions.** Compilers, runtimes, and build tools depend on SDKs, libraries, and configuration outside the repository. Restricting reads to the workspace would break many ordinary workflows. The tradeoff is that sensitive files elsewhere on the machine may also remain readable (such as config files containing API keys).
- **Disables network access.** This blocks direct uploads to external services, including attempts to exfiltrate data the command can read. It also prevents legitimate operations such as downloading dependencies, which require additional access.

These restrictions prevent a large class of bad behavior, but harmful actions are still possible. For example, the agent could inject malicious code into a locally installed package such as `node_modules/prettier`. Such a change might not appear in `git status` because `node_modules` is often ignored by Git. If the user’s editor runs that copy of Prettier on save, simply saving a file could execute the malicious code outside the Codex sandbox. This is why we take a defense in depth approach: the sandbox limits what commands can access, while training and alignment help the model use that access in accordance with the user’s intent.

For guidance on tailoring sandbox permissions and combining them with other protections in an enterprise environment, see the [Codex security cookbook⁠(opens in a new window)](https://learn.chatgpt.com/docs/enterprise/security-cookbook).

## Designing the sandbox

Virtual machines and [containers⁠(opens in a new window)](https://opencontainers.org/) are two popular mechanisms used for sandboxing, but we take a different approach with the Codex sandbox. Instead of moving computation to a separate environment to provide isolation, Codex uses each platform’s sandboxing facilities to constrain commands running in the user’s existing environment.  
  
For many developers, their laptop serves as a bespoke dev environment that they can change on a whim. Reproducing that environment in a Docker container can take work, and some workflows still depend on tools that run on the host.

For example, consider using Codex to develop an iOS app on a Mac. If you decided to sandbox Codex by running it inside Docker, Codex would not be able to run the iOS build toolchain composed of native Mac executables, nor could it launch the iPhone simulator to run the code. A Docker-based workflow could delegate builds and simulator operations to the Mac host, but those operations would execute outside the container’s sandbox and would need their own restrictions. For Codex, we prefer to keep things simple by investing heavily in OS-specific sandboxing so Codex can run in the environment that is most appropriate to the task at hand.

The harness exposes these OS-specific sandboxing mechanisms through a common API across macOS, Windows, and Linux. This API takes a command and a permission profile. If the permission profile allows limited network access, the caller must supply a network proxy to enforce those limits:

#### Python

```` ```
1

# This is a simplified version of the actual API.



2

def spawn_command_under_sandbox(



3

program_and_args: list[str],



4

cwd: Path,



5

env: dict[str, str],



6

permission_profile: PermissionProfile,



7

network_proxy: NetworkProxy | None,



8

) -> Child:
``` ````

This function starts the process in a sandbox and returns a `Child` handle the harness can use to wait for it to finish. Each child process inherits its parent’s sandbox constraints, so those restrictions apply throughout the process tree initiated by the command, even to descendants that outlive the original process.

The following diagram shows how these pieces fit together, from configuration to running a sandboxed command. The sections that follow explain each stage.

Flow diagram: configuration and managed requirements define a session permission profile; the Codex harness launches commands under platform-specific sandbox restrictions on macOS, Linux, or Windows. Child processes inherit those restrictions, and an optional network proxy enforces domain rules.

## How the harness leverages the sandbox

As explained in [Unrolling the Codex Agent Loop](https://openai.com/index/unrolling-the-codex-agent-loop/), the Codex harness is responsible for executing tool calls generated by the model. For coding tasks, the most commonly used tool is a *shell tool*, which runs commands much as a user would in an interactive shell such as Bash. Here we’ll examine the [one-shot ⁠(opens in a new window)](https://github.com/openai/codex/blob/60947e234156ac12bdb7fba2477d3965f166bd34/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs#L483-L512)[`exec_command`⁠(opens in a new window)](https://github.com/openai/codex/blob/60947e234156ac12bdb7fba2477d3965f166bd34/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs#L483-L512) [shell tool⁠(opens in a new window)](https://github.com/openai/codex/blob/60947e234156ac12bdb7fba2477d3965f166bd34/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs#L483-L512) to illustrate how the harness employs the sandbox to achieve the desired protections.  
  
This is a simplified version of how the `exec_command` tool call would be honored by the Codex harness *without sandboxing*:

#### Python

```` ```
1

# Illustrative implementation of the exec_command tool call.



2



3

class ExecCommandToolCall:



4

cmd: str



5

workdir: str | None = None



6

shell: str | None = None



7

login: bool = True



8

timeout_ms: int = 10_000



9



10



11

def perform_exec_command(tool_call: ExecCommandToolCall):



12

program_and_args = [



13

tool_call.shell or os.environ.get("SHELL") or "/bin/sh",



14

"-lc" if tool_call.login else "-c",



15

tool_call.cmd,



16

]



17

child = subprocess.Popen(



18

program_and_args,



19

# workdir defaults to the turn's cwd, assumed here to be the process cwd.



20

cwd=Path(tool_call.workdir or ".").absolute(),



21

stdout=subprocess.PIPE,



22

stderr=subprocess.STDOUT,



23

)



24

output, exit_code = collect_output(child, timeout_ms=tool_call.timeout_ms)



25

return {"output": output, "exit_code": exit_code}
``` ````

To sandbox the command, the harness replaces the call to `subprocess.Popen()` with `spawn_command_under_sandbox()`. The harness supplies the permission profile and, when needed, the network proxy:

#### Python

```` ```
1

# Honoring the exec_command tool call while enforcing sandbox constraints.



2



3

def perform_exec_command_with_sandboxing(



4

tool_call: ExecCommandToolCall,



5

permission_profile: PermissionProfile,



6

network_proxy: NetworkProxy | None,



7

):



8

# ...build program_and_args as in the previous example...



9

child = spawn_command_under_sandbox(



10

program_and_args=program_and_args,



11

cwd=Path(tool_call.workdir or ".").absolute(),



12

env=os.environ.copy(),



13

permission_profile=permission_profile,



14

network_proxy=network_proxy,



15

)



16

output, exit_code = collect_output(child, timeout_ms=tool_call.timeout_ms)



17

return {"output": output, "exit_code": exit_code}
``` ````

The `exec_command` tool also lets the model request different permissions for an individual command, but the harness decides whether to grant the request:

#### Python

```` ```
1

class ExecCommandToolCall:



2

# ...command-related fields...



3



4

# Per-command sandbox override. Defaults to "use_default".



5

sandbox_permissions: Literal[



6

"use_default",



7

"with_additional_permissions",



8

"require_escalated",



9

] = "use_default"



10



11

# User-facing approval question; only for "require_escalated".



12

justification: str | None = None



13



14

# Expand network or filesystem access; only for "with_additional_permissions".



15

# AdditionalPermissions supports fine-grained options.



16

additional_permissions: AdditionalPermissions | None = None
``` ````

When `use_default` is specified, the harness uses the default sandbox config for the turn. `with_additional_permissions` requests expanded access within the sandbox, while `require_escalated` requests execution outside it. The harness evaluates the request based on the user’s preferences before executing the command. (For example, Codex may prompt the user directly, or it might route the request to [auto-review⁠(opens in a new window)](https://learn.chatgpt.com/docs/sandboxing/auto-review).) If execution is authorized, Codex will pass the appropriate `permission_profile` and `network_proxy` to `perform_exec_command_with_sandboxing()` with the command arguments from the original `ExecCommandToolCall`.

The shell tool is the primary consumer of `spawn_command_under_sandbox()`, and the harness also reuses its sandboxing infrastructure for operations such as reading and modifying local files. This reuse extends beyond the harness: the `codex sandbox` command lets you incorporate sandboxed command execution into your own tools, as we’ll see later. Next, we’ll look at how permission profiles are defined.

## Configuring the sandbox

A named permission profile lets you reuse the same filesystem and network restrictions across projects. You can define your own profiles under `[permissions]` in `config.toml`. For example, the following defines a profile named `dev` that [ext
OpenAI——
🟧 hnThe Codex Sandboxgiuliomagnifico20
🟧 hnInside The Codex Sandboxgmays20

Interpretation history

Decision trace