All articles
platform engineering·intermediate··Updated

Codex sandboxing: separate filesystem scope from approvals

Codex treats sandbox enforcement and approval policy as separate controls, and subagents inherit the active parent runtime before role defaults apply.

codexcoding-agentspatternssandboxingsecurity

A Codex permission decision has two independent parts: what the operating system sandbox permits, and whether Codex may ask to step outside that boundary. Treating those controls as one switch creates both false confidence and unnecessary full-access sessions.

Resources
Resource Link
Codex sandboxing concepts developers.openai.com/codex/sandboxing
Codex custom agents developers.openai.com/codex/subagents
Codex configuration reference developers.openai.com/codex/config-reference

The sandbox enforces the boundary

Codex exposes three sandbox modes. The mode controls filesystem writes and network access at the process boundary; instructions in a prompt do not replace that enforcement.

Codex sandbox modes
Mode Write boundary Network Appropriate work
read-only No filesystem writes Blocked Review, exploration, and diagnosis
workspace-write Current workspace and configured writable roots Blocked by default Implementation, refactoring, and tests
danger-full-access No Codex sandbox boundary Available Tasks that genuinely require host-level access

read-only does not mean “shell disabled.” Read operations still run. A command that needs to write, open the network, or cross another restricted boundary may require an approval, depending on the approval policy.

workspace-write is the useful implementation default. Network access remains a separate opt-in:

~/.codex/config.tomltoml
sandbox_mode = "workspace-write"

[sandbox_workspace_write]
network_access = true

This grants outbound network access without granting arbitrary writes outside the workspace.

Approval policy controls escalation

The approval policy determines whether Codex may pause and request permission for an operation outside the active sandbox. It does not change the sandbox by itself.

Two controls, two questions
Control Question
Sandbox mode What can the process do without leaving its enforced boundary?
Approval policy Can Codex ask a person to authorize an operation outside that boundary?

A read-only session with approvals available can request a write. A workspace-write session with approvals disabled cannot escape its workspace merely because a prompt asks it to. Full access removes the sandbox boundary; pairing it with an approval policy of never removes the interactive checkpoint as well.

Use /permissions during an interactive Codex session to inspect or change the active permission mode. The selected runtime state matters when work is delegated.

Subagents inherit the active runtime

A custom agent file can declare sandbox_mode as a reusable default. That declaration is not an immutable security ceiling.

When a subagent starts, omitted settings inherit from the parent. Active parent overrides — including choices made through /permissions or a full-access launch — are reapplied to the child even when its custom agent file declares different defaults.

~/.codex/agents/explorer.tomltoml
name = "explorer"
description = "Maps code and reports evidence without making edits."
sandbox_mode = "read-only"
developer_instructions = """
Inspect the requested surface and cite file paths and line numbers.
Do not edit files or run mutation commands.
"""

The role file makes read-only exploration the normal behavior. It does not protect the child from a parent session that has already been widened.

Match the boundary to the job

Start from the operation the role must complete, then grant the narrowest boundary that supports it.

Role-to-boundary examples
Role Sandbox Network Reason
Code reviewer read-only Off Reads source and reports findings
Repository mapper read-only Off Traces ownership and dependencies
Feature implementer workspace-write Off Edits and tests local code
Dependency updater workspace-write On for the update Fetches packages while keeping writes scoped
Machine bootstrapper danger-full-access As required Changes host-level state

Network access deserves its own decision. Package installation, remote documentation, and API calls need it; most local review and implementation work does not.

Prompts still matter

Sandboxing limits capability, not intent. A workspace-write agent can still delete project files, rewrite a lockfile, or make a poor architectural change inside its permitted root.

Instructions, lifecycle hooks, review gates, and version-control recovery address those risks. The sandbox answers “where can this process act?” Other controls answer “which actions should it take?” and “how is a bad action detected or reversed?”

Takeaways

Separate enforcement from escalation

Sandbox mode defines the process boundary; approval policy defines whether Codex may request an exception.

Prefer workspace-scoped writes

Enable network access independently when implementation needs external packages or services.

Treat agent files as defaults

Active parent permission overrides are reapplied to subagents, so a role-level sandbox is not an immutable cap.

Use managed policy for hard limits

Organizational enforcement belongs in the allowed runtime configuration, not in prose instructions.