Get the free coreGet core

Is Codex safe? How OpenAI Codex sandboxes your Mac

Updated 6 min readSection 03 / Is it safe?
SHORT ANSWER

Is Codex safe? For everyday work, yes, in its default setup. The agent runs with network access off, inside an OS-enforced sandbox, plus an approval policy that says when it must ask you. On a Mac that sandbox is Apple's built-in Seatbelt. The risky choices are yours: the bypass flag, live web search and MCP servers you did not check. OpenAI's docs say to avoid the bypass flag unless you are inside a dedicated sandbox VM.

Before you install an agent that runs commands, it is fair to ask what it can touch. This page explains how Codex CLI limits itself on a Mac, what it can read and write, where it can go wrong and five settings worth keeping. For the same question about other tools, see Claude Code, Cursor and Copilot.

01How Codex limits itself on your Mac

Two separate controls work together. The sandbox decides what a command is technically able to do. The approval policy decides when Codex must stop and ask you.

A sandbox here means an operating system feature that restricts what a program can touch, whatever the program wants. Seatbelt is the macOS version. Because spawned commands inherit it, git, package managers and test runners stay inside the same boundaries. The docs name three sandbox modes.

Sandbox modeWhat it allows
read-onlyInspect files, but not edit or run commands without approval.
workspace-writeThe default low-friction mode. Writes stay in the workspace and network stays off unless you enable it.
danger-full-accessRuns without sandbox restrictions, which removes the filesystem and network boundaries.

The approval policy has two settings you will meet most.

Approval policyWhat it does
on-requestWorks inside the sandbox and asks when it needs to go beyond it.
neverThe agent does not stop for approval prompts. It works with every sandbox mode.

The Auto preset combines --sandbox workspace-write --ask-for-approval on-request. The combination to watch is a loose sandbox plus never, because nothing then stands between a command and your files.

02Does Codex access your files?

Yes, inside the workspace. In the Auto preset it can read files, make edits and run commands in the working directory automatically. It asks for approval to edit files outside the workspace or to run commands that need network access.

Some paths are shielded even inside the workspace. In workspace-write mode, .git is protected as read-only in writable roots, and so is the .codex directory.

Network stays off in workspace-write unless you enable it in your configuration, so check that setting before you assume the network is closed. Anything that needs the network asks you first in the Auto preset.

To look around a repository you do not trust yet, switch to read-only with the /permissions command.

03Can you trust Codex?

Trust the boundaries more than the agent's judgment. OpenAI documents what the sandbox limits and tells you where caution is needed. The docs say to use caution when enabling network access or web search. Destructive app or MCP tool calls always require approval when the tool advertises a destructive annotation.

There is also an optional reviewer. Auto-review reviews eligible approval requests instead of showing them to you, and it uses extra model calls that can add to usage. That is a convenience with a cost, not a replacement for a boundary. If you want it, the docs enable it with a flag combination that keeps the same sandbox:

--sandbox workspace-write --ask-for-approval on-request -c approvals_reviewer=auto_review

The sandbox and approval policy come first, and the reviewer only changes who answers the approval prompts.

Trust also applies to the code it writes. A 2022 Stanford study tested an older model, OpenAI's codex-davinci-002, not today's Codex CLI. Participants with that assistant wrote significantly less secure code, and those who trusted it less and engaged more with their prompts produced fewer vulnerabilities. The lesson carries over to any agent: review what it writes, the same way you would review a pull request from a colleague you do not know yet.

04Is it okay to download Codex?

Yes. Codex CLI is a coding agent from OpenAI that runs locally on your computer. On a Mac, the Homebrew command from the README is the least surprising route:

brew install --cask codex

The README also lists an npm install, npm install -g @openai/codex, and a script that you pipe into the shell. A piped script runs whatever the address serves at that moment, so a named package is easier to trust. After install, run codex and select Sign in with ChatGPT. An API key also works with extra setup.

05Where Codex can go wrong

The documented risks are about what you switch on, not about the defaults.

The --full-auto flag is no longer supported in codex exec. Use --sandbox workspace-write instead. More on the old flag: Codex full-auto.

06Five settings that keep Codex safe

risk-check · 2 stepsClaude CodeCursorCodexGemini CLI / Asks before each actionAuto-accepts editsSkips all permissions, on my main MacInside a sandbox, container or VM
1Which agent
2How it runs
LOWAsks before each action: You see each command before it runs. Read the prompt before you press y, and keep the project in git.
MEDIUMAuto-accepts edits: File edits go through without a question. Commit before you start so you can roll back, and keep secrets out of the project folder.
HIGHSkips all permissions, on my main Mac: Nothing asks you before a command runs. Run it only in a container or VM with no secrets, not on your main Mac.
LOWInside a sandbox, container or VM: Low if nothing secret is inside. Check that your keys, ~/.ssh and cloud credentials are not mounted into the container or VM.
Get the free coreQuiet until it matters. You decide.
  1. Stay in the Auto preset. Use --sandbox workspace-write --ask-for-approval on-request for low-friction local work.
  2. Keep network off and web search cached. Cached web search reduces exposure to prompt injection, and you should treat web results as untrusted. OpenAI's advice for internet access is to keep it as limited as possible and point Codex only at trusted resources.
  3. Leave the bypass flag for a dedicated VM. On your Mac, stay inside the sandbox. Danger-full-access is for a controlled environment such as an isolated CI runner or container.
  4. Use read-only for unfamiliar code. Run /permissions and pick it. For non-interactive CI, the read-only preset is --sandbox read-only --ask-for-approval never.
  5. Check MCP servers before connecting them. A project can define its own. Read the config of a cloned repo first.

Sandbox details are on Codex sandbox.

07So, is Codex safe?

Is Codex safe for everyday work? Yes, in the default sandbox with network off. It stops being safe when you remove the sandbox and the prompts together, or when you let it browse live pages and add MCP servers without a look. Keep it in workspace-write, use read-only for code you do not know yet and commit before long runs.

Codex's sandbox and approvals decide what it may do; they don't show what actually ran on your Mac. Artificial Immunity's free, open-source core watches Codex sessions, package scripts and every program start, and reports what it finds without blocking anything.

Next, read how to run agents safely, the wider AI agent security view, or return to the home page.

FAQ

Is Codex safe?

For everyday work, yes, in its defaults. By default the agent runs with network access off, inside an OS-enforced sandbox, plus an approval policy. The risk rises when you use the bypass flag, which OpenAI's docs say to avoid outside a dedicated sandbox VM.

Can I trust Codex?

Trust the sandbox, not the agent's judgment. The sandbox limits what a command can touch, and commands such as git and test runners inherit its boundaries. Treat web results as untrusted.

Does Codex access your files?

Yes, inside the workspace. In the Auto preset it can read files, make edits and run commands in the working directory automatically, and it asks before editing outside the workspace. Read-only mode can inspect files but not edit or run commands without approval.

Is it okay to download Codex?

Yes. Codex CLI is a coding agent from OpenAI that runs locally on your computer. You can install it with Homebrew using brew install --cask codex, or with npm.

Is Codex better than ChatGPT?

Neither is safer by name, because they do different jobs. Codex CLI is a coding agent that runs locally on your computer, and you can sign in with your ChatGPT account when you first run it. For safety, what matters is the sandbox and approval policy you choose.

What does the Codex --yolo flag do?

It is an alias for --dangerously-bypass-approvals-and-sandbox: no sandbox and no approvals. OpenAI's docs say to avoid it unless you are inside a dedicated sandbox VM.

Sources

  1. OpenAI Codex docs, approvals and security
  2. OpenAI Codex docs, sandboxing
  3. OpenAI Codex docs, CLI reference
  4. OpenAI Codex docs, non-interactive mode
  5. OpenAI Codex docs, internet access
  6. Codex CLI README
  7. Stanford study, Do users write more insecure code with AI assistants
  8. Wiz, s1ngularity supply-chain attack
  9. Artificial Immunity
Running Codex on your Mac? Artificial Immunity watches the Mac where your agents work.Get the free core