NewThe Mac app is out for Apple SiliconGet it →
Fenzi
blog, codex

Is Codex safe?

Safe enough with its defaults, in a folder you trust. Codex runs commands in a sandbox that keeps writes inside the project and the network off, and OpenAI publishes and fixes the sandbox flaws it finds. Turn that sandbox off, or trust a folder you have not read, and Codex runs with your account, your keys and your network.

By Boris Kwemo, , five-minute read

This is about the Codex CLI, the agent that runs in your terminal. Every fact below comes from the Codex source on GitHub, read on 25 October 2026, and from the one security advisory listed in that repository.

What Codex does by default

Codex permissions come down to two controls: a sandbox that decides what a command can touch, and an approval policy that decides when Codex stops to ask you. The defaults depend on whether you have trusted the folder.

A folder you have not decided on gets the read-only sandbox. A folder you trusted gets workspace-write, according to the configuration loader, and the on-request approval policy, where the protocol definitions say the model decides when to ask you.

In workspace-write, commands write to the project and temp folders only, and network access is restricted unless you turn it on: that is the default in the permission types. Inside the project, .git and .codex stay read-only, so a command cannot rewrite a hook or Codex's own settings.

Trusting a folder is a real decision

The first time you open a folder, Codex asks whether you trust it. The prompt in the terminal interface says why that matters.

Folder settings can run code automatically, even without a model request.Codex CLI source, trust_directory.rs

Until you say yes, Codex leaves a folder's own config, hooks and exec policies switched off; the config loader names those three. A repository you cloned this morning can carry a .codex folder, so read it before you trust it.

What leaves your machine

The model does not run on your laptop. Signed in with ChatGPT, Codex talks to chatgpt.com/backend-api/codex; with an API key, to api.openai.com/v1, as the model provider code shows. What goes there is your instructions, the files Codex reads and the output of the commands it runs. What OpenAI keeps is set by the terms of your plan or API account, not by the CLI.

Your sign-in is stored in auth.json in Codex's home folder unless you choose otherwise. The credential store options also offer the system keyring, keyring with a file fallback, or memory only for one session.

The sandbox has had bugs, and they get published

OpenAI's one published advisory for Codex, GHSA-w5fx-fh39-j5rw from September 2025, rated high, let a working directory chosen by the model become the sandbox's writable root. Writes and commands could then land outside the folder you started in. The network restriction was not affected, and version 0.39.0 fixed it.

That is how a sandbox should fail in public: a named bug, a version range and a fix. It also means the version you run is part of your boundary, so update Codex the way you update a browser.

"Codex is sandboxed, so it cannot read my keys."

Revision 1: on Linux the sandbox starts from a read-only view of the whole disk, so commands can read what you can.

Where the risk actually sits

The Linux sandbox notes say the filesystem is read-only by default, which means readable. Your ~/.ssh, your cloud credentials and Codex's own auth.json can be read by a sandboxed command unless a permissions profile masks them. With the network off, a read has nowhere to go except into the conversation the model sees.

Most real exposure comes from settings people change. danger-full-access and the yolo flag remove the sandbox entirely; our notes on dangerously skip permissions in Codex cover what that flag turns off. Turning on network access in workspace-write gives every command a way out. Trusting every folder by habit lets any repository's settings run.

Under all of it sits text the agent reads and follows: a README that says to curl a script, an issue comment, a dependency's install step. Our list of AI agent security risks covers the wrong file, the wrong host and the instruction the agent should not have followed. The same reasoning answers whether Claude Code is safe.

How to run it more safely

Keep the sandbox. Stay in workspace-write. If the questions slow you down, drop the questions before the sandbox.

Keep the network off unless the task needs it, and turn it on for that task, not in your global config.

Mask what it does not need. A permissions profile can mark paths such as **/*.env as none, so the sandbox hides them.

Move the sign-in. Set cli_auth_credentials_store to keyring so the token is not a plain file in your home folder.

Trust folders you have read. Open a fresh clone untrusted, read its .codex folder, then decide.

Set the floor for a team. Administrators can list allowed_sandbox_modes and allowed_approval_policies in /etc/codex/requirements.toml or through device management, per the config loader. Those lists are the same few questions that agentic AI security comes down to for us: directories, hosts, keys, and a person who approves more.

A side note on how we do it

We build Fenzi, which starts Codex inside an OpenShell sandbox with a copy of the project, a short host list and a placeholder instead of the real key; the Codex sandbox notes say how Codex's own sandbox behaves there. It is one way to put a boundary outside the agent, and a container or a virtual machine can do it too.

So, is Codex safe?

With its defaults, in a folder you trusted on purpose, Codex keeps its writes in the project and its commands off the network, and its known sandbox bug was published and fixed. What it does not do is hide your files from a command that reads them. Keep the sandbox, keep it updated, and read the Codex security policy, which points to OpenAI's guide to its sandbox, approvals and network controls.

One line to install.
One command to run.

curl -fsSL https://fenzi.dev/install.sh | sh

Then fenzi run claude. Ask it to open a pull request with the GitHub API, and watch the deny land.