Skip to content

Claude Code vs Codex: sandbox, approvals and security compared

Claude Code and Codex side by side on sandboxing, approval modes, network access, hooks, admin policy and public advisories, with a source for every fact.

Checked

Claude Code

Made by
Anthropic
Out of the box
From v2.1.283, interactive terminal and VS Code sessions start in auto mode, where a classifier reviews actions. Without a supported model it starts in Manual. claude -p and Agent SDK runs start in Manual, which asks before edits, shell commands and network access.
Sandbox
Yes, off by default. Turn on with /sandbox or sandbox.enabled. macOS uses Seatbelt, Linux and WSL2 use bubblewrap. Not supported on native Windows. Covers Bash, PowerShell and Monitor commands only. File tools, MCP servers and hooks run outside it.
Public advisories
8 with a CVE or GHSA id, 6 rated critical or high

Codex

Made by
OpenAI
Out of the box
In a version-controlled folder it starts in the Auto preset: workspace-write sandbox with on-request approvals, so sandboxed commands run and leaving the sandbox asks. Folders without version control start read-only.
Sandbox
Yes, on by default. macOS uses Seatbelt through sandbox-exec, Linux uses bwrap and seccomp, Windows has its own sandbox. It covers spawned commands, and .git, .agents, .codex and .aws stay read-only inside writable roots.
Public advisories
1 with a CVE or GHSA id, 1 rated critical or high

Short answer

Both agents can ask before risky actions, both can run commands in a macOS Seatbelt sandbox, and both let admins lock settings. They start from different defaults. Codex turns its sandbox on from the first run and keeps network access off inside it. Claude Code leaves its sandbox off until you turn it on, and since v2.1.283 interactive sessions start in auto mode, where a classifier reviews each action. Codex is the stricter out of the box. Claude Code gives you finer allow, ask and deny rules, and its sandbox once you switch it on.

At a glance

Every answer links to the page that says it. Both agents change often, so their own docs win where they differ from this page.

Safety controls, side by side
QuestionClaude CodeCodex
Sandbox on from the first runNoOpt-in with /sandbox3Yesworkspace-write in a repo, read-only elsewhere26
OS-level sandbox availableYesSeatbelt on macOS, bubblewrap on Linux3YesSeatbelt on macOS, bwrap and seccomp on Linux26
No network in commands by defaultPartlyAsks in Manual mode; with the sandbox, an allowlist that starts empty34YesOff until network_access = true234
Asks you before shell commands by defaultPartlyAuto mode lets a classifier approve; Manual mode asks2PartlySandboxed commands run; leaving the sandbox asks2
Deny rules you writeYesdeny arrays, checked first4PartlyAdmin command rules can prompt or forbid27
A hook can block a tool callYesPreToolUse with exit code 2 or a deny5YesPreToolUse can deny10
Admin policy users cannot overrideYesManaged settings file, MDM or admin console8Yesrequirements.toml, also by MDM7
Admins can turn off the skip-approvals modeYesAdmins can disable bypassPermissions2Yesrequirements.toml enforces approval and sandbox modes24
Open sourceNoThe sandbox runtime is open source93YesApache-2.0 CLI8

The basics

QuestionClaude CodeCodex
Runs in
Terminal CLI, VS Code and JetBrains extensions, desktop app, web at claude.ai/code, mobile app, GitHub Actions and GitLab CI/CD, and an Agent SDK.1
Terminal CLI, IDE extension and desktop app (macOS and Windows) share one config.toml. Codex cloud is a separate surface that runs tasks on OpenAI's side.496
Platforms
macOS, Linux, WSL and native Windows. Installs with a script, Homebrew, WinGet, apt, dnf or apk.1
CLI sandbox on macOS, Linux and Windows (WSL2 uses the Linux sandbox). The desktop app launches on macOS or Windows.24
Open source
No. The anthropics/claude-code repo holds issues, plugins and examples, and its license file is "All rights reserved" under Anthropic's Commercial Terms. The sandbox runtime is a separate open source package.93
Yes, Apache-2.0 (the CLI, in the openai/codex repository). Latest release at verification: rust-v0.173.0.8
Models
Claude models from Anthropic, or third-party providers such as Amazon Bedrock, Google Cloud and Microsoft Foundry. Auto mode needs Opus 4.6 or later, Sonnet 4.6 or later, Haiku 5.5 or a Fable model on the Anthropic API.12
OpenAI models. The 0.171.0 changelog entry adds GPT-6.2 Sol and Astra to the catalogs, with Sol as the default selection. You set model in config.toml.59
Pricing
Included with Claude Pro, Max, Ultra, Team and Enterprise plans, not Free. Pro is $20 a month, or $17 a month billed annually. Also usable with an Anthropic Console API account at API rates.101
Included in ChatGPT Free, Go, Plus, Pro, Business, Edu and Enterprise plans. Plus is $20 a month. You can also use an API key and pay API rates, without the cloud features.1

Safety controls

QuestionClaude CodeCodex
Out of the box
From v2.1.283, interactive terminal and VS Code sessions start in auto mode, where a classifier reviews actions. Without a supported model it starts in Manual. claude -p and Agent SDK runs start in Manual, which asks before edits, shell commands and network access.2
In a version-controlled folder it starts in the Auto preset: workspace-write sandbox with on-request approvals, so sandboxed commands run and leaving the sandbox asks. Folders without version control start read-only.2
Sandbox
Yes, off by default. Turn on with /sandbox or sandbox.enabled. macOS uses Seatbelt, Linux and WSL2 use bubblewrap. Not supported on native Windows. Covers Bash, PowerShell and Monitor commands only. File tools, MCP servers and hooks run outside it.3
Yes, on by default. macOS uses Seatbelt through sandbox-exec, Linux uses bwrap and seccomp, Windows has its own sandbox. It covers spawned commands, and .git, .agents, .codex and .aws stay read-only inside writable roots.26
Network in commands
Without the sandbox, network commands and WebFetch ask in Manual mode, apart from preapproved documentation domains. With it, traffic goes through a local proxy that checks sandbox.network.allowedDomains, which starts empty.34
Off by default in the sandbox. You turn it on with network_access = true under [sandbox_workspace_write]. Domain rules apply only when the network_proxy feature is on. Web search defaults to cached results.234
Turning approvals off
--dangerously-skip-permissions, same as --permission-mode bypassPermissions. Skips prompts and safety checks. Deny rules and explicit ask rules still apply. Docs say to use it only in containers or VMs. Admins can disable it.2
--dangerously-bypass-approvals-and-sandbox, alias --yolo, runs every command with no approvals and no sandbox. The docs mark it not recommended. --ask-for-approval never turns prompts off but keeps the sandbox.24
Permission rules
permissions.allow, ask and deny arrays in settings.json, for example Bash(npm run test *) and Read(./.env). Deny is checked first, then ask, then allow. /permissions lists them.4
Execution-policy rules decide which commands run without approval, and a rule can also require review. Admins can add command rules in requirements.toml that can only prompt or forbid. The rules file syntax is Not documented on pages checked today.27
Hooks before a tool runs
Yes. PreToolUse hooks run before a tool call and can block it with exit code 2 or a deny decision. Types are command, http, mcp_tool, prompt and agent. A crashed hook does not block unless onFailure is block.5
Yes, on by default. PreToolUse can deny a call (permissionDecision: "deny" or exit code 2) or rewrite its input. It covers shell, apply_patch and MCP tools, not hosted tools such as web search. The docs call hooks a guardrail, not a complete boundary.10
Project instructions
CLAUDE.md in the project and in ~/.claude/, plus CLAUDE.local.md and .claude/rules/. Can read AGENTS.md in place of CLAUDE.md. These are guidance, not enforced.61
AGENTS.md. Codex reads ~/.codex/AGENTS.override.md or AGENTS.md, then one file per directory from the project root down. Combined size is capped at 32 KiB by default. Fallback names are configurable.11
MCP servers
Yes. HTTP, SSE (deprecated), stdio and WebSocket. Servers live in .mcp.json (project) or ~/.claude.json (local and user scope). Admins can set managed-mcp.json or managedMcpServers.78
Yes. Servers are [mcp_servers.<name>] tables in ~/.codex/config.toml or a trusted project's .codex/config.toml, over stdio or streamable HTTP. codex mcp add manages them.12
Session history
Plaintext JSONL transcripts at ~/.claude/projects/<project>/<session>.jsonl, prompt history in ~/.claude/history.jsonl. Transcripts are deleted after 30 days by default (cleanupPeriodDays)6
Local state lives under CODEX_HOME, default ~/.codex. The docs name history.jsonl there. Session files exist at ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl, but the docs checked today do not describe that folder.13
Admin policy
Yes. /Library/Application Support/ClaudeCode/managed-settings.json on macOS, a com.anthropic.claudecode MDM profile, or server-managed settings from the claude.ai admin console. Users and project files cannot override them.8
requirements.toml at /etc/codex/requirements.toml (macOS and Linux) or via macOS MDM domain com.openai.codex, key requirements_toml_base64. Cloud requirements also exist. Users cannot override them. Plans that get cloud requirements: Not documented.7

The differences that matter

The sandbox is on by default in Codex and opt-in in Claude Code

Codex runs commands in a sandbox from the start: Seatbelt on macOS, bwrap and seccomp on Linux. In a version-controlled folder it can write inside the project, and .git, .codex, .agents and .aws stay read-only. Claude Code has a sandbox too, also Seatbelt on macOS, but you turn it on with /sandbox or sandbox.enabled. Once on, it covers shell commands only, so file tools, MCP servers and hooks run outside it.

What runs without asking

Codex's Auto preset runs commands inside the sandbox without asking, and asks when one needs to leave it. Claude Code's interactive sessions start in auto mode, where a classifier approves routine actions and pauses after repeated blocks. Scripted runs with claude -p start in Manual mode, which asks before edits, shell commands and network access.

Network access

In Codex the sandbox has no network until you set network_access = true. In Claude Code without the sandbox, network commands ask in Manual mode. With the sandbox on, traffic goes through a local proxy that checks a list of allowed domains, and that list starts empty.

Turning the safety off

Codex's --yolo flag removes both the sandbox and the approvals in one go. If you only want no prompts, --ask-for-approval never keeps the sandbox. Claude Code's --dangerously-skip-permissions skips prompts, but deny rules and explicit ask rules still apply, and admins can disable the flag.

Rules, hooks and admin policy

Claude Code takes allow, ask and deny rules per tool in settings.json, checking deny first. Codex uses execution-policy rules, and admins can add command rules that can only prompt or forbid. Both have a PreToolUse hook that can block a call. Admins set Claude Code's managed-settings.json and Codex's requirements.toml, and both can be pushed by macOS MDM.

Public advisories

Claude Code's repository lists eight advisories since June 2026, six of them rated high, and two of those affect Claude Desktop. Codex's repository lists one, from September 2025. Each was fixed in a named release. A longer list often means more researchers are looking, so read the advisories rather than counting them.

Approval modes

Each agent's modes, from the one that asks most to the one that asks least, with the mode each starts in marked.

Claude Code

  1. planAsks for some actions
  2. default (Manual)Asks before each action
  3. dontAskNever asks
  4. acceptEditsAsks for some actions
  5. autoAsks for some actionsStarts here
  6. bypassPermissionsNever asks

Codex

  1. read-onlyAsks for some actions
  2. workspace-write with on-request (Auto)Asks for some actionsStarts here
  3. granular approvalsAsks for some actions
  4. neverNever asks
  5. danger-full-accessAsks for some actions
  6. yoloNever asks

Claude Code modes in detail

ModeHow to turn it onAsks youWhat it allows
plan
Shift+Tab, --permission-mode plan or /plan
For some actions
Reads and proposes changes without editing source until you approve the plan.
default (Manual)
--permission-mode default or permissions.defaultMode
Before each action
Prompts for most edits, shell commands and network access. Reads in the working directory run without asking.
dontAsk
--permission-mode dontAsk (not in the Shift+Tab cycle)
Never
Denies every call that would prompt. Only reads and pre-approved tools run.
acceptEdits
Shift+Tab, --permission-mode acceptEdits
For some actions
Auto-approves edits and common filesystem commands in the working directory. Other Bash commands still prompt.
auto
Shift+Tab, --permission-mode auto or defaultMode in user settings
For some actions
A classifier model blocks risky actions such as curl | bash and force pushes. Pauses and prompts after 3 blocks in a row or 20 in total.
bypassPermissions
--dangerously-skip-permissions or --permission-mode bypassPermissions
Never
Skips prompts and safety checks. Deny rules and explicit ask rules still apply. Docs say it offers no protection against prompt injection.

Codex modes in detail

ModeHow to turn it onAsks youWhat it allows
read-only
--sandbox read-only, /permissions, or sandbox_mode in config.toml
For some actions
Codex can read files and run commands but cannot edit. This is the start state outside version-controlled folders.
workspace-write with on-request (Auto)
Default in version-controlled folders; --sandbox workspace-write --ask-for-approval on-request
For some actions
Edits and commands in the workspace run inside the sandbox. Codex asks before leaving the sandbox or using network access it has not been granted.
granular approvals
approval_policy set to granular in config.toml
For some actions
You keep chosen approval categories interactive (sandbox, rule, MCP, permission and skill-script prompts) and the rest are rejected automatically.
never
--ask-for-approval never or -a never
Never
Approval prompts are off. The sandbox mode still limits what Codex can do.
danger-full-access
--sandbox danger-full-access
For some actions
No sandbox. Approval policy still applies unless you also set never.
yolo
--yolo or --dangerously-bypass-approvals-and-sandbox
Never
Removes both the sandbox and approvals. Web search defaults to live results in full-access modes.

Where their settings live

Claude Code

PathWhat it holds
~/.claude/settings.json
User settings, permissions and hooks
.claude/settings.json
Project settings, shared in git
.claude/settings.local.json
Personal project settings, gitignored
/Library/Application Support/ClaudeCode/managed-settings.json
Admin-managed policy on macOS
~/.claude.json
Account state, trust decisions, local and user MCP servers
.mcp.json
Project MCP servers
~/.claude/projects/
Session transcripts and auto memory
~/.claude/history.jsonl
Prompt history
~/.claude/file-history/
Pre-edit file snapshots for checkpoint restore
CLAUDE.md
Project instructions

Codex

PathWhat it holds
~/.codex/config.toml
User config shared by CLI, IDE extension and app
.codex/config.toml
Project config, loaded only for a trusted project
/etc/codex/config.toml
System config on Unix
/etc/codex/requirements.toml
Admin constraints users cannot override
/etc/codex/managed_config.toml
Legacy managed defaults reapplied at startup
~/.codex/AGENTS.md
Global instructions; AGENTS.override.md is read first
~/.codex/hooks.json
User hooks; project hooks in .codex/hooks.json, system in /etc/codex/hooks.json
~/.codex/history.jsonl
Prompt history, size capped by history.max_bytes
~/.codex/sessions/
Per-session rollout JSONL files by date
~/.codex/archived_sessions/
Sessions moved by archive

Security advisories

Public advisories and well-documented reported issues since 2025. A longer list can mean more people are looking, so read each one rather than the count.

Claude Code

8Listed here
8With a CVE or GHSA id
8Name a fix

Codex

1Listed here
1With a CVE or GHSA id
1Name a fix

Both, newest first

  1. Claude CodeGHSA-5xjx-9qx6-jcrvHigh

    A race in the Edit tool's path check let a process in the Bash sandbox swap a parent directory for a symlink, so the unsandboxed Edit tool could overwrite a file outside the workspace on macOS. CVE-2026-88968.

    Fixed in 2.1.251
  2. Claude CodeGHSA-4p2j-qj3c-6x84High

    Uncontrolled search path let a malicious git executable run arbitrary code. Affects Claude Desktop, listed in the Claude Code repo. CVE-2026-88066.

    Fixed in Claude Desktop 1.8089.0
  3. Claude CodeGHSA-pq7j-f95f-qfcvHigh

    A plugin commit SHA pin could be bypassed, allowing installation of attacker-controlled code. CVE-2026-86063.

    Fixed in 2.1.179
  4. Claude CodeGHSA-5j29-h97v-84chHigh

    Arbitrary file write through write-time symlink following (a time-of-check to time-of-use race). CVE-2026-103435.

    Fixed in 2.1.129
  5. Claude CodeGHSA-gfvf-j8jh-jxxwLow

    Managed settings were not applied when a stored API key was preferred over enterprise sign-in. CVE-2026-103012.

    Fixed in 2.1.260
  6. Claude CodeGHSA-v234-4jrq-mgg6High

    Claude Desktop on macOS: opening a malicious file from a Cowork folder could run commands on the host. Listed in the Claude Code repo.

    Fixed in Claude Desktop 1.15962.0
  7. Claude CodeGHSA-7835-87q9-rgvvHigh

    Git worktree path confusion allowed a sandbox escape and unsandboxed code execution. CVE-2026-55607.

    Fixed in 2.1.163
  8. Claude CodeGHSA-4vp2-6q8c-pvq2Medium

    An insecure temporary file in the /copy command allowed response disclosure and a symlink-based file write. CVE-2026-46406.

    Fixed in 2.1.128
  9. CodexGHSA-w5fx-fh39-j5rwHigh

    CVE-2025-59532. A sandbox configuration bug let a model-generated working directory become the writable root, so writes could land outside the folder where the session started. The network restriction was not affected.

    Fixed in CLI 0.39.0, VS Code extension 0.4.12

Strengths and things to watch

Claude Code

What it does well

  • Permission rules and hooks are enforced by Claude Code, not by the model, and deny rules apply in every mode.
  • Managed settings rank above user, project and command-line values, and admins can disable bypass and auto modes.
  • An OS-level sandbox with a domain allowlist and credential and filesystem controls is available, built on an open source runtime.
  • PreToolUse hooks can block a call before it runs, and onFailure: "block" makes a failed hook fail closed.
  • Transcripts and pre-edit file snapshots are kept locally, with claude purge and cleanupPeriodDays to control retention.

What to watch for

  • The sandbox is off by default and covers Bash, PowerShell and Monitor commands only. Edit, Read, Write, WebFetch, MCP servers and hooks run outside it.
  • Sandboxed reads cover most of the machine by default, including ~/.ssh, unless denyRead or similar settings narrow them.
  • A failed sandboxed command can be retried unsandboxed with dangerouslyDisableSandbox unless allowUnsandboxedCommands is false.
  • Bash rules match command text, so Bash(rm *) does not match /bin/rm or bash -c 'rm ...'. The docs point to the sandbox for stronger enforcement.
  • Transcripts are plaintext, so a value read from a .env file or printed by a command is written to ~/.claude/projects/.

Codex

What it does well

  • The sandbox is on by default and uses OS mechanisms: Seatbelt on macOS, bwrap and seccomp on Linux.
  • Network is off by default and is a separate setting from approvals.
  • .git, .codex, .agents and .aws stay read-only inside writable roots.
  • Admins can enforce approval policies, sandbox modes, hooks, MCP allowlists and network domains with requirements.toml, including through macOS MDM.
  • Project config, hooks and rules load only after you trust the project.

What to watch for

  • --yolo removes both the sandbox and approvals in one flag.
  • Domain rules restrict traffic only when the network_proxy feature is on.
  • The docs describe hooks as a guardrail, and hosted tools such as web search do not pass through them.
  • The docs checked today do not describe the ~/.codex/sessions/ folder or its file format.
  • approval_policy = "untrusted" is retired and can stop the client from starting if left in config.

Which should you pick

Pick Claude Code if

  • You want allow, ask and deny rules per tool and path, such as Bash(npm run test *) or Read(./.env).
  • You want a classifier to approve routine actions so you are asked less often.
  • You will turn the sandbox on and want a list of allowed domains for its network proxy.
  • Your team already pays for Claude Pro, Max, Ultra, Team or Enterprise.

Pick Codex if

  • You want a sandbox with no network from the first run, with no setup.
  • You want to read the source: the Codex CLI is Apache-2.0.
  • You run unattended jobs and want no prompts with the sandbox still in place.
  • Your team already pays for ChatGPT, or you want to pay API rates with a key.

Running both

Plenty of teams run both. Codex reads AGENTS.md, and Claude Code reads CLAUDE.md and can read AGENTS.md in its place, so you can keep one set of project instructions. Instructions guide the model, and neither agent enforces them. The enforced parts are each agent's own rules, sandbox and hooks, so set those up in both.

Where Excellent fits

What Excellent doesClaude CodeCodex
Reads its session logs (free scan)
Yes
Yes
Key finder reads its key files
Yes
Yes
Live check before risky actions (Pro)
Yes, in its own hook settings
Yes, in its own hook settings
Before a force push to main
Claude Code asks you first
Refuses and tells Codex to ask you
Excellent's sandbox (Pro)
Yes, in its own sandbox settings
Yes, in its own sandbox settings
Rule sharing
Yes
Yes

Excellent reads the session logs of both Claude Code and Codex on your Mac. The free scan shows what each did: your email in request commands or form inputs, keys sitting in logs, secrets files read, history overwritten, checks skipped. Each finding says which agent and where.

With Pro, Excellent adds its live check to each one's own hook settings, after listing what it will change. The same rules apply to both: it blocks your email on its way to a website, an API key typed into a command, and deleting a folder you marked never-delete.

Claude Code and Codex are the two agents Excellent's sandbox and rule sharing work with. It can write one sandbox from your rules into both agents' own settings, and copy the rules you wrote for one into the file the other reads.

Questions

Is Codex safer than Claude Code?

Codex starts stricter: its sandbox is on and network is off from the first run. Claude Code can be as strict once you turn its sandbox on and add deny rules, and its rules are finer-grained. Which is safer depends on how you set each one up.

Does Claude Code have a sandbox?

Yes. It uses Seatbelt on macOS and bubblewrap on Linux and WSL2. It is off by default, and you turn it on with /sandbox or sandbox.enabled. It covers shell commands only.

Can Codex reach the internet?

Not from inside its sandbox by default. You turn network access on with network_access = true under [sandbox_workspace_write], and domain rules apply only when the network proxy feature is on.

Which one is open source?

The Codex CLI is open source under Apache-2.0. Claude Code is not: its repository holds issues, plugins and examples under Anthropic's commercial terms. Claude Code's sandbox runtime is a separate open source package.

Where do they keep session history?

Claude Code writes plaintext JSONL transcripts to ~/.claude/projects/ and deletes them after 30 days by default. Codex keeps its state under ~/.codex, including history.jsonl and session files under ~/.codex/sessions/.

Read more

Sources

More agent comparisons

All comparisons →

Check what Claude Code and Codex did on your Mac

Get the Mac app