The safe default
sandbox_mode = "workspace-write"
approval_policy = "on-request"
With these, Codex can edit files in your project. It asks before running commands that need more access. OpenAI’s docs also note that some paths inside writable roots stay protected, including .git, .agents, .codex, and .aws.
What each sandbox mode means
sandbox_mode | Codex can |
|---|---|
read-only | Read files and answer questions, but not change anything |
workspace-write | Edit inside the project (writable roots) |
danger-full-access | Act anywhere on your machine, without the project boundary |
Why full access is risky
OpenAI warns that full access means Codex isn’t limited to your project directory and “might perform unintentional destructive actions that can lead to data loss.” Prefer keeping the sandbox and using rules for targeted exceptions.
Approval prompts
on-request: Codex asks when it needs to go beyond the sandbox.never: Codex doesn’t ask. It tries to solve problems within its current permissions.
The older untrusted value is retired. OpenAI has a migration note for configs that still use it.
Windows
The desktop app’s native agent runs commands in PowerShell with a Windows sandbox. Choose Ask for approval below the composer to apply sandbox protections. In WSL mode, it uses Linux sandboxing. In config.toml, OpenAI suggests preferring MXC where supported:
[windows]
sandbox = "elevated"
[features]
prefer_mxc = true
Permission profiles
Codex also ships built-in permission profiles, :read-only, :workspace, and :danger-full-access, and supports custom ones under [permissions.<name>]. In the CLI, /permissions shows the active sandbox and writable roots before you continue.