Skip to content

Approved escalated commands still inherit restricted network policy in interactive CLI sessions #15309

Open

Description

@ignatremizov

What version of Codex CLI is running?

codex-cli 0.116.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.4 high

What platform is your computer?

Linux 6.17.0-19-generic x86_64 x86_64

What terminal emulator and version are you using (if applicable)?

Ghostty (TERM=xterm-ghostty), no tmux, no zellij

What issue are you seeing?

In an interactive Codex CLI session (the TUI) with Default permissions, a command that requires network access can still fail after I explicitly approve escalation.

The core bug is that the restricted network sandbox policy appears to still be applied to an approved escalated command.

Observed behavior:

  • the command is not allowlisted in ~/.codex/rules/default.rules
  • Codex shows an approval prompt for the command
  • I approve the prompt
  • the command still fails with a GitHub network error instead of running with working host network access

Error from the approved command, e.g. gh issue:

error connecting to api.github.com
check your internet connection or https://githubstatus.com

This is in the TUI, not exec, app, or app-server, although likely to be reproducible there.

Workarounds:

  • add the command prefix to ~/.codex/rules/default.rules
  • or run Codex in full access / dangerous mode so the command bypasses the restricted path entirely

That suggests the approval flow is not fully removing the restricted network policy on the retried command.

What steps can reproduce the bug?

  1. Start Codex CLI in default permissions mode.
  2. Ensure the target network command is not allowlisted in ~/.codex/rules/default.rules.
  3. In an interactive session, ask Codex to run a networked command against a public repo with required escalated permissions, for example:
gh issue list -R openai/codex --limit 3
  1. Observe that Codex shows an approval prompt for the command.
  2. Approve the prompt.
  3. Observe that the command still fails with:
error connecting to api.github.com
check your internet connection or https://githubstatus.com

Affected thread id:

  • 019d0aa4-3bfe-7100-a9df-9cf93b1d1397

What is the expected behavior?

Once the user explicitly approves the escalated command, the retried command should run without the restricted network sandbox policy.

In practice, an approved command that needs network access should be able to reach GitHub successfully instead of still failing with a sandbox-like network error.

Additional information

This appears related to the broader family of sandbox/network policy propagation issues, but this report is specifically about interactive approval flow:

  • the user is prompted
  • the user approves
  • the retried command still behaves as if restricted network policy is active

Workaround today is to either allowlist the command prefix or run Codex with full access.

Implementation / fix spec

Probable failure mode:

  • the approval flow correctly authorizes a retry without the filesystem sandbox wrapper
  • but the retried attempt still inherits the original restricted network policy and/or managed-network enforcement state
  • as a result, the command is retried in a partially unrestricted state instead of a truly unrestricted state

Concrete code paths that look involved:

  • codex-rs/core/src/tools/orchestrator.rs
    • the escalated retry path builds SandboxAttempt { sandbox: SandboxType::None, network_policy: turn_ctx.network_sandbox_policy, enforce_managed_network: has_managed_network_requirements, ... }
    • that means the retry drops the sandbox wrapper but still keeps the original network policy and managed-network flag
  • codex-rs/core/src/sandboxing/mod.rs
    • SandboxManager::transform(...) preserves network_policy even when sandbox == SandboxType::None
    • if the effective network policy remains restricted, it injects CODEX_SANDBOX_NETWORK_DISABLED=1
    • it also returns an ExecRequest that still carries the restricted network_sandbox_policy
  • codex-rs/core/src/tools/runtimes/shell/unix_escalation.rs
    • the shell runtime passes network_policy and enforce_managed_network into SandboxTransformRequest
    • then applies any network/proxy config from the resulting ExecRequest to the child environment

Expected implementation behavior:

  • when a command is explicitly approved for escalated execution outside the sandbox, the retry should clear both the sandbox wrapper and the restricted network policy for that retry
  • the retried execution should not preserve a restricted NetworkSandboxPolicy from the original turn if the approved action is intended to run unsandboxed
  • the retried execution should not keep managed-network enforcement enabled for that approved unsandboxed retry
  • the retried execution should not inject or preserve CODEX_SANDBOX_NETWORK_DISABLED=1 for that retry
  • proxy/env rewriting that is only appropriate for the restricted sandbox path should not remain active on the approved unsandboxed retry

Suggested implementation points:

  • audit the retry path in codex-rs/core/src/tools/orchestrator.rs where an approved command is rerun after a sandbox/network denial
  • make the approved retry derive both sandbox mode and effective network policy from the escalation decision, not only sandbox mode
  • update the transform/execution path in codex-rs/core/src/sandboxing/mod.rs so an approved unsandboxed retry cannot silently carry forward a restricted network policy
  • verify the shell execution path in codex-rs/core/src/tools/runtimes/shell/unix_escalation.rs does not reapply restricted-network env/proxy behavior on an approved unsandboxed retry
  • add regression coverage for interactive approval flow, not only allowlisted/trusted execpolicy flow

Acceptance criteria:

  • in a default-permissions interactive CLI session, a non-allowlisted networked command that triggers approval succeeds after the user approves escalation
  • the retried command does not see CODEX_SANDBOX_NETWORK_DISABLED=1 and can resolve and connect to network
    • behavior for commands that remain sandboxed is unchanged
  • existing allowlisted/trusted-command behavior and child/subagent behavior are not regressed

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    sandboxIssues related to permissions or sandboxing
    tool-callsIssues related to tool calling
    on Mar 20, 2026
  2. ignatremizov commented on Mar 20, 2026

    @ignatremizov
    Author

    Why the suggested issues are not exact duplicates:

    Also related:

    So my current read is:

    • #15298 may share the same root cause family and could end up being merged with this
    • #12919 is strongly related on the network-policy side
    • #15305, #14357, and #14978 are related sandbox/runtime-policy bugs, but not the same user-visible failure path
  3. Weijiang-Xiong commented on Mar 20, 2026

    @Weijiang-Xiong

    having similar issue here, codex asks 10 times when running some local python sanity checks ... quite disappointing

  4. removed
    CLIIssues related to the Codex CLI
    tool-callsIssues related to tool calling
    on Mar 20, 2026
  5. gulp commented on Jul 30, 2026

    @gulp

    Contrasting evidence from a newer Linux environment, investigated and drafted by OpenAI Codex CLI itself; the human account owner reviewed the conclusion and explicitly authorized posting this comment.

    This is not an exact reproduction of the reported failure: explicit escalation succeeds here. It may help separate two adjacent failure modes.

    Environment:

    • codex-cli 0.146.0
    • Arch Linux, kernel 7.0.10-arch1-1, x86_64, glibc 2.43
    • managed workspace-write sandbox with restricted networking
    • ~/.codex/rules/default.rules contains prefix_rule(pattern=["gh", "api"], decision="allow")
    • codex execpolicy check --rules ~/.codex/rules/default.rules gh api /user returns a matching rule with "decision":"allow"

    Observed:

    1. A gh api call issued through the default unified/code-mode nested execution path ran in the network-isolated sandbox and failed with error connecting to api.github.com.
    2. The same gh api operation succeeded when explicitly issued with escalated execution.

    Potentially relevant source discrepancy: codex-rs/core/src/tools/runtimes/shell/unix_escalation.rs says a policy-driven allow under SandboxPermissions::UseDefault should select unsandboxed execution. The regression test matched_prefix_rule_runs_unsandboxed_under_zsh_fork covers the zsh-fork runtime. Our observation suggests the unified/code-mode nested execution path may not apply the same policy-driven automatic-unsandbox behavior.

    So the distinction appears to be:

    • this issue: explicitly approved escalation can retain restricted networking;
    • this observation: policy-allowed default execution may remain sandboxed in one runtime path, while explicit escalation works.

    This may warrant separate regression coverage for allowlisted network commands through unified/code-mode nested execution. No repository code was modified during this investigation.

  6. foxylion commented on Jul 30, 2026

    @foxylion

    @gulp it would be interesting how your config.toml looks like. Especially how does the uses permission look like?

    In my case this only fails when relying on the experimental permission feature. And this is, as far as I know, the only way to reliably block access to certain files within the sandbox.

  7. gulp commented on Jul 30, 2026

    @gulp

    My case does not use the experimental [permissions] configuration, so it is probably adjacent rather than the same reproduction.

    User-level ~/.codex/config.toml:

    approvals_reviewer = "user"
    
    [projects."<redacted-project-path>"]
    trust_level = "trusted"

    There is no user-level approval_policy, sandbox_mode, [sandbox_workspace_write], [permissions], or permission profile configured.

    Project-level .codex/config.toml:

    [mcp_servers."<redacted-local-server>"]
    url = "http://127.0.0.1:<redacted>/..."

    The project file contains only local MCP declarations—no sandbox, approval, network, or permissions settings. There is also no project-level requirements.toml.

    The effective session policy was injected at runtime as a managed profile:

    sandbox_mode: workspace-write
    network: restricted
    filesystem: managed workspace-scoped read/write rules

    Separately, ~/.codex/rules/default.rules contains:

    prefix_rule(pattern=["gh", "api"], decision="allow")
    

    codex execpolicy check confirms that the rule matches. Therefore, this does not demonstrate the experimental-permissions failure you reported; it only shows similar behavior under a managed runtime profile.

    Thanks,
    gpt-5.6-sol

  8. zaccromero commented on Nov 15, 2026

    @zaccromero

    Reproduced on macOS in Codex Desktop with Codex CLI 0.169.0, with an important configuration-specific clarification discovered after inspecting current main.

    The active custom permission profile has:

    • explicit denied-read filesystem globs for **/.env and **/.env.*
    • managed networking enabled
    • only localhost and 127.0.0.1 in the domain allowlist

    In that profile, approved require_escalated commands failed with:

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

    The same happened for codex agents against ab.chatgpt.com, and for a nested codex exec attempt against api.openai.com. The equivalent Doppler command reached its service from the user's normal terminal.

    Current main already strips managed networking for ordinary approved escalation and includes coverage for unproxied escalated execution. However, because denied reads are active, the request takes the EscalatedSandboxWithRestrictions path. Current integration coverage intentionally keeps the owner network policy in that mode.

    So this reproduction should not be treated as proof that current main incorrectly preserves network restrictions for an otherwise unrestricted approved escalation. It instead highlights a UX/contract problem: the command is described and approved as require_escalated / “unsandboxed execution,” but security restrictions are intentionally retained without clearly explaining that the requested escalation is only partial or that an explicit domain grant is required.

    Expected UX in this configuration:

    • before approval, state that denied-read protections prevent a fully unsandboxed launch;
    • state that the owner-managed network allowlist will remain active;
    • identify the missing domain and the supported scoped remedy;
    • avoid presenting the approval as though it will bypass restrictions that cannot be removed.

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

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

    bugSomething isn't workingsandboxIssues related to permissions or sandboxing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions