codex icon indicating copy to clipboard operation
codex copied to clipboard

Windows unelevated sandbox refuses workspace-write with "split writable root sets" when cwd differs only in letter case

Open jooyou opened this issue 2 weeks ago • 1 comments

What version of Codex CLI is running?

codex-cli 0.169.0 (npm, native Windows)

What subscription do you have?

n/a — the failure is in local sandbox setup and does not depend on the plan

Which model were you using?

Not model-dependent (the command is refused before it starts)

What platform is your computer?

Windows 11 Pro x64 (10.0.26300), [windows] sandbox = "unelevated" in config.toml

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

PowerShell 7 (pwsh)

What issue are you seeing?

With --sandbox workspace-write, exec_command is refused with the "split writable root sets" error when the working directory differs from the real path only in letter case. The same directory spelled with its real casing works.

exec_command failed: CreateProcess { message: "UnsupportedOperation(\"windows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxed\")" }

Results on one machine, same binary and config, only -C changed:

cwd passed to -C result
%TEMP%\probe runs
C:\Users runs
C:\users refused (split writable root sets)
C:\Users\<user> runs
c:\users\<user> refused (split writable root sets)
C:\Users\<user>\probe-sibling runs

We hit this in practice because a long-running process that drives Codex through app-server had been started from a shell whose current directory was typed as C:\users. Every turn under danger-full-access worked, and every workspace-write turn failed on its first command.

What steps can reproduce the bug?

codex exec --ephemeral --skip-git-repo-check --sandbox workspace-write -C 'C:\Users\<user>' "Run exactly this shell command once: echo PROBE_OK"
# -> runs, prints PROBE_OK

codex exec --ephemeral --skip-git-repo-check --sandbox workspace-write -C 'c:\users\<user>' "Run exactly this shell command once: echo PROBE_OK"
# -> exec_command refused with "cannot enforce split writable root sets directly; refusing to run unsandboxed"

What is the expected behavior?

Windows paths are case-insensitive, so a cwd that differs only in letter case should resolve to the same writable root and run under the same sandbox as the correctly cased path.

Additional information

Likely cause, from reading codex-rs/sandboxing/src/windows.rs on main: resolve_windows_restricted_token_filesystem_overrides compares the legacy projection's writable roots with the resolved split writable roots as BTreeSet<PathBuf>. normalize_windows_override_path only applies dunce::simplified (strips the \\?\ prefix) and does not fold or canonicalize case, and PathBuf comparison is case-sensitive. If one side ends up with the real casing and the other keeps the caller's casing, identical roots compare unequal and the command is refused. Comparing case-insensitively (or canonicalizing both sides the same way) should fix this trigger.

Workaround on our side: launch from (or pass) a correctly cased working directory.

Related reports with the same error string: #59314, #35864, #52252. This report isolates a case-only trigger that may explain some of them.

jooyou avatar Nov 16 '26 00:11 jooyou

A second comparison in current codex-rs/sandboxing/src/windows.rs matters for a case-only repair. After the legacy_root_paths != split_root_paths BTreeSet<PathBuf> check, resolve_windows_restricted_token_filesystem_overrides again locates each legacy root using exact candidate_path == split_root_path. It then compares read_only_subpaths with exact path equality. So normalizing only the first set comparison could simply move the same case-only false rejection to the later lookup; worse, an inconsistent comparison strategy could misclassify a protected carveout.

Suggested regression boundary: (1) identical effective writable roots with C:\Users versus C:\users (and drive-letter-only case differences) must be accepted through the entire unelevated resolution path; (2) an identical effective read-only carveout with case differences must still be recognized as protected, not treated as a newly writable directory; (3) genuinely different roots or missing/changed read-only carveouts must continue to fail closed or generate the required deny-write override. Keep path equivalence tied to actual Windows filesystem identity/canonicalization where appropriate, rather than blindly folding strings and thereby treating reparse-point/alias differences or non-existing paths as proven equivalent.

This is a source-guided repair/test suggestion, not an affected-machine reproduction or a claim that a particular normalization implementation is safe.

84dnnvbdvp-debug avatar Nov 16 '26 05:11 84dnnvbdvp-debug