Kipt

Codex sandbox and approvals: modes, network access and presets

Codex sandbox guide: the read-only, workspace-write and full-access modes, approval policies, network access, protected paths, OS enforcement and safe presets.

By the Kipt team · Updated 24 October 2026

The Codex sandbox is the OS-enforced boundary that limits what commands run by Codex can touch. By default, Codex can read files, edit inside your workspace and run routine commands there, with network access off. An approval policy decides when Codex must stop and ask before crossing that boundary. Together they set how much Codex does on its own.

This guide covers the three sandbox modes, approval policies, network access, protected paths, OS enforcement and presets, from OpenAI's Sandbox and Agent approvals & security pages, read on 24 October 2026. For where these settings live, see the Codex config.toml guide.

What does the Codex sandbox do?

It applies to every command Codex spawns, not just its own file edits. If Codex runs git, a package manager or your test runner, those programs inherit the same limits. It works the same way in the Codex CLI, the IDE extension and local chats in the desktop app.

OpenAI's docs separate the two controls clearly: "The sandbox defines technical boundaries. The approval policy decides when the agent must stop and ask before crossing them." The payoff is fewer prompts. Codex can do low-risk work without asking, and you only hear from it when a task needs more access.

What are the three sandbox modes?

Mode What Codex can do When to use it
read-only Inspect files; editing or running commands needs approval Planning, reviews, exploring unfamiliar code
workspace-write Read, edit inside the workspace, run routine local commands Everyday local work (the default low-friction mode)
danger-full-access Everything, with no filesystem or network limits Only inside a container or VM that is itself the boundary

Choose one per run with --sandbox (or -s), or set a default:

# ~/.codex/config.toml
sandbox_mode = "workspace-write"

The workspace includes the current folder plus temporary directories such as /tmp. Run /status to see exactly which directories are included. When Codex needs another folder, --add-dir path grants write access to it without dropping the sandbox, and sandbox_workspace_write.writable_roots does the same in config.

Which approval policies can you use?

The approval policy controls when Codex pauses:

  • on-request: Codex works inside the sandbox and asks when it needs to go beyond it, such as editing outside the workspace or using the network.
  • never: Codex never stops for approval. It still respects the sandbox and does its best within those limits.
  • Granular: approval_policy = { granular = { ... } } keeps some prompt categories interactive and rejects others automatically. It covers sandbox approvals, rules prompts, MCP prompts, request_permissions prompts and skill-script approvals.

Set it with --ask-for-approval (-a) or approval_policy in config.

The untrusted policy is retired. OpenAI's docs warn that approval_policy = "untrusted" "can prevent either client from starting." Remove it from user config, project config, profiles and scripts. For the old strict behavior, leave approval_policy unset and add a project entry to ~/.codex/config.toml instead:

[projects."/path/to/project"]
trust_level = "untrusted"

Commands in that project then need approval unless a rule allows them, and project-local config is disabled. Explicitly setting on-request overrides the project-derived policy.

Who reviews approvals?

approvals_reviewer decides who answers a prompt. The default is user. Set auto_review and eligible requests go to a separate reviewer agent first, with the same sandbox boundary. The reviewer checks for data exfiltration, credential probing, persistent security weakening and destructive actions, and it fails closed on errors. It uses extra model calls, so it adds to usage. The Auto-review page has the details.

What are the Codex presets?

These combinations follow OpenAI's table of common setups, with the CLI's --approve-for-me shortcut added:

Intent Flags Effect
Auto (default preset) none, or --sandbox workspace-write --ask-for-approval on-request Edits and commands in the workspace; asks to go outside it or use the network
Safe read-only browsing --sandbox read-only --ask-for-approval on-request Reads and runs commands in the read-only sandbox; asks for more
Read-only CI --sandbox read-only --ask-for-approval never Read-only, never asks
Auto-review --approve-for-me, or approvals_reviewer = "auto_review" with on-request Same boundary as Auto; a reviewer agent answers eligible prompts
Dangerous full access --dangerously-bypass-approvals-and-sandbox (alias --yolo) No sandbox, no approvals; not recommended

In the IDE extension and desktop app, the permissions control under the composer shows these as Ask for approval, Approve for me and Full access. In the CLI, type /permissions to switch. When you launch Codex in a folder under version control, it recommends Auto; outside version control it recommends read-only.

You can save a preset as a profile file and load it with codex --profile name:

# ~/.codex/readonly_quiet.config.toml
approval_policy = "never"
sandbox_mode    = "read-only"

How does network access work?

Network access is off by default. To let commands reach the internet in workspace-write mode:

[sandbox_workspace_write]
network_access = true

That gives unrestricted outbound access. To limit it to specific destinations, also turn on the network_proxy feature with domain rules:

[features.network_proxy]
enabled = true
domains = { "api.openai.com" = "allow", "example.com" = "deny" }

The proxy never grants network access by itself; with network off it does nothing. Domain rules are allowlist-first: *.example.com matches subdomains only, **.example.com matches the apex and subdomains, and deny always wins. Local and private addresses stay blocked unless you add an exact localhost or IP rule.

The proxy does not filter web search, MCP server connections, app tool calls or cloud tasks, which have their own controls. Web search defaults to cached mode, which returns results from an OpenAI-maintained index instead of fetching live pages. Use --search or web_search = "live" for live results, or "disabled" to turn it off.

Which paths stay protected?

Even in workspace-write, some folders inside each writable root are read-only:

  • .git, whether it is a folder or a pointer file (and the real Git directory a pointer file points to)
  • .agents, when it exists as a folder
  • .codex, when it exists as a folder
  • .aws, when it exists as a folder

Protection is recursive, so sandboxed commands cannot write to your Git directory, Codex config, skills folder or AWS credentials.

How is the sandbox enforced on each OS?

  • macOS: Seatbelt policies through sandbox-exec. Works out of the box.
  • Linux and WSL2: bwrap plus seccomp. Install bubblewrap first (sudo apt install bubblewrap or sudo dnf install bubblewrap). WSL1 is no longer supported.
  • Windows: Codex's native Windows sandbox in PowerShell, or the Linux sandbox inside WSL2.

In Docker, the inner sandbox may fail if the container blocks namespaces or seccomp. OpenAI's advice is to make the container the boundary and run Codex with --sandbox danger-full-access inside it, with the warning that a malicious project could then reach anything in the container, including Codex credentials. Use that pattern only with trusted repositories.

To see what a command does under the sandbox, test it directly:

codex sandbox macos --log-denials npm test
codex sandbox linux npm test

How do rules give narrow exceptions?

When one command keeps needing approval, a rule beats widening the sandbox. Rules live in .rules files under a rules/ folder next to a config layer, such as ~/.codex/rules/default.rules, and are marked experimental. This example is adapted from OpenAI's rules page, trimmed to leave out its optional match and not_match test lists:

prefix_rule(
    pattern = ["gh", "pr", "view"],
    decision = "prompt",
    justification = "Viewing PRs is allowed with approval",
)

decision can be allow, prompt or forbidden, and the most restrictive match wins. Project rules in .codex/rules/ load only for trusted projects.

Tips for a safe Codex setup

  • Stay on Auto in a Git repo. A clean working tree makes every change easy to review and revert.
  • Grant folders, not full access. --add-dir keeps the sandbox on for everything else.
  • Pick the narrowest approval scope. Approve once rather than for the session when you can.
  • Turn on the network proxy before opening the network so commands reach only the hosts you list.
  • Treat web content as untrusted. Prompt injection is the main risk once network or live search is on.

Keep your skills safe from the sandbox and from loss

The sandbox protects .agents precisely because skills shape what Codex does. Keep those folders under version control too: Kipt stores prompts and Agent Skills as Markdown in a private GitHub repo you own and installs them into Codex with one npx skills add command. The Codex skills guide covers where Codex reads them from.

Questions

What are the Codex sandbox modes?

There are three: read-only, where Codex can inspect files but not edit them or run commands without approval; workspace-write, where it can edit files and run routine commands inside the workspace; and danger-full-access, which removes the filesystem and network boundaries. Set one with --sandbox or sandbox_mode in config.toml.

Does Codex have internet access by default?

No. In the CLI, IDE extension and desktop app, the default workspace-write sandbox keeps network access off. Turn it on with network_access = true under [sandbox_workspace_write] in config.toml, and optionally enable the network_proxy feature to limit which domains commands can reach.

What happened to the untrusted approval policy?

Codex no longer supports approval_policy = "untrusted", and the old setting can stop Codex from starting. Remove it and use on-request with a read-only sandbox, or set trust_level = "untrusted" for that project in your user config.toml to keep command approvals strict.

How do I run Codex without approval prompts?

Add --ask-for-approval never, or -a never. It works with every sandbox mode, so Codex still stays inside the limits you set. The --yolo flag goes further and removes both approvals and the sandbox; OpenAI says to use it only inside an externally hardened environment.

Which folders can Codex never write to in workspace-write mode?

Inside each writable root, .git, .agents, .codex and .aws are protected as read-only when they exist, and the protection covers everything beneath them. If .git is a pointer file, the Git directory it points to is protected too.

Do I need to install anything for the Codex sandbox on Linux?

Yes. On Linux and WSL2, install bubblewrap with your package manager, for example sudo apt install bubblewrap. macOS uses the built-in Seatbelt framework and needs nothing extra, and native Windows uses Codex's own Windows sandbox.

More in Codex

All guides

Keep your prompts and skills in one place, in your own GitHub. Install every skill with one command.

Get started

Kipt is an independent product, not affiliated with or endorsed by Anthropic, OpenAI, Cursor or GitHub. Claude, ChatGPT, Codex, Cursor and GitHub are trademarks of their owners.