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
apply_patch fails on Windows with multiple writable roots #34970
appIssues related to the Codex desktop appbugSomething isn't workingsandboxIssues related to permissions or sandboxingwindows-osIssues related to Codex on Windows systems
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.715.72359
What subscription do you have?
Pro
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
On Windows, apply_patch fails before it opens any workspace file.
Error:
windows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxed
The task is launched with two writable roots:
I uninstalled the Visualize plugin and restarted both the laptop and Codex, but new Codex tasks still receive the visualization writable root. This prevents apply_patch from editing any file.
Expected: apply_patch should work in a normal local project task, or Codex should not attach the stale visualization root.
What steps can reproduce the bug?
Open the Codex desktop app on Windows.
Open a local project task in
Ask Codex to make any small file edit using apply_patch.
The task environment includes the project root plus a .codex\visualizations...\ directory as writable roots.
apply_patch fails before reading or modifying the target file.
I also uninstalled the Visualize plugin and restarted both Codex and Windows. New tasks still get the extra visualization writable root and reproduce the same failure.
Every command spawn then fails before the command runs with:
windows elevated sandbox cannot reopen writable descendants under read-only carveouts directly; refusing to run unsandboxed
A fresh CLI run constrained to the exact repository with --sandbox workspace-write --cd <repo> succeeds. That indicates the repository ACLs are not the cause; Desktop is emitting an impossible writable-parent / protected-child / reopened-writable-descendant root graph.
User impact
This has turned into an almost six-hour troubleshooting task. The complete task's cumulative local counters at audit time show:
32,572,578 total processed tokens
31,385,472 cached input tokens
1,043,896 non-cached input tokens
143,210 output tokens, including 68,198 reasoning tokens
I am not claiming that every one of those tokens is directly billable or solely attributable to this defect; cached and non-cached usage are accounted differently. The figures show the total scale of the troubleshooting task and its substantial credit/usage-limit impact.
Separately, three specifically measured exact-repository workaround runs consumed 81,276 additional tokens outside the actual benchmark, including a 26,315-token failed child and a 35,417-token successful child. The fallback reloads task context, so every failed Desktop spawn can cause significant duplicated work.
Please address both layers:
Treat this exact elevated error as deterministic in Desktop: do not retry the same sandbox spawn; automatically continue once through an exact-repository workspace-write child and return its result to the original task.
Fix the workspace-root producer so it does not grant a broad home ancestor together with a writable capability directory inside protected CODEX_HOME.
The elevated backend's fail-closed behavior should remain intact; weakening the sandbox or using full access is not an acceptable fix.
This is related to #34970 because the same visualization root is injected, but it is not the same refusal path: #34970 reports the unelevated split-root check, while this report reaches the elevated reopened-descendant check.
A built-in apply_patch operation against a task-owned scratch file inside the writable workspace fails before reading or modifying the target:
windows elevated sandbox cannot reopen writable descendants under read-only carveouts directly; refusing to run unsandboxed
The same profile can also prevent otherwise read-only command launches before the child process starts. This is not the older unelevated split-root refusal: the runtime explicitly selects the elevated backend and reaches the reopened-descendant check.
The fail-closed behavior is correct; weakening the sandbox or silently running unsandboxed would not be. The missing behavior is a safe way to execute an already-authorized single-path filesystem request when the full permission graph contains a reopened writable descendant.
A source-level prototype against rust-v0.151.0-alpha.7.2 validated one bounded approach:
Validate the exact requested path against the original permission policy.
Derive a request-scoped, non-overlapping capability root for that one filesystem operation.
Disable symlink/reparse-point following on that compatibility path.
Keep unsupported multi-path/discovery requests and arbitrary process execution fail-closed.
Preserve the existing path on Linux, macOS, and Windows profiles without reopened writable descendants.
Focused unit and Windows helper integration tests passed for ordinary writable files, the authorized reopened descendant, protected siblings, outside paths, and non-Windows compilation. This latest official-runtime reproduction shows the elevated variant still needs a runtime fix and regression coverage.
Additional reproducible elevated-backend evidence for this issue, from native Windows and VS Code extension 26.1007.21434 / bundled CLI 0.162.0-alpha.17.2.
The failing policy is a writable scratch workspace, its protected/read-only .agents directory, and an explicitly reopened writable .agents/sessions descendant. With approvals disabled, ordinary exec_command reads fail before process creation:
windows elevated sandbox cannot reopen writable descendants under read-only carveouts directly; refusing to run unsandboxed
The exact official source tag is rust-v0.162.0-alpha.17.2, commit 740e5af33c71225640e0c1c1555c514c2c93ab74. resolve_windows_elevated_filesystem_overrides in codex-rs/sandboxing/src/windows.rs rejects this policy through has_reopened_writable_descendant before elevated setup can enforce the requested roots. The same check was still present in upstream main when inspected on 2026-10-09.
A synthetic, local-only reproduction is available in my version-pinned toolkit. It drives actual CLI exec_command and native apply_patch through a loopback mock Responses server, so there is no model call or private repository payload:
Use the complete matching official runtime directory, not a lone executable. The script creates disposable fixtures and includes both --ignore-user-config and --ignore-rules, elevated sandboxing, approvals never, and an explicit named permission profile. Ignoring user config alone is not sufficient: saved exec rules can approve unsandboxed execution and falsely make a shell test appear successful. Standalone codex sandbox is also not equivalent to this tool-dispatch path.
I have a narrow local candidate fix plus regressions. It removes only the elevated blanket rejection while preserving original root projection and ancestor denies. The unelevated restricted-token rejection remains. It changes no production ACL masks or token setup. The rationale is that elevated setup grants explicit writable-root allows, which take precedence over inherited ancestor denies; ancestor/sibling restrictions still need to be verified separately.
Observed validation:
Untouched official reopened-root control reproduces the failure; ordinary-workspace control passes.
All 59 sandbox transformation unit tests and an integration regression using the actual elevated sandbox account pass with the candidate.
Rebuilt CLI with matching official unchanged setup/runner helpers passes four 27-case matrices: ordinary, reopened/network-enabled, reopened/network-restricted, and a disposable linked worktree.
A fresh VS Code session after reload confirms default-permission shell reads and native patch lifecycle operations in both the workspace and reopened descendant.
This is a proposed implementation with evidence for the tested layouts, not a claim that removing guards is generally safe for every Windows policy. Please evaluate whether the elevated backend can support this explicit descendant grant, or whether the host should avoid generating an unsupported policy. I am sharing the reproduction and analysis here in accordance with the current contribution policy; no external PR is being opened.
appIssues related to the Codex desktop appbugSomething isn't workingsandboxIssues related to permissions or sandboxingwindows-osIssues related to Codex on Windows systems
Activity
github-actions commentedon Jul 23, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Loumeister commentedon Aug 24, 2026
I can reproduce a distinct elevated-sandbox variant of this bug on Windows Codex Desktop. The CLI installed alongside it reports
codex-cli 0.146.0.The effective permission graph includes:
C:\Users\<user>C:\Users\<user>\.codexC:\Users\<user>\.codex\visualizations\<date>\<thread>Every command spawn then fails before the command runs with:
A fresh CLI run constrained to the exact repository with
--sandbox workspace-write --cd <repo>succeeds. That indicates the repository ACLs are not the cause; Desktop is emitting an impossible writable-parent / protected-child / reopened-writable-descendant root graph.User impact
This has turned into an almost six-hour troubleshooting task. The complete task's cumulative local counters at audit time show:
I am not claiming that every one of those tokens is directly billable or solely attributable to this defect; cached and non-cached usage are accounted differently. The figures show the total scale of the troubleshooting task and its substantial credit/usage-limit impact.
Separately, three specifically measured exact-repository workaround runs consumed 81,276 additional tokens outside the actual benchmark, including a 26,315-token failed child and a 35,417-token successful child. The fallback reloads task context, so every failed Desktop spawn can cause significant duplicated work.
Please address both layers:
workspace-writechild and return its result to the original task.CODEX_HOME.The elevated backend's fail-closed behavior should remain intact; weakening the sandbox or using full access is not an acceptable fix.
This is related to #34970 because the same visualization root is injected, but it is not the same refusal path: #34970 reports the unelevated split-root check, while this report reaches the elevated reopened-descendant check.
zjbob commentedon Sep 2, 2026
Retested the distinct elevated-sandbox variant on 2026-09-02. It remains reproducible in the current official Windows Desktop runtime:
The effective permission graph contains an authorized writable descendant beneath a protected directory:
A built-in
apply_patchoperation against a task-owned scratch file inside the writable workspace fails before reading or modifying the target:The same profile can also prevent otherwise read-only command launches before the child process starts. This is not the older unelevated split-root refusal: the runtime explicitly selects the elevated backend and reaches the reopened-descendant check.
The fail-closed behavior is correct; weakening the sandbox or silently running unsandboxed would not be. The missing behavior is a safe way to execute an already-authorized single-path filesystem request when the full permission graph contains a reopened writable descendant.
A source-level prototype against
rust-v0.151.0-alpha.7.2validated one bounded approach:Focused unit and Windows helper integration tests passed for ordinary writable files, the authorized reopened descendant, protected siblings, outside paths, and non-Windows compilation. This latest official-runtime reproduction shows the elevated variant still needs a runtime fix and regression coverage.
zjbob commentedon Oct 9, 2026
Additional reproducible elevated-backend evidence for this issue, from native Windows and VS Code extension
26.1007.21434/ bundled CLI0.162.0-alpha.17.2.The failing policy is a writable scratch workspace, its protected/read-only
.agentsdirectory, and an explicitly reopened writable.agents/sessionsdescendant. With approvals disabled, ordinaryexec_commandreads fail before process creation:The exact official source tag is
rust-v0.162.0-alpha.17.2, commit740e5af33c71225640e0c1c1555c514c2c93ab74.resolve_windows_elevated_filesystem_overridesincodex-rs/sandboxing/src/windows.rsrejects this policy throughhas_reopened_writable_descendantbefore elevated setup can enforce the requested roots. The same check was still present in upstream main when inspected on 2026-10-09.A synthetic, local-only reproduction is available in my version-pinned toolkit. It drives actual CLI
exec_commandand nativeapply_patchthrough a loopback mock Responses server, so there is no model call or private repository payload:Use the complete matching official runtime directory, not a lone executable. The script creates disposable fixtures and includes both
--ignore-user-configand--ignore-rules, elevated sandboxing, approvalsnever, and an explicit named permission profile. Ignoring user config alone is not sufficient: saved exec rules can approve unsandboxed execution and falsely make a shell test appear successful. Standalonecodex sandboxis also not equivalent to this tool-dispatch path.I have a narrow local candidate fix plus regressions. It removes only the elevated blanket rejection while preserving original root projection and ancestor denies. The unelevated restricted-token rejection remains. It changes no production ACL masks or token setup. The rationale is that elevated setup grants explicit writable-root allows, which take precedence over inherited ancestor denies; ancestor/sibling restrictions still need to be verified separately.
Observed validation:
This is a proposed implementation with evidence for the tested layouts, not a claim that removing guards is generally safe for every Windows policy. Please evaluate whether the elevated backend can support this explicit descendant grant, or whether the host should avoid generating an unsupported policy. I am sharing the reproduction and analysis here in accordance with the current contribution policy; no external PR is being opened.