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

How do Codex permissions work?

Codex combines two settings: a sandbox that decides what a command can touch, and an approval policy that decides when Codex stops to ask you. Three presets pair them, Read Only, Default and Full Access, and rules files can allow, prompt or forbid a command by its first words. A command that a rule allows also runs outside the sandbox, unless the permission profile hides some files from reads.

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 again on 15 November 2026. The pieces are a preset, an approval policy, rules files, permission profiles and an optional reviewer.

Three presets, each a pair

The approval presets in the source each pair an approval policy with a permission profile. Read Only reads the workspace and asks before it edits a file or goes online. Default reads and edits the workspace and runs commands, and asks before it reaches the internet or edits other files.

Full Access edits outside the workspace and reaches the internet without asking. It pairs the never approval policy with no sandbox at all, the same pair as the yolo flag in our notes on dangerously skip permissions in Codex.

People search for Codex auto mode. In the source, auto is the internal id of the Default preset, so auto mode is the starting point, not an extra level of freedom.

When Codex asks

The approval policy has four values in the protocol definitions. on-request is the default, and the model decides when to ask you. never sends a failed command straight back to the model and never to you.

untrusted is marked as internal, for projects marked untrusted: every command needs approval unless a rule allows it. granular takes one switch per kind of request: sandbox escalations, rule prompts, skill scripts, permission requests and MCP prompts. A switch set to false rejects those requests automatically instead of showing them to you.

That makes the policy a list of situations, not tools. Claude Code permissions name a tool and a pattern instead, so a rule written for one agent does not carry over to the other.

Rules files decide by the first words

Codex also reads rules, which its execpolicy notes describe. A prefix_rule lists the first words of a command, such as ["git", "push"], with a decision: allow, prompt or forbidden. When several rules match, the strictest decision wins.

Rules live in *.rules files in a rules folder beside each config layer, read from lowest precedence to highest by the exec policy loader. A project's rules load only once you trust the project. An administrator's rules are merged on top.

The approval prompt writes rules too. Pick "Yes, and don't ask again for commands that start with" a prefix, in the terminal interface, and Codex appends an allow rule to rules/default.rules in its home folder. It stays there after the session ends.

An allowed command can leave the sandbox

An allow rule does more than skip the question. When every part of a command matches an allow rule, the same exec policy code marks it to bypass the sandbox on its first attempt.

ExecPolicy Allow can intentionally imply full trust.Codex source, sandboxing.rs

There is one exception in the same file. If the permission profile denies reads of some paths, the command stays in the sandbox, because leaving it would grant those reads. Only an approval you give for an explicit escalation can widen the filesystem.

Without such a deny, the prefix decides how much you trust. Allow npm and every script in package.json runs outside the sandbox. Allow git and a commit runs whatever hooks the repository installed, with your account and your network.

"I allowed git, so Codex stops asking about it."

Revision 1: it can also stop sandboxing it. Allow git status, not git.

Permission profiles shape the sandbox

The sandbox itself is a permission profile. Three are built in, :read-only, :workspace and :danger-full-access, and default_permissions picks one. You can define your own under [permissions], extend another with extends, and set entries the permissions config spells out.

Files take read, write or deny per path or pattern, so a pattern such as **/*.env can be hidden from commands, and that deny also keeps allowed commands inside the sandbox. Network takes an on or off switch and an allow or deny per domain.

A reviewer can answer for you

approvals_reviewer decides who answers. It is user by default; auto_review, in the config types, hands sandbox escapes, blocked network access and MCP prompts to a subagent that weighs the risk, then approves or denies.

The command-line options turn it on with --approve-for-me, alias --not-so-yolo, which routes approvals to that review and keeps the workspace sandbox. The reviewer is a model too. It replaces you in the chair; the sandbox stays where it was.

A setup that holds

Start from Default. Keep the workspace sandbox and the network off, and turn the network on for one task when it needs it.

Keep allow rules narrow. Prefer prompt for anything that runs other code, read rules/default.rules now and then, and delete the prefixes you would not let run outside the sandbox.

Forbid what you never want. A forbidden rule for git push, with a justification, beats any allow that also matches.

Set the floor for a team. On Linux and macOS, /etc/codex/requirements.toml can list the allowed approval policies, reviewers, sandbox modes and permission profiles, and add rules, per the requirements code.

Put a boundary under the rules. Ask what the process can reach, not what the model intends. Our list of AI agent security risks covers the wrong file and the wrong host, and what agentic AI security means to us comes down to 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. Codex's own sandbox cannot start there, so Codex runs in full access while the outer rules decide which files and hosts every command can reach, including the ones a Codex rule allows; the Codex section of the agents sheet says what we set. It is one way to put a boundary under the rules, and a container or a virtual machine can do the same.

So, how do they work?

A preset picks a sandbox and an approval policy, the policy decides when you are asked, and rules decide some commands before anyone is asked. Allow means no question, and no sandbox unless the profile denies some reads, so keep allow rules to the exact commands you would run yourself. Read the execpolicy notes before you write your first rule, and the Codex security policy.

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.