You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
0.152.0 Windows: --ignore-user-config leaves exec with no usable sandbox — every command "rejected: blocked by policy" (regression from 0.147.0) #42172
CLIIssues related to the Codex CLIbugSomething isn't workingexecIssues related to the `codex exec` subcommandsandboxIssues related to permissions or sandboxingwindows-osIssues related to Codex on Windows systems
On Windows, codex exec with --ignore-user-config and --sandbox read-only refuses every shell command the model attempts — including plain reads like rg --version wrapped in powershell.exe -Command — with:
exec_command failed for `"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" -Command 'rg --version'`:
CreateProcess { message: "Rejected(\"... rejected: blocked by policy\")" }
The identical invocation executes fine on 0.147.0. The process still exits 0 and the model answers from the prompt alone, so automated callers get a plausible-looking response produced without the model having read anything.
Minimal reproduction (verified)
Windows 11 Pro (10.0.26200), codex-cli 0.152.0 standalone, Codex desktop app installed (so ~/.codex/config.toml contains [windows] sandbox = "elevated"):
codex exec -C <scratch-dir> --skip-git-repo-check --ignore-user-config --sandbox read-only ^
-c model_reasoning_effort=low --json "Run the command: rg --version . Report its stdout, or the exact error if it cannot run."
→ every command rejected "blocked by policy", exit 0.
Each of the following makes the same invocation work:
same command on codex-cli 0.147.0;
removing --ignore-user-config (the user config loads, including [windows] sandbox = "elevated");
keeping --ignore-user-config and adding -c windows.sandbox="elevated".
What it is not (bisected)
Each of these was toggled independently on 0.152.0 with no effect: --ignore-rules, -c approval_policy="never", --ephemeral, --sandbox workspace-write instead of read-only, and a fully inherited vs. sanitized environment. codex sandbox cmd.exe /c "echo OK" also succeeds, so the restricted-token machinery itself launches processes.
Root cause (apparent)
0.152.0 moved Windows command execution onto the elevated sandbox, selected by [windows] sandbox = "elevated" in the user config. --ignore-user-config drops that selector, and instead of falling back to a working path (as 0.147.0 did) or failing loudly, the policy layer rejects every command.
--ignore-user-config is the documented way for automation to run hermetically — a config-suppressing flag silently disabling all command execution seems unintended.
Suggestions
When the user config is ignored on Windows, default the exec sandbox to something usable, or emit a startup error naming the missing setting rather than rejecting each command as "blocked by policy".
Consider a nonzero exit (or a machine-readable marker in --json output) when every command execution in a turn was refused — exit 0 makes this invisible to callers.
Possibly related: #38898, #40047 (elevated-sandbox helper failures with different symptoms).
Additional reproduction on Windows with an isolated CODEX_HOME (rather than --ignore-user-config). This appears related to #42172; I cannot yet confirm an identical root cause.
Codex CLI: 0.158.0-alpha.2.1.
The normal desktop profile has [windows] sandbox = "elevated". A separate profile for ephemeral background codex exec calls initially had no config.toml.
With that separate profile, a prompt asking the model to run only Get-Location under --sandbox read-only --ephemeral --json produced CreateProcess ... rejected: blocked by policy for PowerShell. The CLI exited with code 0, while the JSON stream contained no successful command_execution item. Our caller caught this by checking for a completed command item instead of trusting the process exit code.
Adding only project trust to the separate profile did not change the result. Changing the CLI sandbox from read-only to workspace-write did not change it either.
In a temporary test, adding [windows] sandbox = "elevated" to the separate profile removed the immediate policy rejection, but the model received no completed command result; the invocation was cancelled after several minutes. The temporary configuration was removed. This is not a confirmed workaround.
Expected: a supported isolated profile should either execute the permitted read-only command or fail with a nonzero process status and a machine-readable reason. Actual: the initial policy denial still allowed a successful process exit, so an automation must inspect JSON command events to detect it.
All paths and account details have been omitted. No authentication material is included.
I can confirm the windows.sandbox="elevated" workaround, but in a hermetic environment it exposed a second Windows failure.
With codex-cli 0.153.4:
--ignore-user-config --sandbox read-only with no explicit Windows selector -> CreateProcess ... rejected: blocked by policy.
Adding only windows.sandbox="elevated" -> process creation succeeds, but bundled pwsh crashes during InitialSessionState -> GetSaferPolicy with Win32Exception 126 before the requested command runs.
The sandbox environment had no SystemRoot.
Keeping --ignore-user-config, read-only isolation, inherit="none", and explicit elevated backend, then adding only:
SystemRoot=C:\Windows
made the hermetic codex exec read-only scratch-file probe pass.
So on this machine the minimal working explicit configuration was:
No Full Access or user-config loading was required. The important point is that the elevated selector fixes the blanket policy rejection, but a sanitized environment can still fail later if SystemRoot is absent.
CLIIssues related to the Codex CLIbugSomething isn't workingexecIssues related to the `codex exec` subcommandsandboxIssues related to permissions or sandboxingwindows-osIssues related to Codex on Windows systems
Activity
github-actions commentedon Sep 2, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
fix(codex_ro): 2.4.0 — der Reviewer konnte unter Windows seit Wochen …
Merge claude/codex-sandbox-fix-20260923: Codex sandbox cause and tool…
manfred1591-lang commentedon Sep 27, 2026
Additional reproduction on Windows with an isolated
CODEX_HOME(rather than--ignore-user-config). This appears related to #42172; I cannot yet confirm an identical root cause.0.158.0-alpha.2.1.[windows] sandbox = "elevated". A separate profile for ephemeral backgroundcodex execcalls initially had noconfig.toml.Get-Locationunder--sandbox read-only --ephemeral --jsonproducedCreateProcess ... rejected: blocked by policyfor PowerShell. The CLI exited with code 0, while the JSON stream contained no successfulcommand_executionitem. Our caller caught this by checking for a completed command item instead of trusting the process exit code.read-onlytoworkspace-writedid not change it either.[windows] sandbox = "elevated"to the separate profile removed the immediate policy rejection, but the model received no completed command result; the invocation was cancelled after several minutes. The temporary configuration was removed. This is not a confirmed workaround.Expected: a supported isolated profile should either execute the permitted read-only command or fail with a nonzero process status and a machine-readable reason. Actual: the initial policy denial still allowed a successful process exit, so an automation must inspect JSON command events to detect it.
All paths and account details have been omitted. No authentication material is included.
rza255 commentedon Sep 28, 2026
I can confirm the
windows.sandbox="elevated"workaround, but in a hermetic environment it exposed a second Windows failure.With codex-cli 0.153.4:
--ignore-user-config --sandbox read-onlywith no explicit Windows selector ->CreateProcess ... rejected: blocked by policy.windows.sandbox="elevated"-> process creation succeeds, but bundled pwsh crashes duringInitialSessionState -> GetSaferPolicywith Win32Exception 126 before the requested command runs.SystemRoot.--ignore-user-config, read-only isolation,inherit="none", and explicit elevated backend, then adding only:made the hermetic
codex execread-only scratch-file probe pass.So on this machine the minimal working explicit configuration was:
No Full Access or user-config loading was required. The important point is that the elevated selector fixes the blanket policy rejection, but a sanitized environment can still fail later if
SystemRootis absent.