Safeguard
AI Security•

Codex sandbox modes and approval policies: what does each combination do?

Codex pairs a sandbox mode with an approval policy. See what read-only, workspace-write, on-request, and never mean, and which pairing suits which repo.

Safeguard Security Team
6 min read

OpenAI's Codex pairs a sandbox mode, which limits what the agent can touch, with an approval policy, which decides when it must ask. The documented default is workspace-write with on-request approvals and network off. For folders outside version control, the documentation recommends read-only.

The settings, as documented

OpenAI's documentation on agent approvals and security describes three sandbox modes and several approval modes.

SettingWhat the page says
read-onlySandbox mode with no edits
workspace-writeThe default "Auto" preset. Codex can edit files and run commands in the working directory, and asks before editing outside the workspace
danger-full-accessNo sandbox and no approvals, and the page does not recommend it
on-request approvalCommands allowed by the sandbox run without approval. Codex asks before leaving the sandbox or using network access, if enabled
never approvalDisables approval prompts, and works with every sandbox mode
granular policyKeeps selected prompt categories interactive and automatically rejects the rest

The page also states that the agent runs with network access turned off by default, and that inside workspace-write the network stays off unless a specific setting enables it. It notes that an older approval value is retired and can prevent startup, so remove it from configuration.

What the combinations mean in practice

The two settings multiply. Read them as a grid.

SandboxApprovalEffectSuitable for
read-onlyon-requestReads freely, cannot edit, asks if it needs moreExploring unfamiliar code, folders not under version control
workspace-writeon-requestEdits and runs inside the workspace, asks to leave itDay to day work on a feature branch
workspace-writeneverEdits and runs inside the workspace, never asks, still confinedUnattended tasks in a throwaway environment
danger-full-accessneverNo limits at allNot recommended by the documentation

The third row is worth thinking about. Disabling prompts is not the same as removing limits, because the sandbox still bounds what happens. The dangerous cell is the last one, where both controls are gone.

Recommended practice from the documentation

The page recommends the Auto preset for version controlled folders and read-only for folders without version control. It suggests setting values explicitly, for example by passing both the sandbox and approval flags on the command line, so behavior does not depend on defaults that may change. It advises working on a feature branch with a clean git status and reviewing diffs before accepting changes, and it advises keeping prompt logging off unless policy permits storing prompts.

Turn those into a short team standard:

  1. Always set sandbox and approval explicitly in a shared configuration.
  2. Start in a feature branch with a clean status.
  3. Keep network off unless a task needs it, and enable it per task.
  4. Review every diff.
  5. Decide whether prompts may be stored, and write down the answer.

Cloud tasks

For cloud tasks, the documentation describes isolated, OpenAI managed containers, where setup can reach the network to install dependencies and the agent phase runs offline by default unless internet access is enabled for that environment. Secrets for cloud environments are available only during setup and removed before the agent phase starts. It also says local command line and editor use rely on operating system level sandboxing with settings you configure yourself. Check the current page for the latest cloud details, because it says current cloud behavior is documented elsewhere.

That secrets pattern is a good model for any team: give the agent credentials only while it needs them, and remove them before it starts working on untrusted text.

A worked example: choosing per repository tier

Repository tierSandboxApprovalNetwork
Public libraryworkspace-writeon-requestOff, mirror when needed
Internal serviceworkspace-writeon-request, granular for installsOff by default, per task opt in
Restricted codeNot allowed until reviewedNot applicableNot applicable
Unversioned scratch folderread-onlyon-requestOff

Checking what is really enforced

Test the settings on a throwaway project. Ask a read-only session to create a file. Ask a workspace-write session to edit a file outside the workspace and to fetch a page. In each case you should see a block or a prompt. Record the result with the tool version, since behavior changes over time.

Writing the team standard

Turn the grid into a one page standard that engineers can read in two minutes.

ItemStandard
Default sandboxworkspace-write for version controlled projects, read-only elsewhere
Default approvalon-request
NetworkOff by default, enabled per task with a note in the pull request
Full access modeNot permitted
Prompt storageOff unless policy permits
Explicit settingsRequired in shared configuration
ReviewEvery diff read by the author and a second reviewer

Add an exception path for unusual work, with an owner, a reason, and an expiry date. Then spot check a few developer machines each quarter, since local settings can differ from the standard.

Try it yourself

Click through it at your own pace, or open it full screen.

Click through and notice that checks apply to a change regardless of the sandbox settings of the session that wrote it.

Where Safeguard fits

Sandbox and approval settings govern the session. Safeguard works at the dependency and pipeline end: SBOM and dependency scanning, reachability analysis, policies and gates on pull requests, and agent identity. You can try a free scan at gold.safeguard.sh/scan.

Quick check

Is "never" approval the same as full access?

No. It disables prompts and works with every sandbox mode, so a confined sandbox still limits what happens. Full access is the separate mode with no sandbox.

Which setting is safest for a folder outside version control?

The documentation recommends read-only for such folders, since changes there cannot be reviewed as a diff.

Should we rely on defaults?

Set sandbox and approval values explicitly in shared configuration, so a default change does not alter your posture silently.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.