Repository navigation
Description
Summary
On macOS, a long-running Codex app-server that is already running under an outer Seatbelt policy cannot start normal workspace-write tool commands. Both exec_command and the internal apply_patch tool fail before the requested operation begins with:
sandbox-exec: sandbox_apply: Operation not permitted
The same read-only command succeeds when retried through require_escalated, which bypasses the failing nested sandbox path. This points to sandbox setup rather than project file permissions.
Environment
- macOS 26.6 / Darwin 25.6.0, Apple Silicon arm64
- Bundled Codex CLI: 0.154.0-alpha.6.2
- Surface: long-running codex app-server over stdio
- Parent app-server process is already constrained by an outer macOS Seatbelt policy
- Turn policy: workspace-write
- cwd and writable root both contain the target file
Observed behavior
A normal exec_command that only reads a file inside the writable workspace fails immediately:
sandbox-exec: sandbox_apply: Operation not permitted
No command output is produced, indicating that the requested child command never starts.
Retrying the same read via require_escalated succeeds.
The internal apply_patch tool also fails on a file inside the workspace:
apply_patch verification failed: Failed to read file to update $WORKSPACE/file.md:
fs sandbox helper failed with status exit status: 71:
sandbox-exec: sandbox_apply: Operation not permitted
Because apply_patch has no per-call escalation path, ordinary workspace edits are blocked even though the file is within the declared writable root.
Expected behavior
- A workspace-write tool call should be able to read and edit files inside its declared writable root even when app-server has an outer security boundary.
- If nested Seatbelt application is unsupported, the runtime should preserve the parent sandbox and avoid applying a conflicting child sandbox, or return a structured diagnostic with a safe recovery path.
- apply_patch should not become unusable solely because its sandbox helper cannot apply a second profile.
Reproduction outline
- Launch codex app-server on macOS from a parent process already constrained by Seatbelt.
- Start a turn using workspace-write with a valid cwd and writable root.
- Run a trivial exec_command against a file inside that root.
- Run apply_patch against the same file.
- Observe both fail before execution with sandbox_apply and exit 71.
- Retry the read through require_escalated and observe it succeed.
Notes
This resembles nested macOS sandbox failures reported in:
- Memory Phase 2 ignores sandbox_mode=danger-full-access and starts nested macOS sandbox-exec #30615
- node_repl JS kernel fails on macOS with sandbox-exec sandbox_apply Operation not permitted #26262
- macOS: Shell execution silently fails in workspace-write and read-only sandboxes via mcp-server; danger-full-access works #18243
- macOS 0.122.0: apply_patch hangs under workspace-write but succeeds under danger-full-access #19020
The exact surface here is different: a long-running app-server turn where both exec_command and internal apply_patch fail, while the same command succeeds through the escalation path.
I have not disabled sandboxing as a workaround because that would weaken the intended security boundary.
Activity
keiwaya commentedon Sep 24, 2026
Correction / resolved for this setup (2026-09-24): I identified the difference that my earlier report missed. The successful launcher commands matched pre-existing execpolicy
allowrules. Later I changed the invocation to include an inline environment assignment and shell redirection/status handling, which prevented those prefix rules from matching.In the same parent session, with
approval_policy=neverand the same restricted profile unchanged, I have now verified:agent-process run Dev ..., then a freshagent-process run Reviewer ...: succeeded, including actual child commands and an isolated fixture change; the reviewer stayed read-only.CODEX_HOME=... agent-process run Dev ... > log 2>&1; ...on a separate clean fixture: reproducedsandbox-exec: sandbox_apply: Operation not permitted, exit 71, before child commands could execute. No fixture change.The existing rules permit the direct launcher outside the parent's command sandbox; the children still apply their own role sandboxes. This matches the documented execpolicy rules and shell-wrapper handling. I changed no rule, permission setting, model default, or sandbox implementation to recover the run.
My earlier comparison of session-level settings overlooked command-specific policy matching. The standalone
sandbox-execprobe does not match the launcher rule either, so it was not an equivalent test. This does not demonstrate that nested Seatbelt itself has been fixed, and I withdraw the suggestion that our success-to-failure transition was an unexplained runtime regression. Apologies for the incomplete original diagnosis.Original report, retained as history
I can reproduce the same pre-execution
sandbox_applyexit 71 with a nested Codex run on macOS 27.0 (arm64), Codex CLI 0.155.0.The outer session is an interactive Codex PM session with a restricted workspace-write permission profile, network enabled, and approval policy
never. It starts a childcodex execfor an isolated Git fixture. The child records a read-only preflight turn and then a workspace-write resume under the same session ID, but its first Bash command fails before execution:Even the following minimal command fails with exit 71 when launched from the outer Codex session:
/usr/bin/sandbox-exec -p '(version 1)(allow default)' /usr/bin/trueThe same minimal command and
codex sandbox /usr/bin/truehave exited 0 in a normal Terminal outside Codex. The isolated fixture remains clean. I did not bypass the child sandbox or use escalation.A notable difference from a consistently failing setup: an earlier child Dev and Reviewer did run successfully from a parent session with the same recorded Codex version, permission profile, network setting, and approval policy. Later, the minimal nested
sandbox-execfailed even in that same parent session. A fresh parent session with the same recorded settings also fails. The transition is not explained by the recorded configuration.This appears related to the nested Seatbelt failure in this issue, though my surface is an interactive parent launching a noninteractive child, and I have not established the underlying cause. Is this nesting path supported, or is there a safe diagnostic/recovery path that preserves both parent and child sandbox boundaries?
aghi79 commentedon Sep 29, 2026
We are assessing a local Codex app-server integration on macOS 26.6.2 with the 0.157.1 SDK/CLI pair. In a synthetic restricted-read test, the app-server reported the intended permission profile and the one-byte permitted fixture as allowed, but the permitted
command/execreturned exit code 71, empty stdout and anoperation_not_permittedstderr category. We stopped before attempting the denied fixture. No agent turn or private-file test was run.This resembles the sandbox setup failure in this issue, but our retained diagnostic does not identify the enforcing layer or contain the full
sandbox_applyline, so we cannot claim the same root cause. For 0.157.1, is there a supported way to distinguish an outer/inner macOS sandbox conflict from a profile/configuration refusal without relaxing the intended boundary? Which documented version-matched configuration can permit the synthetic allowed read, deny a synthetic out-of-root read, and constrain all built-in file, shell and network tools during a model turn? If no such configuration is supported, could you identify the first supported SDK/runtime pair or confirm that this integration shape remains unsupported?AlfiAI commentedon Oct 26, 2026
We are assessing native sandbox verification with Codex CLI 0.163.0 on macOS from an already sandboxed workspace session. A helper invocation returned exit 71 with
sandbox_apply: Operation not permitted. That invocation also had a command-syntax mistake; the corrected invocation has not been run. We therefore cannot claim a clean version-specific reproduction or a confirmed kernel-level cause.Is there a documented, supported interface for verifying an inner permission profile while preserving the existing outer isolation? If this nesting arrangement is unsupported, could you confirm that limitation and identify any supported verification interface that does not require bypassing or relaxing the outer boundary?
We have not retried through escalation, disabled isolation, or launched a model for this verification. We understand that the earlier execpolicy-based recovery described here ran outside the parent command sandbox and does not establish nested Seatbelt compatibility.
v2b9p9j7vh-max commentedon Nov 8, 2026
Adding another observed case:
sandbox_apply: Operation not permittedAn outer sandbox was already present in this session. That is an observation, not a confirmed root cause.
I have submitted feedback with ID
01a1a89c-1de6-7710-9658-2f4c098ca0fafor reference.gatfygubgx commentedon Nov 25, 2026
Additional reproduction: two released CLI versions, matched native/outer-sandbox control
I reproduced the same macOS error on Codex CLI 0.160.0 and 0.172.0. Both versions recognize the current platform-specific command syntax:
codex sandbox -c 'sandbox_mode="read-only"' -- /usr/bin/trueThe command is an inert canary: no model, network, file mutation or privileged operation is requested.
The native terminal observations are from an operator-witness transcript; the host-confined observations are tool-captured. The same host, binary versions and command arguments were used. The runner's version-bound source establishes an existing outer Seatbelt policy. The inner sandbox error occurs before /usr/bin/true runs. This supports an environment-dependent sandbox initialization conflict; I have not independently identified the exact kernel denial or proved universal incompatibility of every nested profile.
Expected: a supported approach that preserves the host's security boundary, Codex filesystem/network policy and independent approval semantics, or a structured diagnostic for unsupported composition. Successful execution obtained by disabling isolation or by relying on an existing out-of-sandbox command allow rule would not demonstrate that nested sandbox initialization is fixed.
Could maintainers confirm whether a supported isolation-preserving composition exists for these versions, or whether this is a known unsupported configuration? If a fix lands, a matched positive canary and independent policy-denial tests would help verify it.