Skip to content

macOS app-server: nested workspace-write tools fail before execution with sandbox_apply exit 71 #45657

Open

Description

@cheqing0410

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

  1. Launch codex app-server on macOS from a parent process already constrained by Seatbelt.
  2. Start a turn using workspace-write with a valid cwd and writable root.
  3. Run a trivial exec_command against a file inside that root.
  4. Run apply_patch against the same file.
  5. Observe both fail before execution with sandbox_apply and exit 71.
  6. Retry the read through require_escalated and observe it succeed.

Notes

This resembles nested macOS sandbox failures reported in:

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

  1. added
    bug
    app-server
    sandbox
    tool-calls
    on Sep 15, 2026
  2. keiwaya commented on Sep 24, 2026

    @keiwaya

    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 allow rules. 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=never and the same restricted profile unchanged, I have now verified:

    • Direct agent-process run Dev ..., then a fresh agent-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: reproduced sandbox-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-exec probe 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_apply exit 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 child codex exec for 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:

    sandbox-exec: sandbox_apply: Operation not permitted
    exit 71
    

    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/true

    The same minimal command and codex sandbox /usr/bin/true have 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-exec failed 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?

  3. aghi79 commented on Sep 29, 2026

    @aghi79

    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/exec returned exit code 71, empty stdout and an operation_not_permitted stderr 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_apply line, 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?

  4. AlfiAI commented on Oct 26, 2026

    @AlfiAI

    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.

  5. v2b9p9j7vh-max commented on Nov 8, 2026

    @v2b9p9j7vh-max

    Adding another observed case:

    • macOS: 26.3
    • ChatGPT app: 26.1103.31037
    • Error: sandbox_apply: Operation not permitted
    • Exit code: 71
    • Node did not start.

    An 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-2f4c098ca0fa for reference.

  6. gatfygubgx commented on Nov 25, 2026

    @gatfygubgx

    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/true

    The command is an inert canary: no model, network, file mutation or privileged operation is requested.

    CLI Ordinary native macOS terminal Existing host-confined command runner
    0.160.0 exit 0, empty stderr exit 71, sandbox_apply: Operation not permitted
    0.172.0 exit 0, empty stderr exit 71, sandbox_apply: Operation not permitted

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app-serverbugsandboxtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions