Windows Desktop sandbox forces choice between CreateProcessAsUserW 1312 and apply_patch split-root failure
What version of the Codex App are you using (From "About Codex" dialog)?
26.623.13972.0
Desktop package:
OpenAI.Codex_26.623.13972.0_x64__2p2nqsd0c76g0
Codex CLI/runtime:
codex-cli 0.142.5
What subscription do you have?
Pro 5x
What platform is your computer?
Windows 11 Home 25H2, 64-bit, build 26200.8655.
Registry version fields:
ProductName : Windows 10 Home
DisplayVersion : 25H2
CurrentBuild : 26200
CurrentBuildNumber : 26200
UBR : 8655
EditionID : Core
InstallationType : Client
Codex environment also reported:
Microsoft Windows NT 10.0.26200.0 x64
Note: Windows compatibility APIs still report ProductName = Windows 10 Home
and NT version 10.0, but the 25H2 display version and 26200 build identify
this as a Windows 11 system.
Shell: PowerShell
What issue are you seeing?
Codex Desktop on Windows currently forces a choice between two broken sandbox configurations:
-
With
[windows] sandbox = "unelevated":- normal shell commands work
apply_patchcan create filesapply_patchupdate/delete fails before patching workspace files
-
With
[windows] sandbox = "elevated":apply_patchcreate/update/delete works- normal shell commands fail before PowerShell starts
So there does not appear to be a working Windows Desktop setup where both safe file edits and ordinary diagnostic/build/test commands work in the same session.
This looks related to both existing issues:
- #30712: Desktop injects split writable roots and
apply_patchcannot enforce them under the unelevated Windows sandbox. - #30024: Windows sandbox command runner fails with
CreateProcessAsUserW failed: 1312.
Current relevant config for the latest repro:
approval_policy = "never"
sandbox_mode = "danger-full-access"
[windows]
sandbox = "elevated"
Observed with [windows] sandbox = "elevated":
windows sandbox: runner error: CreateProcessAsUserW failed: 1312
This happens even for simple read-only commands.
Observed with [windows] sandbox = "unelevated":
apply_patch verification failed: Failed to read file to update <workspace file>:
failed to prepare fs sandbox:
failed to prepare windows sandbox wrapper:
windows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxed
What steps can reproduce the bug?
- Use Codex Desktop on Windows with a normal managed workspace-write session.
- Set:
[windows]
sandbox = "unelevated"
- Restart Codex Desktop.
- In a workspace, run a normal shell command such as
Get-Location. - Observe that shell commands work.
- Use
apply_patchto create a new file. - Observe that file creation works.
- Use
apply_patchto update or delete an existing workspace file. - Observe that
apply_patchfails with:
windows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxed
- Change config to:
[windows]
sandbox = "elevated"
- Restart Codex Desktop.
- Use
apply_patchto create/update/delete a workspace file. - Observe that
apply_patchworks. - Run a simple shell command such as
Get-Location,codex --version, or a file read command. - Observe that shell execution fails before PowerShell starts with:
windows sandbox: runner error: CreateProcessAsUserW failed: 1312
What is the expected behavior?
There should be at least one Windows Desktop sandbox configuration where both of these are true:
apply_patchcan create/update/delete files inside the active workspace root.- ordinary shell commands can run for diagnostics/build/test operations.
If the unelevated Windows sandbox cannot enforce split writable root sets, Codex
Desktop should avoid injecting a sandbox shape that breaks apply_patch, or
apply_patch should use a sandbox strategy that supports the Desktop-managed
profile.
If the elevated Windows sandbox is the intended workaround for apply_patch,
ordinary shell commands should still launch successfully instead of failing with
CreateProcessAsUserW failed: 1312.
Additional information
Troubleshooting already tried without resolving the issue:
-
Changed
[windows] sandboxtounelevated.- Result: shell commands worked, but
apply_patchupdate/delete failed with the split writable roots error.
- Result: shell commands worked, but
-
Changed
[windows] sandboxback toelevated.- Result:
apply_patchworked, but normal shell commands failed withCreateProcessAsUserW failed: 1312.
- Result:
-
Restarted Codex Desktop after config changes.
- Result: no change.
-
Ended older Codex tasks/processes and restarted Codex again.
- Result: no change.
-
Tried launching/restarting Codex "as administrator".
- Result: process token checks still reported Codex processes as not elevated
(
Elevated=0), and shell commands still failed in elevated sandbox mode.
- Result: process token checks still reported Codex processes as not elevated
(
-
Tried:
[windows]
sandbox = "elevated"
sandbox_private_desktop = false
- Result: normal shell commands still failed with
CreateProcessAsUserW failed: 1312.
- Tried excluding temp writable roots:
[sandbox_workspace_write]
exclude_tmpdir_env_var = true
exclude_slash_tmp = true
- Result: the Desktop managed permission profile still exposed extra writable
roots such as
C:\tmp;apply_patchstill failed inunelevatedmode.
-
Tried a custom permission profile with only the workspace root writable.
- Result: the config parsed and a direct
codex sandbox -P <profile> ...check worked, but Desktop managed sessions still injected the extra writable roots, so app session behavior did not change.
- Result: the config parsed and a direct
-
Tried direct elevated launch attempts for the packaged app:
- Direct
Start-Processagainst theWindowsAppspackage executable failed with access denied due to package ACLs. Start-Processviashell:AppsFolder\OpenAI.Codex_2p2nqsd0c76g0!Appreturned success but appeared to focus/reuse the existing non-elevated app instance instead of starting an elevated Codex process.
- Direct
-
Rechecked after explicitly ending old Codex tasks and restarting as admin.
- Result: current Codex process token checks still showed
Elevated=0.
- Result: current Codex process token checks still showed
The report intentionally redacts the local user profile and workspace paths.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #30712
- #30024
- #30009
Powered by Codex Action
I can reproduce the same unelevated sandbox failure with Codex CLI v0.144.1 on Windows.
Configuration:
[windows]
sandbox = "unelevated"
The session uses workspace-write. I have no [sandbox_workspace_write] section and no user-configured writable_roots.
apply_patch fails with:
windows unelevated restricted-token sandbox cannot enforce split writable root sets directly
Runtime diagnostics show the workspace plus runtime-managed special temp roots such as :special slash_tmp and :special tmpdir.
I also tried setting both TEMP and TMP to a directory inside the workspace before launching Codex, but the failure remained. This suggests that the special temp-root representation itself still causes a split writable-root set.
Codex CLI v0.142.5 with the unelevated sandbox previously allowed apply_patch on the same machine, so this may also be a regression affecting v0.144.1.
Additional reproduction from Codex Desktop on Windows 10 Home:
- Desktop runtime reported in-session:
26.707.72221. - The desktop permission UI was set to Full access, but the effective task context still reported
sandbox_mode = "workspace-write"and invoked theunelevatedWindows sandbox wrapper. - The managed session included multiple writable roots: the workspace,
C:\tmp, and a Codex visualization directory. - Updating an existing workspace file via
apply_patchfailed before reading the target:
apply_patch verification failed: Failed to read file to update <workspace>\src\deckTests\ggo.test.ts:
failed to prepare fs sandbox:
failed to prepare windows sandbox wrapper:
windows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxed
- Switching from elevated to unelevated had been suggested after elevated mode caused failures, so neither configuration has provided a reliable editing workflow.
- Reinstalling the desktop app did not resolve the problem.
The misleading Full access UI state is important: the patch path still behaved as sandboxed/unelevated in the active task.
Additional controlled A/B reproduction from Codex Desktop on Windows (2026-07-20). I originally posted this datapoint on #30009, but this issue appears to be the canonical tracker for the split-root Windows sandbox failure.
Environment:
- Codex Desktop:
26.715.4045.0 - Windows:
Microsoft Windows NT 10.0.26200.0 x64 - Normal local Git workspace
- Tiny temporary text file inside the workspace
Managed workspace-write / restricted-filesystem mode:
apply_patchAdd File stalled for about 60 seconds.- It eventually returned
{}, and the file had been created correctly. - A subsequent
apply_patchDelete File was still unresponsive after about 20 seconds and the task was interrupted. - The file remained after interruption.
After changing only the task permission profile to danger-full-access / unrestricted in the same workspace:
- Delete leftover file: 55 ms
- Add file: 91 ms
- Content verification: succeeded
- Delete file: 413 ms
- Final verification: file absent and no Git status residue
This isolates the long stall/hang to the Windows restricted sandbox/wrapper path rather than patch parsing or the workspace filesystem.
Original comment with the same measurements: https://github.com/openai/codex/issues/30009#issuecomment-5018068355
I can reproduce this outside the Codex Desktop app through Zed's ACP integration.
Environment:
- Windows 11 x64
codex-acp1.8.0- bundled
codex-cli 0.152.1 - managed
workspace-writeprofile - UNC workspace:
\\<server>\<share>\<workspace>
apply_patch can create new files, but updating existing files fails with:
windows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxed
Session logs show that apply_patch worked on the same UNC workspace with Codex 0.142.4. The failure appeared with 0.145.0 and remains reproducible with 0.152.1.
This appears to be the same CLI/runtime issue as #32168, but it is also reproducible when Codex is hosted through ACP, without using the Desktop app.
#35864 seems to be a related fix.