Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.144.3
Which model were you using?
gpt-5.6-sol with high reasoning effort
What platform is your computer?
macOS 26.5.1 (25F80), Apple Silicon (arm64)
What issue are you seeing?
In Code Mode on macOS, shell commands are invoked through an outer functions.exec custom tool call and an inner tools.exec_command. The inner command stays under the outer Seatbelt sandbox even when:
- it matches an explicit
allowrule, or - it is retried with
sandbox_permissions: "require_escalated".
The initial .git write failure under the workspace profile is expected because .git is a protected path. The bug is that the approved/allowed escalation does not lift that restriction.
The rollout records the nested call and an immediate failure, but no approval request/decision event for the inner command. Outer telemetry identifies only tool_name=exec.
Original affected thread: 019f5c9b-6f72-74f0-9f6d-d3fa9f743897
Effective configuration
default_permissions = "workspace"
approval_policy = "on-request"
approvals_reviewer = "auto_review"The repository is trusted and the workspace root is writable. Global rules include:
prefix_rule(pattern=["git", "add"], decision="allow")
prefix_rule(pattern=["git", "commit", "-m"], decision="allow")There is no local requirements.toml and no explicit .git deny rule.
What steps can reproduce the bug?
- Start Codex on macOS with the workspace permission profile.
- In Code Mode, invoke:
const r = await tools.exec_command({ cmd: "git add --refresh -- tests/test_ui_claude_agent_stream.py", workdir: "/Users/<user>/<repo>" });
- Observe the expected protected-path failure for
.git/index.lock. - Retry the same inner call with:
sandbox_permissions: "require_escalated", justification: "Allow the explicitly authorized git index refresh.", prefix_rule: ["git", "add"]
- Observe the same Seatbelt denial immediately, without an approval event.
A fresh controlled nested-Codex diagnostic reproduced the propagation problem more minimally. Both the normal and escalated inner commands exited in about 0.1 seconds with:
sandbox-exec: sandbox_apply: Operation not permitted
The original thread produced:
fatal: Unable to create '/Users/<user>/<repo>/.git/index.lock': Operation not permitted
An escalated direct probe such as touch .git/codex-write-probe also remained denied.
What is the expected behavior?
A nested command matching an allow rule, or a command whose require_escalated request is approved, should execute outside the workspace Seatbelt restriction. If escalation cannot be honored through Code Mode, the inner request should be surfaced as rejected/unsupported instead of silently running with the original sandbox.
Additional information
Read-only Git operations work. The same Git binary and repository work outside the Codex shell, and GitHub Desktop can update the repository metadata normally. File ownership, ACLs, flags, stale locks, and alternate Git binaries were ruled out.
Related but distinct:
- .git is mounted read-only even though Codex is configured for workspace-write #15505 concerns the normal protected
.gitbehavior in workspace-write. - Codex sandbox_permissions approval doesn't get surfaced through app-server #21982 concerns an app-server approval request not being surfaced; this report is specifically the Code Mode outer-
exec/ inner-exec_commandpropagation path.
Activity
sixbangs commentedon Sep 13, 2026
Seeing the same behavior with 1Password CLI on macOS. Through
functions.exec→tools.exec_command, this still fails:The host's kernel log confirms:
An explicitly escalated diagnostic also returned
sandbox_check: 1;/usr/bin/logreportedCannot run while sandboxed.opworks in a normal terminal. Restarting the app and resuming the session did not help.App: 26.901.51231 (8109), bundle
com.openai.codex. 1Password: 8.12.36; CLI: 2.34.1. Workspace permission profile withauto_review.OskarSwierad commentedon Sep 15, 2026
I can reproduce this on Linux Codex CLI, so the issue is not macOS-specific.
Environment
0.154.0, installed via curl26.908.408347.2.5-1-cachyosgpt-5.6-solReproduction
A normal Code Mode call failed as expected because
.gitis protected:fatal: Unable to create '.git/index.lock': Read-only file systemThe agent then retried through the same outer
functions.execcall with:After my approval, the inner command still received:
fatal: Unable to create '.git/index.lock': Read-only file systemIt also retried
git add convert.pyseparately withrequire_escalated. The command prefix was saved as approved, but.git/index.lockremained read-only.Running the identical Git commands outside the Codex conversation succeeded immediately.
This appears to be the same nested-sandbox propagation problem described in this issue? Basically, the approval flow runs, but the inner
tools.exec_commandremains confined by the outer Code Mode sandbox. On Linux,.gitis mounted read-only rather than producing the macOS Seatbelt error.Config
OskarSwierad commentedon Sep 18, 2026
I worked around it by explicitly granting
.gitwrite access in my named permission profile:I then verified it in a temporary repository, first with actual ChatGPT Desktop, then with:
Result:
So the explicit
.gitpermission works on Linux and avoids the failing escalation path. However,require_escalateditself still appears not to propagate through the Code Mode outerexec/ innerexec_commandboundary.jason21wc commentedon Sep 30, 2026
Additional macOS reproduction, with an important denied-read-policy caveat.
Our commands use the same
functions.exec→tools.exec_commandpath described here. Direct execution of:/bin/ps -p $$ -o pid=,ppid=,comm=fails inside Codex with exit 127 and
operation not permitted: /bin/ps. The identical command in ordinary Terminal succeeds and prints the current zsh PID, parent PID, and/bin/zsh. This is a direct invocation, not merely a Homebrew/RVM startup warning.Earlier normal and
sandbox_permissions: "require_escalated"attempts both failed. No automatic approval-review rejection was returned; we cannot establish that unrestricted execution was actually attempted. Codex's/usr/bin/log showalso returns exit 64,log: Cannot run while sandboxed, matching the September 13 comment above.Environment and evidence:
auto_review./bin/psis setuid-root on this host; relevance to the exact denial is unproven.denyandps, returned no matching events. This is inconclusive, not proof that no denial occurred.Caveat: upstream sandboxing code deliberately preserves sandboxing during escalation when denied-read rules exist. That may explain our escalation result independently of the propagation defect reported here. We have not matched the running binary to that revision and are not claiming an identical root cause.
Related symptom reports: #8104 and #4620. The latter's startup workarounds do not establish a fix for direct ps execution.
Could maintainers clarify whether narrow read-only process inspection is supported while retaining denied-read protections, and whether this reproduction belongs to this issue or intentional policy behavior? If intentional, an actionable explanation when escalation retains the sandbox would help distinguish it from a failed approval path. No protected-path rules or other security controls were removed for this investigation.
TyceHerrman commentedon Oct 20, 2026
Reproduced on macOS with Codex Desktop’s bundled
0.163.0-alpha.10.2,on-requestapprovals,auto_review, and a workspace profile containing credential-read denies.With this saved rule:
Calling
git switch -c test/probethroughfunctions.exec→tools.exec_commandwithsandbox_permissions: "require_escalated"failed immediately when creating the Git reference lock. In the same session, escalatedgit branch test/probe-othersucceeded; no saved rule allowedgit branch. Explicit command-scoped Git write grants also allowedgit switch -cto succeed.The approval logic and sandbox selection appear to explain this: the saved allow rule skips fresh approval, leaving
already_approved = false, but escalation with read denies requires that approval to broaden writes. The explicit escalation request therefore retains the original restrictions.#54440 may share this cause, although I haven’t reproduced its Windows case.
Could an explicit escalation request trigger filesystem approval even when the command is already allowlisted, or clearly report that broader access wasn’t granted?
m-szymanska commentedon Nov 21, 2026
I can reproduce this in the desktop app on Apple Silicon (macOS 27.3, app 26.1117.31558, bundled Codex CLI 0.171.0-alpha.13) with an on-request approval policy.
The probe uses only a profile that denies networking and a no-op executable. It does not read user files or change settings:
/usr/bin/sandbox-exec -p '(version 1) (allow default) (deny network*)' /usr/bin/truecodex sandboxfrom that terminalfunctions.exec→tools.exec_command, withsandbox_permissions: "require_escalated"and approvalBoth failures report
sandbox-exec: sandbox_apply: Operation not permitted. The terminal control reproduces the same error when a parent sandbox is already active. It does not identify a Code Mode approval propagation bug by itself. This desktop profile contains explicit denied reads. In the exact bundled version,sandbox_override_for_first_attemptdeliberately retains a filesystem sandbox after approval when denied reads must be enforced. I have not verified that the desktop failure also occurs with a policy that has no denied reads.A practical example is Homebrew’s sandboxed bottle extraction. The approved upgrade stops at extraction with exit 71. For a profile with denied reads, the compatibility gap is that an approved tool can still need to establish its own Seatbelt profile. If nested sandboxing cannot be composed safely, an explicit unsupported-operation error would distinguish this case from approval loss. Any functional fix must preserve denied reads inside the approved execution path itself. For a separate no-denied-read profile, the same probe can verify whether the requested escalation actually reaches the executor.