Skip to content

Bare Codex CLI injects hidden granular policy with sandbox_approval=false #56732

Open

Description

@jrothlis

What happened?

Codex CLI 0.164.0 creates a thread with a hidden granular approval policy that makes network escalation impossible.

Environment:

  • Codex CLI 0.164.0, installed with Homebrew
  • macOS 27.0.1, Apple Silicon
  • ChatGPT authentication
  • TERM_PROGRAM=herdr, Herdr 0.9.5
  • Launched using bare codex

A newly created CLI thread receives:

{"granular":{"sandbox_approval":false,"rules":false,"skill_approval":false,"request_permissions":true,"mcp_elicitations":true}}

This is not one of the four visible /permissions modes. Because sandbox_approval=false, commands requiring network escalation—for example outbound SSH—are rejected without displaying an approval request.

The thread is also incorrectly persisted with source="vscode", although:

  • It was launched from the Codex TUI in Herdr.
  • TERM_PROGRAM is herdr.
  • The recorded originator is codex-tui.
  • No VS Code environment variables are present.

Configuration checks:

  • ~/.codex/config.toml contains no approval policy.
  • /etc/codex/managed_config.toml does not exist.
  • codex app-server --print-startup-config reports requirements=null.
  • codex doctor --json reports the effective fresh approval policy as OnRequest.
  • No alias or wrapper is used; codex resolves directly to /opt/homebrew/bin/codex.
  • The incorrect policy is present from the thread's first turn and is persisted in ~/.codex/state_5.sqlite under threads.approval_mode.
  • The app-server protocol exposes approvalPolicy in ThreadStartParams, suggesting the Codex TUI/app-server client is supplying an incorrect per-thread override.

Uploaded thread: 01a16df4-481b-7ba0-ac78-62d304ad01bc

What did you expect to happen?

Bare codex should use the documented visible permission preset/default, permit sandbox escalation prompts, and record the thread source as CLI.

What is the workaround?

Launching with codex --approve-for-me creates an on-request/auto-review context in which the same outbound SSH command succeeds.

This appears to be a Codex TUI/app-server thread-creation bug, not a local or managed configuration issue.

Activity

  1. added
    bug
    CLI
    app-server
    sandbox
    on Oct 24, 2026
  2. github-actions commented on Oct 24, 2026

    @github-actions
    Contributor
  3. jrothlis commented on Oct 28, 2026

    @jrothlis
    Author

    Update: still reproducible on Codex CLI 0.165.0

    This remains reproducible after upgrading the Homebrew installation to codex-cli 0.165.0.

    Fresh-session evidence:

    • Launched from the TUI with bare codex and no permission-related flags.
    • ~/.codex/config.toml still contains no approval_policy, sandbox_mode, default_permissions, approvals_reviewer, or permission-profile configuration.
    • No local requirements.toml, managed config, or macOS MDM policy was found.
    • codex doctor --json resolves the disk/default approval policy as OnRequest and reports no managed filesystem source.
    • The command environment identifies the built-in filesystem profile as CODEX_PERMISSION_PROFILE=:workspace.
    • Nevertheless, the first turn_context receives:
    {
      "sandbox_policy": {
        "type": "workspace-write",
        "network_access": false
      },
      "approval_policy": {
        "granular": {
          "sandbox_approval": false,
          "rules": false,
          "skill_approval": false,
          "request_permissions": true,
          "mcp_elicitations": true
        }
      },
      "permission_profile": {
        "type": "managed"
      }
    }

    Thus the filesystem profile is the standard workspace profile; the TUI displays Custom solely because the injected granular approval policy does not match any visible /permissions preset.

    The new thread is again persisted with originator="codex-tui" but source="vscode". The affected 0.165.0 thread is 01a18417-37fc-7a30-815a-be312d0035d9.

    Manually selecting Ask for approval changes the existing thread to plain on-request, but a later fresh session receives the granular policy again. Guardian reviewer subthreads are also created automatically, despite no local reviewer configuration.

    This differs from #56570, where the configured on-request policy remained active and automatic escalation behavior was restored in 0.165.0. Here the fresh CLI thread is not starting with on-request at all; a per-thread/runtime override replaces the documented default during thread creation.

    The 0.165.0 changelog notes that fresh TUI sessions now honor the server default approval reviewer when no explicit override is present. Combined with the codex-tui / source="vscode" mismatch, the evidence continues to point to the TUI/app-server thread-start path or a server-supplied default, rather than user configuration.

  4. jrothlis commented on Oct 28, 2026

    @jrothlis
    Author

    Codex in this state is incredibly nerfed, it can do almost nothing, and I end up wasting time troubleshooting why it's so nerfed on every single session.

  5. oslijunw commented on Nov 3, 2026

    @oslijunw

    Additional evidence on 0.166.0: granular policy can leave no usable permission-request tool

    I am seeing the same class of problem on macOS with Codex CLI/runtime 0.166.0 (November 3, 2026). Adding evidence here rather than opening a duplicate, as requested by the contributing guide.

    Observed behavior

    • Retained local turn_context records show workspace-write with this approval policy:
    {"granular":{"sandbox_approval":false,"rules":false,"skill_approval":false,"request_permissions":true,"mcp_elicitations":true}}
    • A read-only docker --context <existing-context> ps request using sandbox_permissions="require_escalated" was rejected by the approval policy before execution; no approval prompt appeared.
    • After permissions were reselected, one thread recorded on-request + auto_review. A different, newly created thread subsequently started with the granular policy above. That new thread later switched to on-request + user after its permissions were changed. This is evidence of differing initialization/selection behavior, not proof that changing one thread should change every other thread.
    • In a further fresh TUI session, the status bar showed granular. When asked to inspect only its injected permissions and available tools, the agent reported that sandbox approvals were disabled and that no request_permissions tool was available. This last observation is an agent/tool-list report captured in a screenshot, not an independently captured full tool-schema trace.
    • The inspected user config did not explicitly set an approval policy. The checked project config and standard /etc/codex/managed_config.toml and /etc/codex/requirements.toml paths were absent. This was not an exhaustive audit of all policy sources.

    Potential implementation gap in current main

    Static inspection at commit 80a8710546cfab76aa13503645fccc3af1e5ec35 found:

    1. projectless.rs can select the granular policy above for qualifying implicit projectless defaults. That function does not also enable the permission-request tool.
    2. The feature declaration still has request_permissions_tool defaulting to false.
    3. Tool registration adds RequestPermissionsHandler only when that feature is enabled.

    These independent gates appear capable of producing “legacy escalation disabled, replacement permission-request tool unavailable” unless another layer enables the tool. This is a candidate explanation, not a claim that every affected desktop/TUI session takes this exact path. I have not compiled or run a regression test against main.

    Requested improvements

    • Validate the policy/tool combination at thread creation: if a preset relies on request_permissions, make the supported request mechanism available, or clearly explain that permission requests are unavailable under the effective policy. Preserve managed restrictions.
    • Show the effective approval categories and their source in the permissions UI, so “Ask for approval” cannot misleadingly imply that command escalation is available.
    • Add regression coverage for fresh startup, permission reselection, resume, and a subsequent fresh thread, checking both the effective policy and the tools actually exposed to the model.

    Could maintainers confirm whether the projectless default and tool-feature gating are intended to be coupled, and track a fix for the unusable combination?

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

    CLIapp-serverbugsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions