Checked November 17, 2026. This article analyzes the Codex CLI 0.169.0 release and current OpenAI documentation. It is not a claim that I reproduced the original bug or benchmarked the fix. Commands below are examples to review and run in your own environment.
Imagine a CI job that checks out a pull request and asks an AI agent to review it:
codex exec --sandbox workspace-write \
"Review the current changes and report anything risky."
The agent is allowed to work inside the checkout. So it must trust the checkout's .codex/config.toml, right?
No. Those are different permissions, and a November 13 fix in Codex CLI 0.169.0 made the boundary explicit for scripted runs. codex exec now keeps project configuration and project-defined MCP servers disabled in untrusted directories, even when the command sandbox is workspace-write. codex exec --trust and codex review --trust deliberately save project trust.
If you run agents on freshly cloned repositories, that distinction matters more than another model picker or terminal UI feature.
Three questions hiding behind the word permission
Here are three questions with different answers:
| Question | Control | What it decides |
|---|---|---|
| May the agent write here? | Sandbox (read-only, workspace-write, etc.) |
What model-generated commands can access or change. |
| May this repository configure the agent? | Project trust | Whether project-scoped .codex/ settings, hooks, rules and MCP definitions are loaded. |
| Must a person approve this action? | Approval policy | When execution pauses for review. |
A writable checkout is not evidence that its instructions for running tools were accepted. Conversely, a trusted checkout does not mean every command is allowed: sandbox and approval settings still apply.
This isn't a claim that Codex cannot read untrusted source files. Its task may require reading them. The trust gate concerns project-scoped configuration, not every line of repository content. A source file or README can still contain hostile instructions, so ordinary prompt-injection precautions remain necessary.
See OpenAI's agent security overview and configuration precedence guide for the separate controls.
The release note people running CI should read
The relevant change is described as a bug fix, not an entirely new security model. The 0.169.0 release notes say non-interactive runs no longer enable project configuration and MCP servers in untrusted directories merely because the sandbox permits workspace writes. The change points to PR #60041.
Consider a checkout with these files:
service/
├── .git/
├── .codex/
│ ├── config.toml
│ └── hooks.json
├── AGENTS.md
└── src/
An untrusted run doesn't load the project .codex/ layers. That includes its project-local config, hooks and rules. But the user and system configuration layers remain separate, and a user-installed MCP server may still be available. "Untrusted project" therefore does not mean "no MCP tools anywhere."
One more distinction: AGENTS.md is repository guidance, not the same thing as .codex/config.toml. Don't assume the .codex/ trust gate makes every repository instruction harmless or invisible.
Why MCP changes the consequences
A project-local .codex/config.toml can define an MCP connection. One form points to a remote HTTP service; another tells the client to launch a local executable over stdio. That latter command is part of the environment you are allowing to start.
OpenAI's security cookbook makes an uncomfortable detail explicit: local stdio MCP processes run outside the local command sandbox. An allowlist for the executable and arguments is not, by itself, a constraint on working directory, environment variables or what the process can access.
So if your team says, "The coding agent is sandboxed, so any MCP process it starts is sandboxed too," you should correct that assumption before building the CI job.
For a reviewed project, an approved MCP integration may be exactly what the task needs. The problem is granting that capability as an accidental side effect of running a write-capable agent in an unfamiliar directory.
A read-only preflight before trusting a checkout
I would start with inspection, not --trust. Here is a minimal Python 3.11+ script that reads only a repository's Codex configuration. It lists MCP server names and whether they appear to use an HTTP URL or a local launcher. It deliberately does not print commands, arguments or environment values; those may contain secrets.
from pathlib import Path
import sys
import tomllib
repo = Path(sys.argv[1] if len(sys.argv) > 1 else ".")
config = repo / ".codex" / "config.toml"
if not config.is_file():
print("No project .codex/config.toml")
raise SystemExit(0)
with config.open("rb") as stream:
data = tomllib.load(stream)
servers = data.get("mcp_servers", {})
for name, settings in servers.items():
kind = "HTTP" if "url" in settings else (
"stdio" if "command" in settings else "unknown"
)
print(f"MCP {name}: {kind}")
print(f"Project MCP entries found: {len(servers)}")
The snippet is self-contained and requires no third-party package installation. Its output is an inventory of declarations, not proof that the servers are enabled, safe or actually connected.
Don't stop at config parsing. Before authorizing project trust, review any project .codex/hooks.json, inline [hooks], executable scripts referred to by hooks, policy rules, and plugin definitions. Then inspect the actual MCP executable, dependency chain, requested credentials, reachable networks, and intended tool permissions. The name internal-docs proves nothing about what a server does.
What --trust actually changes
For a project you own and have reviewed, Codex documents this explicit form:
codex exec --trust --sandbox workspace-write \
"Review the current changes and report anything risky."
Do not run this on an arbitrary PR checkout just to make a missing tool appear. --trust is not a per-command permission prompt. The CLI reference says it saves project trust for this and future chats, including when the run uses --ephemeral. It conflicts with --ignore-user-config. If a project was explicitly marked untrusted, the documentation says to change that setting first.
This is the most surprising footnote for an automation author: ephemeral conversation state does not make the trust decision ephemeral.
If a pipeline needs an MCP server, a safer design is to review and provision that server as part of the runner's controlled configuration and policy, then test exactly what is active. Don't ask every unreviewed checkout to decide which processes your CI host should launch.
There is also no universal guarantee that a trusted project can replace all user-level settings. Codex ignores sensitive project-level override keys including provider/auth routing, notify, and otel configuration. The advanced configuration reference lists them explicitly.
A five-minute CI checklist
Before changing a pipeline from an older Codex version, answer these questions with actual runner evidence:
-
Pin and record the CLI version. Use
codex --versionin the job log. The behavior discussed here was documented for 0.169.0; recheck later releases before publishing or upgrading. -
Separate write access from trust. Record the effective sandbox and approval policy. Don't assume
workspace-writealso enables.codex/config.toml. -
Inventory the checkout's
.codex/content. Review config, hooks and any executable paths before accepting project trust. The read-only script above helps only with the MCP declarations. -
Inventory globally configured MCP servers too. Project trust does not disable the user-level layer. Check the runner's effective server list and tool availability; a
codex mcp listlisting by itself is not evidence a tool was used safely. - Test one permitted and one denied operation in a disposable environment. Compare the CLI's real diagnostics, approval events and external process logs. Don't infer an authorization decision from the model saying "I wasn't allowed."
If the agent can still complete a task without the project MCP server, a passing job alone will not tell you whether the server was enabled. Put a positive preflight assertion in the pipeline for every dependency you expect to be available.
Observing an agent is not authorizing it
I work on ccdeck, a local dashboard for Claude Code and Codex sessions. One reason I care about this distinction is that a session timeline can show activity without acting as a permission engine. An observer should never be mistaken for a policy boundary. ccdeck does not grant project trust or approve MCP processes.
The 0.169.0 fix is a useful reminder of what a trust decision really represents. A sandbox says which commands may operate inside an environment; a trusted project is allowed to contribute configuration to that environment. In CI, an external checkout should not receive the second privilege merely because your build job needed the first.
A question for people running Codex in CI: do you configure MCP connections on the runner, or do you let each checked-out repository define them?
Top comments (0)