Approved escalated commands still inherit restricted network policy in interactive CLI sessions
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?
- Start Codex CLI in default permissions mode.
- Ensure the target network command is not allowlisted in
~/.codex/rules/default.rules. - 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
- Observe that Codex shows an approval prompt for the command.
- Approve the prompt.
- 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.rsSandboxManager::transform(...)preservesnetwork_policyeven whensandbox == SandboxType::None- if the effective network policy remains restricted, it injects
CODEX_SANDBOX_NETWORK_DISABLED=1 - it also returns an
ExecRequestthat still carries the restrictednetwork_sandbox_policy codex-rs/core/src/tools/runtimes/shell/unix_escalation.rs- the shell runtime passes
network_policyandenforce_managed_networkintoSandboxTransformRequest - then applies any network/proxy config from the resulting
ExecRequestto 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
NetworkSandboxPolicyfrom 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=1for 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.rswhere 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.rsso 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.rsdoes 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=1and 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
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Why the suggested issues are not exact duplicates:
That issue is about
default.rules/ execpolicyallownot being honored for sandbox-escaping commands, primarily reproduced on Windows and focused on write access under.git.This issue is about an interactive CLI approval flow on Linux where the user is explicitly prompted, approves escalation, and the retried command still appears to inherit restricted network policy.
The likely underlying bug may be related, but the reported trigger and observed failure mode are different.
This issue does not involve subagent spawning or review-mode inheritance. It is about a command in the active interactive session still behaving as network-restricted after explicit approval.
Again, that is a child-agent/runtime inheritance bug. This report is not about sub-agents. It is about the main TUI session's approved command retry path.
This report is not about localhost specifically, and not primarily about UX clarity. It is about the actual execution behavior after approval: the approved retried command still fails as if restricted network policy remains active.
Also related:
So my current read is:
having similar issue here, codex asks 10 times when running some local python sanity checks ... quite disappointing
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.07.0.10-arch1-1, x86_64, glibc 2.43~/.codex/rules/default.rulescontainsprefix_rule(pattern=["gh", "api"], decision="allow")codex execpolicy check --rules ~/.codex/rules/default.rules gh api /userreturns a matching rule with"decision":"allow"Observed:
gh apicall issued through the default unified/code-mode nested execution path ran in the network-isolated sandbox and failed witherror connecting to api.github.com.gh apioperation succeeded when explicitly issued with escalated execution.Potentially relevant source discrepancy:
codex-rs/core/src/tools/runtimes/shell/unix_escalation.rssays a policy-driven allow underSandboxPermissions::UseDefaultshould select unsandboxed execution. The regression testmatched_prefix_rule_runs_unsandboxed_under_zsh_forkcovers 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 may warrant separate regression coverage for allowlisted network commands through unified/code-mode nested execution. No repository code was modified during this investigation.
@gulp it would be interesting how your
config.tomllooks 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.
My case does not use the experimental
[permissions]configuration, so it is probably adjacent rather than the same reproduction.User-level
~/.codex/config.toml:There is no user-level
approval_policy,sandbox_mode,[sandbox_workspace_write],[permissions], or permission profile configured.Project-level
.codex/config.toml: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:
Separately,
~/.codex/rules/default.rulescontains:codex execpolicy checkconfirms 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