Windows elevated sandbox setup helper hits os error 206 when Base64 setup payload exceeds CreateProcessW limit
What version of Codex is running?
codex-cli 0.144.1
What platform is your computer?
Microsoft Windows 11, 10.0.26200.0, x64.
What issue are you seeing?
With the elevated Windows sandbox, even a minimal sandboxed command such as Get-Location fails before the target command starts.
Sanitized error:
windows sandbox: orchestrator_helper_launch_failed: setup refresh failed to launch helper:
helper=codex-windows-sandbox-setup.exe
error=The filename or extension is too long. (os error 206)
The corresponding sanitized sandbox log entry is:
setup refresh: spawning <CODEX_INSTALL>\codex-windows-sandbox-setup.exe
(cwd=C:\Users\<USER>, payload_len=40616)
No complete sandbox log is attached because it contains private historical workspace paths. No secrets or .sandbox-secrets data are included here.
Why this appears to be an argv-size failure
Read-only local diagnostics found:
- Setup helper path length: approximately 176 characters.
- Process
PATHlength: approximately 3,201 characters. - Total process environment block: approximately 6,475 characters.
- Logged Base64 setup payload length: 40,616 characters.
- The local capability ledger contained 669 path-scoped writable-root mappings. This is evidence of broad root expansion, but the ledger itself does not appear to be the direct payload input.
Microsoft documents a maximum CreateProcessW command-line length of 32,767 characters, including the terminating null:
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
Windows error 206 is ERROR_FILENAME_EXCED_RANGE:
https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
In the v0.144.1 source, setup refresh:
- builds an
ElevationPayloadcontaining read/write/deny roots, - serializes it to JSON,
- Base64-encodes the JSON,
- passes the complete Base64 string as one process argument with
cmd.arg(&b64).
The same source expands a user-profile root into individual top-level profile entries, which can make the setup payload very large on a long-lived development profile:
https://github.com/openai/codex/blob/rust-v0.144.1/codex-rs/windows-sandbox-rs/src/setup.rs#L383-L430
Because the logged payload alone is already 40,616 characters, this looks like a Windows command-line transport limit rather than a genuinely overlong executable or workspace path.
Steps to reproduce
- Use Windows with an established user profile containing many top-level files/directories.
- Configure the native Windows sandbox as
elevated. - Start a session whose effective workspace/read-write permissions include the user-profile root (
C:\Users\<USER>). - Run any minimal sandboxed command, such as
Get-Location. - Observe that setup refresh fails while launching
codex-windows-sandbox-setup.exe, before the requested command executes. - Inspect
CODEX_HOME\.sandbox\sandbox.<date>.log; the failing entry reports a setuppayload_lenabove 32,767.
Expected behavior
The setup helper payload should not depend on the Windows process command-line limit.
Possible fixes:
- transport the serialized payload through stdin, a temporary file, a named pipe, or another bounded IPC mechanism;
- reject oversized setup payloads before process creation with an actionable diagnostic;
- compact ancestor/descendant roots where that preserves the permission model;
- add a
codex doctorsmoke test that launches the same setup-refresh helper path used by actual sandboxed commands.
Workarounds observed
- A narrow repository CWD alone did not reduce the elevated setup payload in a controlled
:workspaceprobe; it remained about 40.6 KB. A narrow repository root is still required with theunelevatedworkaround because using the complete user profile as that sandbox root producedSetTokenInformation(TokenDefaultDacl) failed: 1344. [windows] sandbox = "unelevated"avoids this elevated setup-helper launch path, with the documented reduction in isolation strength.
Related reports
- #31511 — false Windows error 206 under a restricted permission profile
- #17107 and #15003 — Windows argv transport causing error 206 for large patch payloads
- #24098 — elevated setup-refresh helper launch failures with a different Win32 error
- #31140 — broad user-profile workspace roots and persistent path-scoped capability mappings
I did not find an existing report combining orchestrator_helper_launch_failed, setup payload_len above 32,767, and Win32 error 206.
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Follow-up: controlled elevated/unelevated comparison
I ran the same minimal
Get-Locationprobe using the built-in:workspacepermission profile.Results:
elevated, user-profile CWD: failed with error 206,payload_len=40640.elevated, process CWD changed to a narrow repository: still failed with error 206,payload_len=40668.unelevated, narrow repository A: succeeded, exit 0.unelevated, associated worktree B: succeeded, exit 0.unelevated, complete user-profile root: failed with the distinct errorSetTokenInformation(TokenDefaultDacl) failed: 1344.Correction to the initial report: changing only the CWD to a narrow repository is not sufficient to shrink the elevated setup payload. Based on
gather_full_read_roots_for_permissions, the:workspacefull-disk-readable shape appears to continue adding top-level profile entries independently of the repository CWD.The narrow repository root remains important for the unelevated workaround because applying the permission/token model to the entire user profile hits the separate 1344 boundary.
The local mitigation was therefore:
plus reopening work from an exact repository/worktree root rather than the complete user profile.
codex doctor --jsonremains overall OK, and both repository probes pass.Reproduced on
codex-cli 0.146.0/windows-x86_64on 2026-08-05.Minimal direct repro:
Result:
The sandbox log records
payload_len=38240. The same 38,240-byte payload failed with both the npm-distribution helper path and the shorter Codex app helper path, so shortening the helper path does not address this reproduction.Additional diagnostics:
[windows] sandbox = "elevated"(the documented recommended mode).codex doctor --summary --no-color --asciireports17 ok | 1 idle | 0 warn | 0 failand says the sandbox is healthy, despite the direct sandbox command failing immediately.codex exec --ignore-user-configavoided this setup-helper failure, which suggests the expanded configured capability/read-root state contributes to the oversized payload.--dangerously-bypass-approvals-and-sandboxallowed the same read-only agent workload to complete, confirming the workload and target executable were otherwise healthy.windows.sandbox="unelevated"fallback did not provide a viable workaround here: even directwhoami.exeandharbor.exe search-statusprobes exited 127 without output.This supports the proposed fixes in the issue: transport setup state via stdin/temp file rather than argv, and make
codex doctorexecute the real setup-refresh path and fail when it cannot launch.Reproduced on
codex-cli0.145.0 and 0.144.1, Windows 11 Pro 26100.I think I can pin down the payload input, which the original report left open ("the ledger itself does not appear to be the direct payload input").
The payload scales with the number of top-level entries in the home directory
Decisive test — point
USERPROFILEat an empty directory and re-run the same command:| condition |
payload_len||---|---|
| home with 725 top-level entries | 33,232 |
|
USERPROFILE→ empty directory | 756 |A 32,476-byte difference attributable solely to home-directory contents. Empirically each top-level entry costs roughly 46 bytes of the fixed 32,767
CreateProcessWbudget, so the ceiling is hit at roughly 700 entries regardless of what those entries are.Ruled out
Each tested individually, none made a meaningful difference:
config.toml— removed the file entirely;payload_lenunchanged at 33,232.PATH— trimmed 2,048 → 110 chars; unchanged.HKCU\Environment+ system env total ~3.4 KB.failed to launch setup helper (non-elevated), i.e. the elevated path falls through to the same oversized spawn. (Matches @Faust7777777's elevated/unelevated comparison.)setup_marker.json— moving it aside changes the failure toShellExecuteExW ... 1223(UAC auto-declined under automation) but never resolves the 206.Workaround that actually works
Reduce the top-level entry count in the home directory. I deleted 61 empty leftover directories (abandoned
git worktreestubs), taking the count 725 → 664, and Codex recovered immediately on the same CLI version that had been failing seconds earlier. No reinstall, no config change, no elevation.This also explains the "worked yesterday, broken today" pattern: the home directory silently crosses the threshold and every invocation fails at once, in every repo.
Two suggestions
I can independently reproduce this issue on a Windows development workstation, and in my case the setup payload is significantly larger than the original report.
Independent reproduction: ~347K setup payload
Environment:
Observed failure:
The important part is the measured payload size:
This is not marginally above the Windows
CreateProcessWcommand-line limit. It is approximately 10× the 32,767-character limit.Local root-cause evidence
I investigated what was expanding the payload.
The Windows user profile contained approximately:
Of those, approximately:
Read-only diagnostics showed approximately:
The simulated size and the actual Codex sandbox log payload size are therefore extremely close.
This strongly supports the analysis in this issue: expansion of the user-profile root into many top-level entries can massively amplify
ElevationPayload, after which JSON + Base64 encoding makes the payload too large to transport through a single process argument.This is not a repository path-length problem
In this environment:
git core.longpathsis unrelated.CreateProcessWcommand-line limit.The failure occurs while launching:
before the requested PowerShell/process command actually executes.
Operational impact
This is more than an unusual path-length edge case.
On a long-lived Windows development workstation, the user profile can naturally accumulate a large number of top-level entries. If Codex expands those entries into the sandbox setup payload, payload size becomes dependent on unrelated contents of the developer's Windows profile.
In our case, this makes the elevated Windows sandbox effectively unusable, including for automated AI coding/orchestration workflows that require strong filesystem/network isolation.
The available workaround of moving away from the elevated sandbox means accepting weaker isolation, which is not an acceptable long-term solution for security-sensitive automated development workflows.
Suggested architectural fix
I agree with the proposed fixes in the original report.
The serialized
ElevationPayloadshould ideally not be transported as a single argv value.For example:
I would also recommend adding a deterministic regression test where the serialized setup payload is deliberately larger than 32,767 characters.
For example:
That would prevent this class of Windows argv-size regression from returning.
Why I think this deserves priority
The original report demonstrated failure at:
This independent reproduction reaches approximately:
So this does not appear to be a narrow boundary condition.
The current architecture allows the setup payload to grow far beyond the Windows process command-line limit based on the contents of an established developer profile.
For teams using Codex on native Windows with elevated sandboxing as part of automated coding workflows, this can become a complete blocker rather than an intermittent failure.
I can provide additional sanitized diagnostics or run a targeted test against a candidate fix if that would help.
I can independently reproduce this issue on a Windows development workstation, and in my case the setup payload is significantly larger than the original report.
Independent reproduction: ~347K setup payload
Environment:
Observed failure:
The important part is the measured payload size:
This is not marginally above the Windows
CreateProcessWcommand-line limit. It is approximately 10× the 32,767-character limit.Local root-cause evidence
I investigated what was expanding the payload.
The Windows user profile contained approximately:
Of those, approximately:
Read-only diagnostics showed approximately:
The simulated size and the actual Codex sandbox log payload size are therefore extremely close.
This strongly supports the analysis in this issue: expansion of the user-profile root into many top-level entries can massively amplify
ElevationPayload, after which JSON + Base64 encoding makes the payload too large to transport through a single process argument.This is not a repository path-length problem
In this environment:
git core.longpathsis unrelated.CreateProcessWcommand-line limit.The failure occurs while launching:
before the requested PowerShell/process command actually executes.
Operational impact
This is more than an unusual path-length edge case.
On a long-lived Windows development workstation, the user profile can naturally accumulate a large number of top-level entries. If Codex expands those entries into the sandbox setup payload, payload size becomes dependent on unrelated contents of the developer's Windows profile.
In our case, this makes the elevated Windows sandbox effectively unusable, including for automated AI coding/orchestration workflows that require strong filesystem/network isolation.
The available workaround of moving away from the elevated sandbox means accepting weaker isolation, which is not an acceptable long-term solution for security-sensitive automated development workflows.
Suggested architectural fix
I agree with the proposed fixes in the original report.
The serialized
ElevationPayloadshould ideally not be transported as a single argv value.For example:
I would also recommend adding a deterministic regression test where the serialized setup payload is deliberately larger than 32,767 characters.
For example:
That would prevent this class of Windows argv-size regression from returning.
Why I think this deserves priority
The original report demonstrated failure at:
This independent reproduction reaches approximately:
So this does not appear to be a narrow boundary condition.
The current architecture allows the setup payload to grow far beyond the Windows process command-line limit based on the contents of an established developer profile.
For teams using Codex on native Windows with elevated sandboxing as part of automated coding workflows, this can become a complete blocker rather than an intermittent failure.
I can provide additional sanitized diagnostics or run a targeted test against a candidate fix if that would help.
Additional real-world impact from the same machine:
This issue now blocks even basic Git maintenance workflows in Codex.
I asked Codex to fast-forward a completed feature branch into local main. Before it could execute git status, git merge-base, or git merge --ff-only, the Windows sandbox helper failed with:
orchestrator_helper_launch_failed
os error 206
I restarted/retried the Codex workflow and received the same failure again, still before PowerShell launched.
So this is not limited to unusual sandbox setup operations. Once the payload reaches this size, Codex cannot execute even trivial shell commands required for normal repository operations.
The practical result is that native Windows Codex becomes unable to complete ordinary development tasks such as status checks, commit verification, or local fast-forward merges, unless the user manually leaves Codex and runs the commands outside the sandbox.
This significantly increases the priority from my perspective because the bug can completely disable normal Codex CLI/App workflows on an established Windows development workstation.