Skip to content
← All guides

Codex sandbox: modes, macOS Seatbelt and network access

How the Codex sandbox works on a Mac. Read-only, workspace-write and danger-full-access, writable roots, protected paths and network defaults.

4 min read

The Codex sandbox limits what commands the model writes can touch. It has three modes, read-only, workspace-write and danger-full-access. On macOS it uses Seatbelt, which is built in. By default the agent runs with network access off. Inside writable roots, Codex also keeps .git, .agents, .codex and .aws read-only.

The three modes

ModeWhat the docs say it allows
read-onlyInspect files. No edits and no commands without approval
workspace-writeRead files, edit within the workspace and run routine local commands inside that boundary
danger-full-accessRun without sandbox restrictions

Pick one with --sandbox (short form -s) or with sandbox_mode in config.toml. The docs say workspace-write is the default for the Auto preset. The sandbox is separate from approvals. The approval policy decides when Codex stops to ask you. The installed help for Codex CLI 0.166.0 lists on-request and never for --ask-for-approval.

How it works on macOS

The docs say Codex uses Seatbelt policies on macOS and runs commands with sandbox-exec and a profile that matches the selected mode. If the platform sandbox cannot enforce the chosen policy, the permissions docs say Codex refuses to run the command instead of running it unsandboxed.

Writable roots and protected paths

In workspace-write, the workspace is the current directory plus temporary directories like /tmp. Run /status in a session to see which directories are included. To add folders, use --add-dir <DIR>, or set roots in config.

sandbox_mode = "workspace-write"
 
[sandbox_workspace_write]
network_access = false
writable_roots = ["/Users/you/other-project"]
exclude_slash_tmp = false
exclude_tmpdir_env_var = false

Inside writable roots, the docs say .git (as a directory or file), .agents, .codex and .aws stay read-only when they exist, recursively. That protects hooks, rules and cloud credentials in those folders from the agent.

Network access

The docs state that by default the agent runs with network access turned off. In workspace-write you can allow it with sandbox_workspace_write.network_access = true. Permission profiles have their own setting, permissions.<name>.network.enabled, which defaults to false, and domain rules apply only when features.network_proxy is active. Web search is a separate tool. It defaults to web_search = "cached", and the docs say to treat web results as untrusted because prompt injection can make the agent follow untrusted instructions.

Permission profiles

Newer Codex docs describe permission profiles. The built-ins are :read-only, :workspace and :danger-full-access, selected with default_permissions. A custom [permissions.<name>] table can extend :workspace, set filesystem roots and set network rules. The docs say that if sandbox_mode is set or you pass --sandbox, Codex uses the older settings instead of default_permissions. Don’t combine the two styles in one config.

Test a command under the sandbox

Codex 0.166.0 has a codex sandbox subcommand that runs a command under the platform sandbox. The CLI reference lists these macOS flags.

  • --permission-profile, -P NAME applies a named profile.
  • --log-denials prints macOS sandbox denials after the command exits.
  • --allow-unix-socket path allows Unix sockets under a path.
  • -C, --cd DIR sets the working directory and requires --permission-profile.

Use a harmless command in a disposable folder first. Then check whether the write or network call you expected was refused.

What the sandbox does not cover

The sandbox applies to commands the model runs. It does not protect a shared branch on your Git host, and it does nothing about a folder you made writable. Keep the writable list short. To remove the sandbox deliberately, read the bypass flag guide. For the full config file, see Codex config.toml.

Checked against the vendor documentation on November 25, 2026. Sandboxing · Agent approvals and security · Permissions · Config reference · CLI reference

Set sandbox rules once

Excellent Pro can configure Codex’s native Mac sandbox, and Claude Code’s, from your file and folder rules, with a plan to review first. Sandbox setup. Excellent’s free scan reads supported logs on the Mac and reports findings for review, so you can see what Codex ran afterward. For a local report without installing an app, run the free scan. See a sample report. Pro is priced here and is US-only for now.

Related guides

View all