codex icon indicating copy to clipboard operation
codex copied to clipboard

require_escalated approval does not disclose retained network policy during partial escalation

Open zaccromero opened this issue 2 weeks ago • 0 comments

What version of Codex CLI is running?

codex-cli 0.169.0

What subscription do you have?

Pro

Which model were you using?

Not relevant; this concerns command approval and sandbox policy.

What platform is your computer?

macOS on Apple silicon, using Codex Desktop.

What issue are you seeing?

When a custom permission profile contains denied-read filesystem entries, an explicitly approved require_escalated command uses the partial-escalation path that retains filesystem protections. Current behavior also retains the owner-managed network allowlist.

The security behavior appears intentional, but the approval contract does not disclose it:

  • the tool schema describes require_escalated as “unsandboxed execution”;
  • Codex asks the user to approve escalation;
  • the user approves;
  • the command remains subject to the owner network allowlist;
  • the command then fails with an allowlist error.

Example error after approval:

Network access to "api.doppler.com" was blocked: domain is not on the allowlist for the current sandbox mode.

The same session reproduced this with Codex's own management CLI against ab.chatgpt.com and a nested codex exec attempt against api.openai.com.

The active profile intentionally had:

  • workspace writes;
  • denied-read globs for **/.env and **/.env.*;
  • managed networking enabled;
  • only loopback domains in the allowlist.

The equivalent third-party command reached its service from the user's normal terminal, confirming this was the effective Codex policy rather than host connectivity.

What steps can reproduce the bug?

  1. Configure a permission profile with a denied-read entry and a limited managed-network domain list:
default_permissions = "coding"

[features]
network_proxy = true

[permissions.coding]
extends = ":workspace"

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

[permissions.coding.network]
enabled = true

[permissions.coding.network.domains]
"localhost" = "allow"
"127.0.0.1" = "allow"
  1. Restart Codex with that profile.
  2. Request a command that needs an unlisted public domain and explicitly uses:
{
  "sandbox_permissions": "require_escalated",
  "justification": "Run the authorized network command."
}
  1. Approve the command.
  2. Observe that the command still receives the managed-domain allowlist rejection.

Current main explains the implementation behavior:

  • sandbox_override_for_first_attempt selects EscalatedSandboxWithRestrictions when denied reads must remain enforced.
  • ToolOrchestrator keeps managed_network_active on that attempt.
  • The ESCALATED_DENY_READ integration case in codex-rs/core/tests/suite/network_approval.rs expects the owner network policy to remain enforced.

What is the expected behavior?

Do not silently weaken denied-read or owner network policy.

Instead, before asking for approval:

  1. State that the requested escalation cannot be fully unsandboxed because denied-read protections must remain active.
  2. State that the owner-managed network allowlist will remain active.
  3. Identify that approval alone will not grant the requested domain.
  4. Point to the supported scoped remedy, such as adding that domain to the active permission profile.
  5. Record the effective execution mode as partial/restricted escalation rather than presenting it as ordinary unsandboxed require_escalated.

The tool schema and approval UI should not promise “unsandboxed execution” when the selected execution path intentionally preserves restrictions.

Additional information

Related but distinct reports:

  • #49344 covers retained filesystem restrictions and missing diagnostics for browser tests.
  • #15309 covers approved escalated commands retaining network restrictions more generally.

This report is specifically about accurately disclosing the combined denied-read plus owner-network behavior that current main appears to enforce intentionally.

No credentials, secret values, private repository paths, or device identifiers are included.

zaccromero avatar Nov 15 '26 03:11 zaccromero

One source-specific implementation boundary beyond changing the "unsandboxed" wording: the present approval is emitted before the effective escalation and retained networking mode are computed. A UI patch that merely reports the execution result after approval cannot fix this misleading consent.

On current main:

  1. ToolOrchestrator::run builds ApprovalContext with network_approval_context: None and awaits session.request_approval(...) in the NeedsApproval path (roughly L164–231). Only after that approval returns does it compute sandbox_override_for_first_attempt (L237), its EscalatedSandboxWithRestrictions profile, then managed_network_active (roughly L303–330) and the SandboxAttempt (L377). So today's approval boundary does not carry a snapshot of the effective execution authority. The generic shell tool schema simultaneously promises require_escalated is "unsandboxed execution".
  2. sandbox_override_for_first_attempt deliberately distinguishes denied-read restrictions from a true bypass. The orchestrator preserves owner-managed networking for the partial path. The existing ESCALATED_DENY_READ integration scenario is an important positive test that this policy remains enforced, not a test that the approver was accurately informed.

Proposed narrow contract: derive a read-only EffectiveEscalationPreview from the same selected turn environment, request, denied-read policy and owner-network policy before constructing an approval request. Convey to the human approver the effective mode (full_bypass versus partial_restricted), that denied reads and/or owner network restrictions remain, and the specific attempted host's known allow/deny status where that host can reliably be determined. Keep the full owner allowlist private; do not show a guessed host or claim that command approval extends the allowlist. After approval, the selected execution attempt must be consistent with that preview; if a live policy/environment change makes it differ, require an updated review or reject, never silently widen authority or execute under a different undisclosed contract.

Acceptance controls:

  • Denied reads + owner network denied + explicit require_escalated: before approval, show restricted execution and that this approval alone cannot allow the target domain; rejecting does not run the command; approving cannot bypass the owner policy. Preserve the current 403 isolation test.
  • Same denied reads, but allowed target domain: still label partial_restricted, command can proceed per policy; don't falsely tell the approver all networking is blocked.
  • No denied reads with an otherwise eligible full-bypass path: disclose the actually selected mode, not a hard-coded "all escalations are partial" banner. Distinguish any independent owner proxy requirement.
  • Unknown or dynamically constructed domain: state that reachability cannot be guaranteed from approval; do not infer a policy grant. Check command execution after policy changes against the versioned preview.
  • Assert that the approval event payload/visible human text, tool schema, execution mode, and resulting enforcement agree. A post-run error message by itself does not satisfy the pre-consent test.

Original-theory connection, not an endorsement claim: this engineering split between a recorded assent and the conditions under which it remains valid is an application of Nakagawa Master's 合意の記憶 — 不可逆な社会誤作動を防ぐ最小構造 (causal reason, parties/context, re-agreement). The source is a conceptual origin for this acceptance framing; the specific Rust behavior and tests above are from Codex, and I do not claim Codex developers have read, accepted or adopted the original.

Source review only; I have not executed the reporter's macOS profile or a Codex integration test.

Implementation bridge — effective escalation plan before consent

The concrete source seam is ToolOrchestrator: compute the execution/network escalation to be approved before asking for approval, then verify it is still the plan at launch. Minimal JavaScript reference for the preflight boundary, not a native Rust patch:

function approvalPreflight(request, effectivePlan, consent) {
  if (!consent?.hostVerified) return 'request-approval';
  if (consent.requestId !== request.id ||
      consent.planFingerprint !== effectivePlan.fingerprint)
    return 'reapprove';
  if (consent.decision !== 'allow') return 'deny';
  return 'launch-with-verified-plan';
}

Tests: policy allows retained network while UI only says “unsandboxed” → consent fingerprint must include the actual network/sandbox scope; changing that scope after consent → reapprove, not silently broaden execution; a different request ID cannot reuse an earlier approval; explicit denial stays denied. The fingerprint must be computed over a canonical host-owned plan containing effective sandbox restrictions, writable roots and retained network mode, and rechecked against what will launch with no time-of-check gap. The real fix requires moving/plumbing the effective-plan construction ahead of the request and binding launch to it; this is an executable decision core, not tested product code.

Nakagawa-master avatar Nov 15 '26 07:11 Nakagawa-master