Agentic AI AcademyAgentic AI Academy

Widening & Bypassing Access Safely

/permissions, --add-dir, profiles, and the --yolo warning

Intermediate 11 minBuilder
What you'll be able to do
  • Switch Codex's approval and sandbox posture mid-session with /permissions (the command that replaced /approvals)
  • Grant exactly the extra access a task needs using --add-dir and -C/--cd instead of dropping the sandbox
  • Explain why the newer permission profiles do not compose with the legacy sandbox_mode and choose one system per session
  • Identify --dangerously-bypass-approvals-and-sandbox (--yolo) and the only situation where it is acceptable
  • Recognize that --full-auto is deprecated and prefer explicit -s/-a flags
  • Route risky approvals to an auto-review agent that screens for exfiltration and destructive actions
At a glance

Once you understand that Codex separates approvals (when it asks) from the sandbox (where it can act), the next skill is widening access without throwing the doors open. This lesson is a least-privilege toolkit: switch posture mid-session with /permissions, hand over one extra writable directory with --add-dir instead of dropping the sandbox, understand why the newer permission profiles don't compose with the legacy sandbox_mode, route risky approvals to an auto-review agent, and treat --dangerously-bypass-approvals-and-sandbox (--yolo) as a hardened-VM-only last resort.

  1. 1The mental model: widen the smallest hole that unblocks the task
  2. 2/permissions: change posture without restarting
  3. 3--add-dir: grant one directory, keep the sandbox
  4. 4Permission profiles — and the one-system rule
  5. 5Auto-review: route risky approvals to a reviewer agent
  6. 6--yolo and --full-auto: the levers to (almost) never pull

The mental model: widen the smallest hole that unblocks the task

You already know the core safety model from the previous lesson: sandbox = WHERE Codex can read, write, and reach the network (OS-enforced); approval = WHEN it has to stop and ask you. They're independent dials, and the Auto preset (workspace-write + on-request) is the sensible local default.

This lesson is about the moment that default isn't enough. Codex needs to write to a directory outside your project, or hit a package registry, or run unattended in CI — and it's pausing to ask, or refusing outright. The instinct is to reach for the biggest lever: drop the sandbox entirely, or pass --yolo. Resist it.

The right mental model is a least-privilege staircase. When a task is blocked, climb exactly one step — grant the one directory, allow the one domain, flip one approval — never jump to the top. The cost of over-granting isn't hypothetical: Codex runs model-generated commands, and a prompt injection in a web page, a dependency, or an MCP tool result can turn "full access" into "deletes files / exfiltrates secrets." The sandbox is your primary defense against exactly that, so you widen it deliberately and narrowly.

Think of it as three escalating tools, in order of preference:

  1. /permissions — change posture for this session without restarting.
  2. --add-dir — grant one more writable directory while keeping the sandbox on.
  3. --yolo — turn everything off. Reserved for hardened VMs. Almost never the answer.

Key insight

The one rule

When Codex is blocked, grant the narrowest thing that unblocks it. A single --add-dir is almost always the right answer; danger-full-access and --yolo almost never are.

/permissions: change posture without restarting

You don't have to kill your session and relaunch with new flags every time the task's needs change. /permissions switches Codex's approval/sandbox posture mid-session — it's the picker for "set what Codex can do without asking first."

A typical flow: you start in Read Only to let Codex explore and propose a plan you trust, then run /permissions and bump up to Auto so it can actually make the edits — all in the same thread, with all the context it already gathered intact.

text
/permissions        → opens the posture picker
  Read Only         (read-only + on-request)  — browse & plan
  Auto   (default)  (workspace-write + on-request)  — edit in workspace
  Full Access       (danger-full-access + no approvals)  — not recommended

Two naming gotchas the dossier is explicit about:

  • /permissions replaced /approvals. Older tutorials, videos, and even some slice titles still say /approvals — it is no longer a distinct entry. Use /permissions.
  • /approve is a different command. It approves one retry of a recent auto-review denial (covered later in this lesson) — it does not switch your posture. Don't confuse the two.

To see your current posture at any time, run /status, which shows workspace dirs, context usage, rate limits, and the thread ID.

Watch out

/approvals is gone; /undo never existed

Two stale habits to drop: the mode-switching command is now /permissions, not /approvals. And there is no /undo in Codex — you roll back through your normal git workflow, because the transcript surfaces every action Codex took. (Verify the live roster: developers.openai.com/codex/cli/slash-commands.)

--add-dir: grant one directory, keep the sandbox

Here's the single most useful move in this lesson. When Codex needs to write somewhere outside your workspace — a shared cache, a sibling repo, a generated-assets folder — the wrong fix is to drop to danger-full-access. The right fix is to grant just that path:

bash
# Grant one extra writable directory; sandbox stays ON everywhere else
codex --sandbox workspace-write --add-dir ../shared-assets

# Repeatable — grant several without ever removing the boundary
codex --add-dir ../shared-assets --add-dir /tmp/build-cache

--add-dir <path> is repeatable and is explicitly preferred over dropping to danger-full-access. Every directory you don't list stays protected by the OS-level sandbox, so a misbehaving command can't wander off and touch your home directory or /etc. You've widened the hole by exactly one directory.

A sibling flag controls where the agent starts: -C / --cd <path> sets the working directory before the agent runs. This is how you point Codex at the right place in a monorepo (open the directory that holds the .codex folder) without granting write access to the whole tree.

GoalReach forNot
Write to one extra folder--add-dir <path> (repeatable)danger-full-access
Start the agent in a subdir-C / --cd <path>restarting in that dir manually
Persisted extra writable roots[sandbox_workspace_write] writable_roots in configdropping the sandbox in config

If the same extra directory is needed every run, persist it in ~/.codex/config.toml under [sandbox_workspace_write] writable_roots = [...] rather than typing the flag each time — but the principle is identical: name the directory, keep the sandbox.

Tip

Network is its own dial, not a directory

--add-dir grants filesystem access, not network. Remember from the last lesson that workspace-write has network OFF by default; opt in narrowly via [sandbox_workspace_write] network_access = true (legacy) or a per-domain allowlist (newer profiles) — never reach for full access just to install one package.

Permission profiles — and the one-system rule

Alongside the legacy sandbox_mode, Codex ships a newer permission profiles system that expresses least-privilege filesystem and network rules more granularly. Built-in profiles:

ProfileEffect
:read-onlyKeeps local command execution read-only
:workspaceAllows writes inside the active workspace roots
:danger-full-accessRemoves local sandbox restrictions

Filesystem access levels are read, write, deny — and the conflict rule is the one to memorize: deny wins, and more-specific entries override broader ones. So you can grant write to a whole tree and then carve out a deny on a secrets folder inside it, and the deny holds. Network rules work the same way as a per-domain allowlist where deny overrides allow.

toml
# Newer permission-profile schema (illustrative)
[permissions.my-profile.network]
enabled = true

[permissions.my-profile.network.domains]
"api.openai.com"        = "allow"
"*.internal.example.com" = "allow"
"tracking.example.com"   = "deny"   # deny overrides allow

The compatibility trap — and it's the one most likely to bite you: permission profiles do NOT compose with the older sandbox_mode / [sandbox_workspace_write] settings. The docs are blunt: "Choose one system per session." Mixing a sandbox_mode = "workspace-write" with [permissions.*] rules doesn't merge them into something stricter — it produces confusing, version-dependent behavior. Pick one model and stay in it.

Watch out

Two systems that don't merge

Permission profiles ([permissions.*], :read-only/:workspace/:danger-full-access) and legacy sandbox_mode ([sandbox_workspace_write]) are parallel, coexisting systems — they do not compose. Configure one or the other for a session, never both. This schema is volatile; confirm the exact shape live at developers.openai.com/codex/permissions and /codex/config-advanced.

Auto-review: route risky approvals to a reviewer agent

There's a middle ground between "approve every single command yourself" (slow) and "approve nothing" (-a never, blind). Auto-review routes eligible approval requests to a reviewer agent instead of interrupting you for each one.

You enable it by setting approvals_reviewer = "auto_review" (the alternative is the default "user"), configured via an [auto_review] section with a policy. When a command would normally prompt you, the reviewer agent evaluates it first, specifically screening for:

  • Data exfiltration — sending your code or secrets somewhere
  • Credential probing — fishing for API keys, tokens, .env files
  • Persistent security weakening — disabling protections, opening backdoors
  • Destructive actionsrm -rf, dropping data, force-pushes

If the reviewer flags something it denied, /approve lets you approve one retry of that recent auto-review denial — this is the command from the earlier gotcha, and now you can see why it exists. In managed/enterprise setups, a guardian_policy_config can override the local [auto_review].policy, so org defaults win over individual config.

Auto-review is a productivity-and-safety layer, not a license to remove the sandbox. It reduces approval fatigue while keeping a screen on the dangerous stuff — but it's still the sandbox, not the reviewer, that physically stops a harmful command from reaching your filesystem.

Note

Where auto-review fits

Think of it as a tier: sandbox (OS-enforced wall) → approvals (you, the human gate) → auto-review (an agent that handles the easy approvals and escalates the scary ones). It thins your approval queue; it does not replace the wall behind it.

--yolo and --full-auto: the levers to (almost) never pull

Finally, the lever this lesson's title warns about. --dangerously-bypass-approvals-and-sandbox — alias --yolo — disables both controls at once. No approvals, no sandbox. Every command Codex generates runs with your full user permissions, with full filesystem and network access.

The name is the documentation. There is exactly one defensible use: inside an externally hardened container or throwaway VM where the blast radius is already contained by something other than Codex — and even then, prefer the narrower tools first. On your real machine, against a repo you care about, --yolo is how a single prompt injection becomes a very bad day.

A related, easily-confused flag: --full-auto is deprecated. It used to be a shortcut for --sandbox workspace-write + --ask-for-approval on-request (the Auto preset). It now prints a warning; prefer setting -s and -a explicitly so your posture is unambiguous. Don't read "full-auto" as "full access" — historically it stayed inside the workspace sandbox; it's --yolo that removes the boundary.

FlagWhat it doesWhen to use
--add-dir <path>Adds one writable dir, sandbox stays onDefault way to widen access
-C / --cd <path>Sets the agent's start directoryPoint at a subdir / monorepo package
--full-autoDeprecated shortcut for workspace-write + on-requestDon't — set -s/-a explicitly
--dangerously-bypass-approvals-and-sandbox (--yolo)Disables both sandbox and approvalsOnly in a hardened container/VM

Note the OS won't quietly help you here either: if a platform can't enforce the sandbox you asked for, Codex refuses to run rather than silently dropping to no-sandbox — so an unsandboxed run is always something you chose, explicitly, with a flag like this one.

Watch out

--yolo removes your last line of defense

With the sandbox off, a malicious instruction hidden in a web page, dependency, or tool output runs with your full privileges — no approval prompt, no OS wall. Only ever inside a disposable, hardened VM. Alias presence (--yolo) and exact behavior can change: verify at developers.openai.com/codex/cli/reference.

Try it: Climb the least-privilege staircase

Goal: practice widening Codex's access by exactly one step instead of throwing the doors open.

1) Start consultative. In a small repo, launch codex and use /permissions to set Read Only. Ask it to propose (not make) a change that would need to write a file into a sibling directory, e.g. ../scratch/output.txt. Confirm it plans the work but does not — and cannot — write.

2) Widen with --add-dir, not full access. Exit and relaunch with the sandbox on plus one extra writable directory:

bash
codex --sandbox workspace-write --add-dir ../scratch "write a hello file into ../scratch"

Verify the write succeeds — and then confirm the boundary still holds by asking Codex to write somewhere you did not grant (e.g. your home directory). It should be blocked or have to ask.

3) Switch posture mid-session. Back in an interactive session, run /permissions to move from Read Only up to Auto without restarting, and run /status before and after to see the posture change. Note that /approvals is not recognized — the command is /permissions.

4) Reason about the dangerous lever. Do NOT run --yolo on your machine. Instead, write two sentences: what --dangerously-bypass-approvals-and-sandbox disables, and the single environment where it's defensible. Then write one sentence on why --full-auto is not the same thing.

5) (Stretch) Inspect auto-review. Read the agent-approvals-security docs and note the four categories the auto-review reviewer screens for. Write one sentence on why auto-review still doesn't let you safely remove the sandbox.

Deliverable: a short note showing the --add-dir command you ran, proof the un-granted write was blocked, and your reasoning on --yolo vs --full-auto. The instinct you're building: when blocked, grant the narrowest thing that unblocks the task.

Key takeaways

  1. 1Widen access with the least-privilege staircase: try /permissions, then --add-dir, and treat --yolo as a hardened-VM-only last resort — never jump straight to full access.
  2. 2/permissions switches approval/sandbox posture mid-session (it replaced /approvals); /approve is unrelated — it retries one auto-review denial.
  3. 3--add-dir <path> (repeatable) grants extra writable directories while keeping the sandbox on, and is explicitly preferred over danger-full-access; -C/--cd just sets the start directory.
  4. 4Permission profiles (:read-only, :workspace, :danger-full-access; deny wins, specific over broad) do NOT compose with legacy sandbox_mode — choose one system per session.
  5. 5Auto-review (approvals_reviewer = auto_review) routes risky approvals to a reviewer agent that screens for exfiltration, credential probing, security weakening, and destructive actions — it thins the queue but doesn't replace the sandbox.
  6. 6--full-auto is deprecated (prints a warning; prefer explicit -s/-a); --dangerously-bypass-approvals-and-sandbox (--yolo) disables BOTH controls and runs with your full permissions.

Quiz

Lock in what you learned

Check your understanding

0 / 4 answered

1.Codex is paused asking permission to write a generated file into a sibling directory just outside your project. You'll do this often for this task. What is the least-privilege way to unblock it?

2.A tutorial tells you to run /approvals to switch from Read Only to Auto mid-session, but Codex doesn't recognize it. What's going on?

3.You've configured a [permissions.my-profile] block with granular read/write/deny rules AND left sandbox_mode = "workspace-write" with a [sandbox_workspace_write] section in the same config. Why is this a problem?

4.Which statement about --full-auto and --dangerously-bypass-approvals-and-sandbox (--yolo) is correct?

Go deeper

Hand-picked sources to keep learning