Codex

Codex sandbox modes: read-only, workspace-write, danger-full-access and network access

How do I change the Codex sandbox mode and allow network access?

Codex has three sandbox modes: read-only, workspace-write and danger-full-access. Pick one per run with codex --sandbox <mode>, or set sandbox_mode in ~/.codex/config.toml. Network access is off by default in workspace-write; turn it on with network_access = true under [sandbox_workspace_write].

The three sandbox modes

  • read-only: Codex can inspect files but cannot edit files or run commands without approval.
  • workspace-write: Codex can read files, edit inside the workspace and run routine local commands there. This is the default low-friction mode for local work. Network access is off by default.
  • danger-full-access: no sandbox. Filesystem and network limits are removed. OpenAI marks it as elevated risk and not recommended.

Set the mode for one run

Edit the workspace, ask before leaving it

codex --sandbox workspace-write --ask-for-approval on-request

Read only, for browsing or planning

codex --sandbox read-only --ask-for-approval on-request

Read only in CI, never prompt

codex --sandbox read-only --ask-for-approval never

Inside a session you can switch to read-only with the /permissions command.

Set a default in config.toml

sandbox_mode accepts read-only, workspace-write or danger-full-access. Extra keys under [sandbox_workspace_write] apply only in workspace-write mode.

~/.codex/config.toml

sandbox_mode = "workspace-write"
approval_policy = "on-request"

[sandbox_workspace_write]
network_access = true
writable_roots = ["/path/to/another/folder"]
  • network_access: allow outbound network access inside the workspace-write sandbox.
  • writable_roots: extra folders Codex may write to.
  • exclude_tmpdir_env_var: remove $TMPDIR from writable roots.
  • exclude_slash_tmp: remove /tmp from writable roots.

Paths that stay read-only

Even in workspace-write, some folders inside a writable root stay read-only, including everything under them:

  • <writable_root>/.git, whether it is a folder or a file. If it is a gitdir pointer file, the real Git folder is protected too.
  • <writable_root>/.agents when it exists as a folder.
  • <writable_root>/.codex when it exists as a folder.

How each platform enforces it

  • macOS: the built-in Seatbelt framework. It works out of the box.
  • Linux and WSL2: bubblewrap (bwrap). Codex uses the first bwrap on PATH and otherwise falls back to a bundled helper that needs unprivileged user namespace support.
  • Windows: the native Windows sandbox in PowerShell, and the Linux sandbox in WSL2.

Sources

More on Codex

Other guides

Cursor: allow all terminal commandsClaude Code: allow commands without promptsCodex CLI: approval and sandbox modesGemini CLI: YOLO mode, auto_edit and allowing specific shell commandsCursor Privacy Mode: telemetry, training and data retentionClaude Code telemetry and data retention: what is sent and how to turn it offGemini CLI: turn off usage statistics and telemetryCLAUDE.md: where it goes, how it loads, and how it works with AGENTS.mdClaude Code hooks: format on save, block risky edits, get notifiedClaude Code subagents: create one, limit its tools, and call itAdd MCP servers to Cursor with mcp.json: Keep files out of Cursor with .cursorignore: Configure Codex with config.toml: Configure Gemini CLI with settings.json: Add MCP servers to Claude Code (claude mcp add, .mcp.json, scopes): Claude Code custom slash commands and skills (SKILL.md): GitHub Copilot custom instructions: Adding MCP servers to GitHub Copilot: Claude Code settings.json: file locations, precedence, and key settingsClaude Code plugins and marketplaces: install, create, and shareGemini CLI extensions and custom commands: Configuring OpenCode with opencode.json: Cline Rules: workspace, global, and conditional rulesKiro steering files: .kiro/steering, inclusion modes, and AGENTS.mdZed agent: instruction files, MCP servers, tool permissions, and ACP agentsCursor CLI: install, headless mode, permissions and CIAider: CONVENTIONS.md, .aider.conf.yml and API keysJunie guidelines, MCP and the Action Allowlist: Amp AGENTS.md, settings.json and MCP: Configure Goose extensions, hints, recipes and permissions: Customize OpenHands with skills, AGENTS.md, setup.sh and MCP: Configure Factory Droid CLI: AGENTS.md, settings.json, autonomy, custom droids and MCPConfigure Qwen Code: settings.json, providers, QWEN.md, MCP and approval modesCursor hooks: hooks.json, beforeShellExecution, afterFileEdit and exit codesCursor sandbox: sandbox.json, network allowlist and run modesCursor settings: settings.json, Cursor Settings and the ~/.cursor config filesCursor browser agent: @browser, browser automation and approval modesCursor subagents: .cursor/agents, frontmatter, built-in Explore, Bash and BrowserCursor telemetry and OpenTelemetry export (Privacy Mode, OTLP, Analytics API): Cursor rules setup: .cursor/rules, .mdc frontmatter, globs, alwaysApply and AGENTS.mdClaude Code headless mode: claude -p, --output-format json, --bare and CI flagsClaude Code statusline: custom status bar in settings.json with context %, cost and git branchClaude Code /model: switch models, aliasesClaude Code /cost and /usage: check token spend, usage limits and reduce costsClaude Code VS Code extension: install, shortcuts, settings and /ideCodex AGENTS.md: global, project and override instruction files explainedCodex MCP servers: codex mcp add and [mcp_servers] in config.tomlcodex exec: run Codex non-interactively in scripts and CI with JSON outputCodex skills: create SKILL.md, skill folder locations and $skill invocationGEMINI.md in Gemini CLI: context file locations, imports and /memoryGemini CLI MCP servers: gemini mcp add and mcpServers in settings.jsonGemini CLI custom slash commands: TOML files, {{args}}, !{shell} and @{file}Gemini CLI headless mode: gemini -p, JSON output and exit codes for scripts and CIGemini CLI sandbox: enable Docker, Podman, macOS Seatbelt or gVisorcopilot-setup-steps.yml: set up the GitHub Copilot cloudGitHub Copilot CLI permissions: --allow-tool, --deny-tool, --allow-all-tools and trusted directoriesGitHub Copilot custom agents: .github/agents/*.agent.md profiles, tools and frontmatterGitHub Copilot code review settings: automatic PR reviews, rulesets, effort level and approvals

Get the weekly agent stack update

New official MCP servers, spec changes and harness releases, checked against the source. One email a week, no fluff.

Reviewed Oct 13, 2026. Settings change often; the linked vendor docs are the source of truth.