Windows: PowerShell fails with error 8009001d (NTE_PROVIDER_DLL_FAIL) in sandbox
Description
On Windows 11 (10.0.26200), Codex CLI v0.111.0 always uses powershell.exe as the shell for command execution. However, PowerShell fails to start with error 8009001d (NTE_PROVIDER_DLL_FAIL - cryptographic provider DLL initialization failure) when spawned by Codex.
Environment
- OS: Windows 11 Pro 10.0.26200
- Codex CLI: v0.111.0
- PowerShell: 5.1.26100.7705
- Node: via npm global install
Steps to Reproduce
- Install codex-cli on Windows
- Run any command:
````
codex exec --full-auto "echo hello"
- Observe that all PowerShell invocations fail with:
````
Windows PowerShell のキャリブレーションがエラー 8009001d で失敗しました
Key Findings
powershell.exe -NoProfile -Command "echo test"works fine when called from bash/cmd directlycodex sandbox windows -- powershell.exe -NoProfile -Command "echo test"fails with 8009001dcodex sandbox windows -- cmd.exe /c "echo test"works fine- Error persists with ALL sandbox modes:
read-only,workspace-write,danger-full-access - Error persists with both
[windows] sandbox = "elevated"and"unelevated"config - Error persists with
--dangerously-bypass-approvals-and-sandbox
Root Cause Analysis
The Windows restricted token created by Codex's sandbox (even in full-access mode) appears to strip privileges or SIDs required by PowerShell's cryptographic service provider initialization. Error 0x8009001d (NTE_PROVIDER_DLL_FAIL) indicates the RSA/AES crypto provider DLL cannot initialize under the restricted process token.
Since cmd.exe doesn't require cryptographic services, it works fine under the same restricted token.
Current Workaround
The model (gpt-5.3-codex) can self-correct by falling back to cmd.exe /c commands after PowerShell failure, but this wastes tokens on every session. Adding instructions to AGENTS.md to prefer cmd.exe helps.
Expected Behavior
Either:
- Codex should use
cmd.exeas the default shell on Windows (since PowerShell requires crypto providers that the restricted token blocks) - Or the restricted token should preserve the privileges needed for PowerShell crypto initialization
- Or provide a config option to select the shell (e.g.,
[windows] shell = "cmd")
Feature Flags
Relevant feature flags from codex features list:
elevated_windows_sandbox: removedexperimental_windows_sandbox: removedpowershell_utf8: stable (true)shell_tool: stable (true)
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I've implemented a fix for this issue. The root cause is in shell.rs where
default_user_shell() hardcodes ShellType::PowerShell on Windows. The fix
changes Session::new in codex.rs to use ShellType::Cmd when
windows_sandbox_level != Disabled.
The fix includes regression tests and cargo fmt passes:
https://github.com/Sequela02/codex/tree/fix/windows-powershell-8009001d
I can reproduce this on Windows as well, and I found one additional data point that may help narrow the problem down.
Environment:
codex-cli 0.126.0-alpha.8~/.codex/config.toml:The important part is that the Windows sandbox itself is not completely broken.
cmd.exeworks inside the sandbox:Output:
Windows PowerShell 5.1 fails inside the same sandbox:
Result:
However, PowerShell 7 works inside the same Codex Windows sandbox:
Output:
Output:
So on this machine the behavior is:
This seems to point specifically at Windows PowerShell 5.1 initialization under the Codex Windows restricted token/sandbox, rather than a general sandbox failure or a broken PowerShell installation.
From a user-impact perspective, the built-in tool execution path still appears to use
powershell.exe, soshell_commandfails even thoughcmd.exeandpwsh.exeare viable in the same sandbox. A practical workaround would be to allow Windows users to configure the tool execution shell path, for example topwsh.exeorcmd.exe, until the underlying Windows PowerShell 5.1 sandbox issue is fixed.I would prefer a proper fix in Codex if possible, but exposing a configurable Windows tool shell would also unblock this class of failures.
I seem to be having the same issue. Right now, I can't use PowerShell with either the Codex app or the Codex CLI.
Codex -> PowerShell crashes during initialization. However, it works fine on my machine with both PowerShell 5.1 and 7.
GitHub Issue #14057 Comment (English)
Additional evidence: PowerShell 7 comparison + Node direct CSPRNG test
Further diagnosis on Windows 11 + Codex Desktop
26.721.4979.0(MSIX, Microsoft Store) confirms the failure scope is broader than initially expected.Environment
OpenAI.Codex_26.721.4979.0_x64__2p2nqsd0c76g0(Microsoft Store MSIX)[windows].sandbox = "unelevated", no custom[shell_environment_policy]C:\Program Files\PowerShell\7\pwsh.exe)Test 1: PowerShell 5.1 inside Codex sandbox — FAILED
Result: exit code
-65536, error8009001d(NTE_PROVIDER_DLL_FAIL).Test 2: PowerShell 7 inside Codex sandbox — SUCCESS
Result: output
pwsh7-ok, exit code0.Test 3: PowerShell 7 LanguageMode
Result:
ConstrainedLanguage, exit code0.Test 4: System Node directly inside Codex sandbox — CSPRNG CRASH
Without PowerShell wrapper, directly launching system Node in the sandbox:
Result:
Test 5: Codex UI Full Access mode — STILL FAILS
Switched to Full Access in Codex UI, ran cmd / PowerShell / Node minimal tests — all
8009001d / -65536.ProcMon evidence summary
ProcMon captured PowerShell 5.1 launching inside the sandbox:
RegCreateKeywriteHKCU\Software\Policies\Microsoft\SystemCertificates\CA→ ACCESS DENIED (Read/Write, Delete)RegCreateKeywriteHKLM\SOFTWARE\Microsoft\SystemCertificates\CA→ ACCESS DENIEDRegCreateKeywriteHKLM\SOFTWARE\Microsoft\SystemCertificates\ROOT→ ACCESS DENIED8009001dFull .PML (583 MB) and CSV (264 MB) retained. Available via private read-only link if a maintainer requests it. Not uploading publicly to avoid leaking username/path/environment variables.
Conclusions
8009001d.ncrypto::CSPRNG(nullptr, 0), exit 134) — proving the issue is not limited to PowerShell 5.1; Codex's restricted context also has a Node/CNG compatibility problem.Requests
pwsh.exeor configurable agent shell (ref #16579).ncrypto::CSPRNGassertion failure under restricted context.Reproduction steps
config.toml:[windows].sandbox = "unelevated"codex sandbox "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command 'echo ok'→ exit -65536codex sandbox "C:\Program Files\nodejs\node.exe" -e "console.log(require('crypto').randomBytes(16).toString('hex'))"→ exit 134 (CSPRNG)codex sandbox "C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -Command 'echo ok'→ exit 0 ✅Related issues