Skip to content

Sandbox with custom profile forbids all commands on Mac OS once permissions ever change #45953

Open

Description

@warpspin

What version of the Codex App are you using (From “About Codex” dialog)?

26.908.70816

What subscription do you have?

Business

What platform is your computer?

Darwin 27.0.0 arm64 arm

What issue are you seeing?

Codex App, when used without explicit project and a custom permission profile, will have the sandbox deny every execution after the first.

codex-cli does not show the same behaviour (though of course always has some dir implicitely as project dir) unless you explicitely use /permissions.

What steps can reproduce the bug?

Run Codex App with a permission profile.

default_permissions = "mine"

[permissions.mine]
extends = ":workspace"

[permissions.mine.filesystem]
":root" = "deny"
":minimal" = "read"
"/opt/homebrew" = "read"
"/opt/homebrew/var/mysql" = "deny"
"/usr" = "read"
"/bin" = "read"
"~/.ssh" = "deny"
"~/.env" = "deny"
"~/.bash_profile" = "read"
"~/.bashrc" = "read"

[permissions.mine.filesystem.":workspace_roots"]
"**/*.env" = "deny"

Start a chat, but OUTSIDE a project, you write: Please try calling "date"
Output: The date
You write: "Again"
Output: "Couldn’t run date again: the updated sandbox blocks the command runner’s configured /opt/homebrew/bin/bash, and permission was not granted."

You write: "Show exact error message"
Output: "sandbox-exec: execvp() of '/opt/homebrew/bin/bash' failed: Operation not permitted"

You write "Run it through /bin/bash"
Output: "It still fails before executing the command because the runner itself launches the configured Homebrew Bash:"

Also, it's super irritating that the visually selected policy seems to change automatically after the first test.
Also, if it tries to request permission, you can give it but sandbox will still fail.

On Codex App, without projects, default behaviour is already buggy.
Within a project, changing the active permissions through the UI in any way will also trigger the bug and condemn the chat to all access failing.
On codex CLI, sandbox will stay stable until you call /permissions in any way. Even switching to "Full access" will immediately fail with:

failed to load AGENTS.md instructions for environment `local`: fs sandbox helper failed with status exit status:
71: sandbox-exec: execvp() of '/opt/homebrew/bin/codex' failed: Operation not permitted

The root cause of all this seems to be the ":root" = "deny" entry in the config, even though it's officially in your documentation. Remove it from the profile (which I don't want), the problem vanishes.

What is the expected behavior?

Reliable sandbox behaviour.

Additional information

This might be related to #45657 - I am not sure. A sandbox that's tried to be constructed within the current sandbox might cause these problems.

Activity

  1. added
    app
    on Sep 16, 2026
  2. added
    bug
    sandbox
    config
    on Sep 16, 2026
  3. changed the title [-]Sandbox forbids all commands on Mac OS once permissions ever change[/-] [+]Sandbox with custom profile forbids all commands on Mac OS once permissions ever change[/+] on Sep 16, 2026
  4. ryandamico commented on Oct 5, 2026

    @ryandamico

    Same failure here (0.160.1, macOS), with a profile that extends :workspace and sets ":root" = "deny" and ":minimal" = "read".

    On my system the issue depends on how codex is launched. Through the installer's symlink (~/.local/bin/codex or ~/.codex/packages/standalone/current/bin/codex), every session fails at startup:

    fs sandbox helper failed with status exit status: 71: sandbox-exec: execvp() of '~/.local/bin/codex' failed: Operation not permitted
    

    But when launched by the resolved path (~/.codex/packages/standalone/releases/0.160.1-aarch64-apple-darwin/bin/codex), it starts normally and the profile still blocks reads outside the workspace. It looks like the helper gets re-executed through the path codex was invoked with, and the profile denies that path.

    My workaround for now is to replace the ~/.local/bin/codex symlink with a script that resolves the path first:

    #!/bin/sh
    exec "$(cd -P "$HOME/.codex/packages/standalone/current" && pwd)/bin/codex" "$@"
  5. tokenmaxxr commented on Oct 20, 2026

    @tokenmaxxr

    Additional reproduction on codex-cli 0.163.0, installed through Homebrew, on macOS 27.0.1 (26A434).

    This also blocks resuming an existing CLI session:

    codex resume <session-id>

    Observed error (personal paths redacted):

    Error: Failed to resume session from <session-file>: thread/resume failed during TUI bootstrap: thread/resume failed: error resuming thread: failed to load AGENTS.md instructions for environment `local`: fs sandbox helper failed with status exit status: 71: sandbox-exec: execvp() of '/opt/homebrew/bin/codex' failed: Operation not permitted (code -32603)
    

    Relevant parts of the current configuration (excerpt, not a standalone minimal reproduction):

    default_permissions = "workspace-only"
    approval_policy = "on-request"
    
    [permissions.workspace-only]
    extends = ":workspace"
    
    [permissions.workspace-only.filesystem]
    ":root" = "deny"
    ":minimal" = "read"
    "/opt/homebrew" = "read"

    Earlier turns in the affected session used the custom restricted profile. The final saved turn_context contains:

    {
      "approval_policy": "never",
      "permission_profile": {"type": "disabled"},
      "sandbox_policy": {"type": "danger-full-access"}
    }

    Verified workaround: the same session resumes and reaches the idle prompt when the policy is explicitly supplied:

    codex resume <session-id> --sandbox workspace-write

    Additional checks:

    • --no-daemon still produces the original resume failure.
    • codex sandbox -P workspace-only /opt/homebrew/bin/codex --version succeeds.
    • The same sandbox command using the real Homebrew executable path also succeeds.
    • Resuming through the real executable path still fails loading AGENTS.md, although the error becomes Operation not permitted (os error 1).
    • macOS logs show sandbox-exec ... deny(1) file-read-metadata /opt/homebrew/bin/codex during the failing resume.
    • The executable's code signature verifies successfully. Temporarily removing its quarantine attribute did not fix resume; the original attribute was restored.

    This appears consistent with the permission-transition issue described above, with resume restoring a saved disabled profile as another trigger. The exact internal cause is not confirmed.

  6. mrtomatwo commented on Dec 1, 2026

    @mrtomatwo

    I observed the same failure after selecting Full access in an existing local chat on Codex Desktop 26.1120.50957 (build 30866), bundled engine 0.171.0-alpha.13.2, macOS 27.2.1 (26B131), arm64.

    The chat began with a custom restricted profile containing ":root" = "deny" and ":minimal" = "read". After selecting Full access, two consecutive turns recorded active_permission_profile.id = ":danger-full-access" and approval_policy = "never". The effective permission_profile remained managed, and the saved sandbox_policy.type was workspace-write with no writable roots. The tool instructions reported read-only.

    The filesystem policy changed from 32 read rules, 5 write rules, and 38 deny rules to one write rule (:root = write) plus the exact same 38 deny rules, including :root = deny. The :minimal = read rule disappeared.

    A minimal failing call was /usr/bin/true via /bin/sh, with login: false and workdir: "/private/tmp". It returned exit code 134 with empty output. A matching macOS crash report for /bin/sh shows EXC_CRASH / SIGABRT in dyld, including dyld4::CacheFinder. A new side conversation in the same project recorded effective danger-full-access and permission_profile.type = "disabled". The identical call returned 0 there. This comparison uses the affected chat and a fresh control. A standalone reproduction with only the two custom rules above has yet to be verified.

    The tagged build's session settings update preserves prior filesystem denials. The merge turns an unrestricted profile into root-write plus the previous denies. That explains the policy recorded in this chat. The resulting profile also lacks the grant that enables macOS platform read defaults.

    Expected: apply Full access when permitted. If required restrictions prevent that mode, show the effective mode and preserve a working shell or reject the change with an actionable error. The root-deny merge also resembles #37562 on Linux.

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

    appbugconfigsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions