Codex vs Cursor: sandbox, approvals and security compared
OpenAI's Codex and Cursor side by side on sandboxing, approval and run modes, network access, hooks, admin policy and public advisories, with a source for every fact.
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
Cursor
- Made by
- Cursor, now part of Grok Build (SpaceX)
- Out of the box
- Auto-review is the recommended mode. Allowlisted calls run, other shell commands run in the sandbox when possible, and the rest go to an LLM classifier. The security page says terminal commands and all MCP tools need approval by default.
- Sandbox
- Yes, for terminal commands in Auto-review and optionally in Allowlist mode. macOS uses Seatbelt through
sandbox-exec. Run Everything has no sandbox. Commands that need more access leave the sandbox after a prompt or classifier review. Docs say it is not a hard security boundary. - Public advisories
- 8 with a CVE or GHSA id, 8 rated critical or high
On this page
Short answer
Codex and Cursor both run agent commands in a Seatbelt sandbox on macOS with no network by default, so their safe defaults are closer than most pairs. They differ in who decides when a command leaves the sandbox. Codex asks you. Cursor's Auto-review mode can let an AI classifier decide, or ask you. Codex is an open source CLI with an IDE extension and a desktop app, for OpenAI models. Cursor is an editor with models from several providers, and on November 30, 2026 it became the desktop app of Grok Build.
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.
workspace-write in a repo, read-only elsewhere26●YesIn Auto-review, the recommended mode17network_access = true234●YesBlocked in the sandbox until a host list opens it17requirements.toml, also by MDM7●YesEnterprise dashboard and MDM12456The basics
| Question | Codex | Cursor |
|---|---|---|
Runs in | ||
Platforms | ||
Open source | Yes, Apache-2.0 (the CLI, in the openai/codex repository). Latest release at verification: rust-v0.173.0.8 | Not documented as open source. The docs reviewed state no source license for the app or the cursor-agent CLI. |
Models | Several providers through one picker: Grok 4.7, GPT-5.6 Sol, Claude Fable 5.2 and Opus 5.5, Gemini 3.1 Pro, Composer 2.5, plus an Auto router.13 | |
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 | Legacy plans: Hobby free, Pro $20 a month, Pro+ $60, Ultra $200, Teams $40 or $120 a seat. Newer plans are sold through The X Subscription, from free to $200 a month.12 |
Safety controls
| Question | Codex | Cursor |
|---|---|---|
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.2 | |
Sandbox | ||
Network in commands | ||
Turning approvals off | ||
Permission rules | ||
Hooks before a tool runs | 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 | Yes. 21 events in hooks.json. Six permission events, including beforeShellExecution, beforeMCPExecution and preToolUse, can allow or deny. Exit code 2 blocks. Other failures fail open unless failClosed is true.2 |
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 | .cursor/rules/*.mdc (with frontmatter) and AGENTS.md in the project root and subfolders. User and team rules are set in the app and the dashboard. CLAUDE.md is not listed on the rules page.8 |
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 | 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 | 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
Leaving the sandbox
With Codex's Auto preset, commands run in the sandbox and you are asked when one needs to leave it. In Cursor's Auto-review mode, allowlisted calls run, other shell commands run in the sandbox where they can, and the rest go to an AI classifier or a prompt. Cursor's docs say Auto-review is not a security boundary.
Turning it off
Codex's --yolo removes the sandbox and the approvals together, and --ask-for-approval never drops only the prompts. Cursor's Run Everything mode, set in Settings, turns off both the sandbox and the classifier.
Protected paths
Inside its writable folders Codex keeps .git, .codex, .agents and .aws read-only. Cursor's sandbox write-protects .git/hooks, .git/config, .vscode and .cursorignore. Cursor allows reads outside the workspace by default.
Hooks and admin policy
Both have a hook that runs before a tool call and can deny it. Cursor's fail open on a crash unless failClosed is set, and Codex's docs call hooks a guardrail. Codex admins enforce settings with requirements.toml, pushed by file or MDM. Cursor's Enterprise dashboard enforces run modes, network rules and MCP allowlists, with audit logs to a SIEM.
Cursor is now part of Grok Build
Cursor joined SpaceX in August 2026 and became the Grok Build desktop app on November 30. Its docs moved to docs.grok.com, and new plans are sold through The X Subscription.
Public advisories
Codex's repository lists one advisory, from September 2025, fixed in CLI 0.39.0. Cursor's lists eight from November 2025 to July 2026, two rated critical, most of them sandbox escapes through paths, symlinks and Git hooks. Cursor's sandbox has had more researchers testing it, and keeping it updated matters.
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.
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
Cursor
- AllowlistAsks before each action
- Auto-reviewAsks for some actionsStarts here
- Run EverythingNever asks
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. |
Cursor modes in detail
| Mode | How to turn it on | Asks you | What it allows |
|---|---|---|---|
Allowlist | Settings > Agents > Approvals & Execution, or permissions.json | Before each action | Only actions on your allowlist run without approval. Supported shell commands can run in the sandbox when sandboxing is on. |
Auto-review | Settings > Agents > Approvals & Execution | For some actions | Allowlisted calls run. Other shell commands run in the sandbox when possible. A classifier reviews calls that cannot use the sandbox. |
Run Everything | Settings > Agents > Approvals & Execution | Never | Every tool call runs automatically with no sandbox and no classifier. |
Where their settings live
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 |
Cursor
| Path | What it holds |
|---|---|
~/.cursor/permissions.json | User allowlists and Auto-review instructions |
.cursor/permissions.json | Project allowlists, meant to be committed |
~/.cursor/sandbox.json | User sandbox network and path rules |
.cursor/sandbox.json | Project sandbox rules, win over the user file |
~/.cursor/hooks.json | User hooks |
.cursor/hooks.json | Project hooks |
/Library/Application Support/Cursor/hooks.json | Enterprise hooks on macOS |
~/.cursor/mcp.json | User MCP servers |
.cursor/rules/ | Project rules in .mdc files |
.cursorignore | Files hidden from the agent |
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.
Codex
Cursor
Both, newest first
On macOS, an agent in Auto-Run Sandbox mode could swap a Python virtual environment's interpreter for a wrapper. The Python extension then ran it outside the sandbox with the user's privileges.
Fixed in3.1.2On macOS with Docker Desktop and the Dev Containers CLI, an agent in Auto-Run Sandbox mode could start a privileged container and reach the home directory without a prompt. The advisory lists no patched version.
No fixed version publishedWeb content loaded in a browser enabled Cloud Agent session could reach a local agent endpoint with no authentication. That allowed code execution in the sandbox and exposed repo files, environment variables and GitHub App tokens.
Fixed inServer side fix on 2026-03-31If the sandbox could not resolve a write target, it fell back to the in-workspace path and skipped approval. A symlink pointing outside the workspace could then lead to unsandboxed code execution.
Fixed in3.0The default sandbox allowed writes to a command's working directory, and the agent could set that parameter to a path outside the workspace. That allowed overwriting the
Fixed incursorsandboxhelper and unsandboxed code execution.3.0Cursor Desktop ran hook commands from a workspace's
Fixed in.claude/settings.local.jsonwithout specific approval. A malicious workspace or agent-created file could run local commands at the end of a turn.3.0.0A sandboxed agent could write to unprotected
Fixed in.gitsettings and plant Git hooks that later ran code outside the sandbox, for example after a prompt injection.2.5A validation flaw in MCP server install deep-links let a crafted link skip the security warning and hide the commands to be run. Accepting a dialog that looked like a Playwright install ran the attacker's commands.
Fixed in2.0CVE-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
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.
Cursor
What it does well
- Auto-review runs shell commands in a Seatbelt sandbox on macOS where it can, with a classifier for the rest.
- Sandbox network access is blocked by default and opened by a host allowlist you can edit per project.
- Protected paths such as
.git/hooks,.git/config,.vscodeand.cursorignoreare write protected inside the sandbox. - Hooks cover shell, MCP and file reads, can deny, and have a
failClosedoption. Enterprise hooks live in a system path. - Admins can enforce run modes, sandbox network rules, MCP allowlists and Privacy Mode from the dashboard, and local files cannot weaken them.
What to watch for
- The docs say Auto-review is not a security boundary and run modes are best effort guardrails.
- Commands that cannot use the sandbox, or that fail in it, can run outside it after a classifier check or a prompt.
- Run Everything turns off the sandbox and the classifier. Read access outside the workspace is allowed by default.
- Most 2026 advisories are sandbox escapes through paths, symlinks, Git hooks and helper processes, so keep the app updated.
- Hooks fail open on a crash or timeout unless
failClosedis set. The editor and the legacycursor-agentCLI differ in sandbox config, and the CLI's default sandbox state is not documented.
Which should you pick
Pick Codex if
- You want to be asked, by a person, whenever a command leaves the sandbox.
- You want an open source CLI (Apache-2.0) you can read and run in CI.
- You want OpenAI models and already pay for ChatGPT.
- You want
.awsand.gitread-only inside the folders the agent can write.
Pick Cursor if
- You want the agent inside an editor, with models from several providers.
- You want fewer prompts, with a classifier handling routine commands.
- Your company wants run modes and MCP allowlists set in a dashboard, with audit logs.
- You already use Cursor or Grok Build.
Running both
Both read AGENTS.md, so one file of project instructions reaches both. Their enforced settings are separate: Codex's in config.toml and requirements.toml, Cursor's in permissions.json, sandbox.json and hooks.json. Set the same limits in each.
Where Excellent fits
| What Excellent does | Codex | Cursor |
|---|---|---|
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 | Refuses and tells Codex to ask you | Refuses and tells Cursor to ask you |
Excellent's sandbox (Pro) | Yes, in its own sandbox settings | No |
Rule sharing | Yes | No |
Excellent reads the session logs of both Codex and Cursor 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.
Excellent's sandbox and rule sharing are for Claude Code and Codex only, so here they apply to Codex. The check reads what a command says, so it isn't a wall around your Mac.
Questions
Is Codex or Cursor safer?
Both sandbox commands with no network by default on macOS. Codex asks a person before a command leaves the sandbox, while Cursor's Auto-review can let a classifier decide. If you want a person to approve every escape, Codex's default does that.
Do both run on Windows?
Codex's CLI has a sandbox on macOS, Linux and Windows, and its desktop app runs on macOS and Windows. Cursor's desktop app runs on macOS, Linux and Windows, but its docs list no Windows sandbox.
Which is open source?
The Codex CLI, under Apache-2.0. The docs we read state no source license for Cursor.
Is Cursor still called Cursor?
Yes, as the Grok Build desktop app. SpaceX brought its coding products under the Grok Build brand on November 30, 2026.
Read more
Sources
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
Cursor
- Cursor docs (now Grok Build docs): Run modes, sandboxing and auto-review
- Cursor docs: Agents Window hooks
- Cursor docs: Terminal UI permissions
- Cursor docs: Model and integration management (MCP allowlists)
- Cursor docs: Enterprise
- Cursor docs: Security and privacy hardening
- Cursor docs: Agent security
- Cursor docs: Rules
- Cursor docs: MCP
- Cursor docs: Customize overview
- Cursor docs: Privacy and data
- Cursor docs: Legacy plans
- cursor.com homepage
- Announcement: Cursor is now Grok Build
- GitHub Security Advisories for cursor/cursor




