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.
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 -pand Agent SDK runs start in Manual, which asks before edits, shell commands and network access. - Sandbox
- Yes, off by default. Turn on with
/sandboxorsandbox.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-writesandbox withon-requestapprovals, so sandboxed commands run and leaving the sandbox asks. Folders without version control startread-only. - Sandbox
- Yes, on by default. macOS uses Seatbelt through
sandbox-exec, Linux usesbwrapand seccomp, Windows has its own sandbox. It covers spawned commands, and.git,.agents,.codexand.awsstay read-only inside writable roots. - Public advisories
- 1 with a CVE or GHSA id, 1 rated critical or high
On this page
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.
/sandbox3●Yesworkspace-write in a repo, read-only elsewhere26network_access = true234deny arrays, checked first4◐PartlyAdmin command rules can prompt or forbid27requirements.toml, also by MDM7The basics
| Question | Claude Code | Codex |
|---|---|---|
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 | |
Platforms | macOS, Linux, WSL and native Windows. Installs with a script, Homebrew, WinGet, apt, dnf or apk.1 | |
Open source | Yes, Apache-2.0 (the CLI, in the openai/codex repository). Latest release at verification: rust-v0.173.0.8 | |
Models | ||
Pricing | 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
| Question | Claude Code | Codex |
|---|---|---|
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 | |
Network in commands | ||
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 | |
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 | |
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 | 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. 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
- planAsks for some actions
- default (Manual)Asks before each action
- dontAskNever asks
- acceptEditsAsks for some actions
- autoAsks for some actionsStarts here
- bypassPermissionsNever asks
Codex
- read-onlyAsks for some actions
- workspace-write with on-request (Auto)Asks for some actionsStarts here
- granular approvalsAsks for some actions
- neverNever asks
- danger-full-accessAsks for some actions
- yoloNever asks
Claude Code modes in detail
| Mode | How to turn it on | Asks you | What 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
| Mode | How to turn it on | Asks you | What 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
| Path | What 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
| Path | What 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
Codex
Both, newest first
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 in2.1.251Uncontrolled search path let a malicious git executable run arbitrary code. Affects Claude Desktop, listed in the Claude Code repo. CVE-2026-88066.
Fixed inClaude Desktop 1.8089.0A plugin commit SHA pin could be bypassed, allowing installation of attacker-controlled code. CVE-2026-86063.
Fixed in2.1.179Arbitrary file write through write-time symlink following (a time-of-check to time-of-use race). CVE-2026-103435.
Fixed in2.1.129Managed settings were not applied when a stored API key was preferred over enterprise sign-in. CVE-2026-103012.
Fixed in2.1.260Claude Desktop on macOS: opening a malicious file from a Cowork folder could run commands on the host. Listed in the Claude Code repo.
Fixed inClaude Desktop 1.15962.0Git worktree path confusion allowed a sandbox escape and unsandboxed code execution. CVE-2026-55607.
Fixed in2.1.163An insecure temporary file in the
Fixed in/copycommand allowed response disclosure and a symlink-based file write. CVE-2026-46406.2.1.128CVE-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 inCLI 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.
PreToolUsehooks can block a call before it runs, andonFailure: "block"makes a failed hook fail closed.- Transcripts and pre-edit file snapshots are kept locally, with
claude purgeandcleanupPeriodDaysto 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, unlessdenyReador similar settings narrow them. - A failed sandboxed command can be retried unsandboxed with
dangerouslyDisableSandboxunlessallowUnsandboxedCommandsisfalse. - Bash rules match command text, so
Bash(rm *)does not match/bin/rmorbash -c 'rm ...'. The docs point to the sandbox for stronger enforcement. - Transcripts are plaintext, so a value read from a
.envfile 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,
bwrapand seccomp on Linux. - Network is off by default and is a separate setting from approvals.
.git,.codex,.agentsand.awsstay 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
--yoloremoves both the sandbox and approvals in one flag.- Domain rules restrict traffic only when the
network_proxyfeature 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 *)orRead(./.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 does | Claude Code | Codex |
|---|---|---|
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
- Claude Code: safety and how to run it
- Codex: safety and how to run it
- All agents Excellent works with
Sources
Claude Code
- Claude Code docs: Overview
- Claude Code docs: Permission modes
- Claude Code docs: Sandboxing
- Claude Code docs: Permissions
- Claude Code docs: Hooks
- Claude Code docs: Explore the .claude directory
- Claude Code docs: MCP
- Claude Code docs: Deploy managed settings
- anthropics/claude-code: LICENSE.md
- Claude pricing
- anthropics/claude-code: Security advisories
Codex
- Codex docs: Pricing and plans
- Codex docs: Agent approvals and security
- Codex docs: Permissions
- Codex docs: CLI reference
- Codex docs: Changelog
- Codex docs: Sandboxing
- Codex docs: Managed configuration
- openai/codex on GitHub
- Codex docs: Config basics
- Codex docs: Hooks
- Codex docs: AGENTS.md
- Codex docs: MCP
- Codex docs: Advanced config
- GitHub Security Advisory GHSA-w5fx-fh39-j5rw




