[BUGFIX INCLUDED] Windows unelevated sandbox rejects enforceable split writable roots, breaking apply_patch updates and deletes
# THIS INCLUDES A BUGFIX RATHER THAN BEING A PLAIN ISSUE REPORT
I reproduced the native Windows CLI apply_patch failure under the unelevated restricted-token sandbox and traced it to the filesystem override compatibility check.
Linked Issues
#34088
#31229
Reproduction
With:
- Native Windows Codex CLI
- [windows] sandbox = "unelevated"
- Managed workspace-write permissions with split writable roots
A controlled three-step probe behaves as follows:
- Add File succeeds.
- Update File fails.
- Delete File fails for the same reason.
The update fails during patch verification with:
apply_patch verification failed: Failed to read file to update <path>:
failed to prepare fs sandbox:
windows unelevated restricted-token sandbox cannot enforce split writable root sets directly;
refusing to run unsandboxed
This explains why creation works while modification and deletion do not: adding a file does not require reading an existing file, whereas update/delete verification does.
Root cause
The relevant path is:
apply_patch handler
→ verify_apply_patch_args
→ sandboxed filesystem read
→ resolve_windows_restricted_token_filesystem_overrides
resolve_windows_restricted_token_filesystem_overrides rejects the operation whenever the legacy writable-root projection differs from the modern split writable-root set.
However, unequal root sets do not necessarily mean the requested policy is unenforceable.
Concrete split writable roots already receive capability SIDs through the unelevated sandbox machinery.
The blanket equality check rejects enforceable configurations before that machinery can be used.
This is not specific to patch verification: the actual patch application uses the same sandboxed filesystem path, so bypassing verification alone would not correctly solve it.
Proposed fix
Permit split-only concrete writable roots and continue enforcing their restrictions through the existing capability-root and deny-write mechanisms.
The implementation:
- Removes the blanket legacy-versus-split root-set equality rejection.
- Accepts concrete split-only writable roots.
- Adds their read-only carve-outs to the additional deny-write set.
- Continues failing closed for unsupported filesystem-root writes.
- Preserves the existing rejection of unsupported read restrictions and unsafe descendant configurations.
- Does not fall back to unsandboxed execution.
Reference implementation:
https://github.com/PerikiyoXD/codex/commit/381acb1
Validation
After rebuilding the CLI with the change, the same production apply_patch path completed all three operations:
Add File: succeeded
Update File: succeeded
Delete File: succeeded
The focused sandboxing suite also passes:
37 tests run: 37 passed, 0 skipped
just fix -p codex-sandboxing completes without warnings.
I have kept the change as a focused commit on my fork. I can add a dedicated regression test and submit the implementation if a maintainer confirms that this approach matches the intended Windows sandbox architecture and invites a PR.
11 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
<img width="1465" height="598" alt="Image" src="https://github.com/user-attachments/assets/190f70ea-9943-407c-8b35-67eade41251d" />
https://github.com/PerikiyoXD/codex/commit/381acb1
Fixes
https://github.com/openai/codex/issues/34088
https://github.com/openai/codex/issues/31229
https://github.com/openai/codex/issues/35086
https://github.com/openai/codex/issues/34993
https://github.com/openai/codex/issues/34970
Additional reproduction from Codex Desktop on native Windows (workspace path omitted):
Environment:
Observed:
apply_patch verification failed: Failed to read file to update <path>: failed to prepare fs sandbox: windows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxed
On this machine, switching to elevated made sandbox setup/ACL helper work fail to complete promptly and made normal commands impractical; unelevated restores command responsiveness but leaves apply_patch update/delete unusable. We therefore currently need a PowerShell fallback.
This matches the Add/Update/Delete behavior described here and appears related to #35428, #34970, and the newer #36178 read-after-create failure. Could the maintainers please consider integrating the focused fix and adding a regression test covering managed split writable roots for Add, Update, and Delete? A release note or confirmation of the target version would help Windows users know when to retest.
I can also reproduce this issue with the latest ChatGPT Desktop.
Environment
Additional observation
The workaround suggested by Codex is to switch the task to Full Access.
However, the current ChatGPT Desktop application does not expose any Sandbox, Permissions, or Full Access settings.
I checked:
There are no Sandbox / Permissions / Full Access controls available.
Therefore, the suggested workaround cannot be performed.
This behavior occurs in the official ChatGPT Desktop application, not in the standalone Codex CLI.
Reproduction
Error:
Restarting ChatGPT Desktop does not resolve the issue.
If needed, I can provide screenshots showing that the current Desktop UI does not contain the Full Access / Sandbox controls that Codex instructs users to use.
The issue occurs in the built-in Codex experience inside the official ChatGPT Desktop application.
<img width="375" height="360" alt="Image" src="https://github.com/user-attachments/assets/d97d3b02-f523-42a1-b562-192598ea621b" />
<img width="265" height="279" alt="Image" src="https://github.com/user-attachments/assets/317e14fb-4ad4-48b4-87b6-765125462e7f" />
I recommend users to self-compile Codex with the commit I sent as a workaround.
Thank you for the suggestion.
My issue occurs in the built-in Codex included in the official ChatGPT Desktop application, not the standalone Codex CLI.
Unfortunately, ChatGPT Desktop users cannot self-compile or patch the bundled Codex.
Is this fix expected to be included in a future ChatGPT Desktop release?
Thank you!
I never used Desktop app but I can assure you the mechanism lives in this repository. This is why the issue no longer exists when I recompiled Codex CLI from this repo and my commit applied (Tried "master" from a few days ago and then switched to 0.145.0 tag and works equally fine)
Thank you for the clarification.
That makes sense.
Since ChatGPT Desktop is powered by Codex, I hope this fix will be included when the Desktop application is updated to a newer Codex version.
I'll test it again after a future ChatGPT Desktop update and report back if I can confirm the fix.
Thank you for tracking down the root cause and providing a fix.
I retested this issue after updating the official ChatGPT Desktop application.
Environment
Test result
Creating a new file with
apply_patchSuccess.
Updating the created file with
apply_patchFailed.
Error:
Verification
Conclusion
This issue is still reproducible in ChatGPT Desktop 26.730.61639.
Creating new files works correctly, but updating existing files with
apply_patchstill fails with the same Windows sandbox error.Good news — I retested this after updating the official ChatGPT Desktop application, and the issue appears to be resolved.
Environment
Test result
apply_patch: Successapply_patch: SuccessNo sandbox errors occurred.
No existing project files, source files, documents, or database contents were modified during the test.
Based on this minimal reproduction test, the issue appears to be resolved in ChatGPT Desktop 26.810.52044.
Thank you for the fix!