Repository navigation
Description
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
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:
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.
Activity
github-actions commentedon Jul 29, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
apply_patchintermittently fails withcannot enforce split writable root setsafter workspace migration on Windows #35086:workspaceprofile creates unsupported split roots and breaksapply_patch#34993Powered by Codex Action
PerikiyoXD commentedon Jul 29, 2026
PerikiyoXD commentedon Jul 29, 2026
PerikiyoXD@381acb1
Fixes
#34088
#31229
#35086
#34993
#34970
[-]Windows unelevated sandbox rejects enforceable split writable roots, breaking apply_patch updates and deletes[/-][+][BUGFIX] Windows unelevated sandbox rejects enforceable split writable roots, breaking apply_patch updates and deletes[/+][-][BUGFIX] Windows unelevated sandbox rejects enforceable split writable roots, breaking apply_patch updates and deletes[/-][+][BUGFIX INCLUDED] Windows unelevated sandbox rejects enforceable split writable roots, breaking apply_patch updates and deletes[/+]Gale0418 commentedon Jul 31, 2026
Additional reproduction from Codex Desktop on native Windows (workspace path omitted):
Environment:
Observed:
apply_patch verification failed: Failed to read file to update : 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.
kt-dev-ds commentedon Jul 31, 2026
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.
PerikiyoXD commentedon Jul 31, 2026
I recommend users to self-compile Codex with the commit I sent as a workaround.
kt-dev-ds commentedon Jul 31, 2026
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!
PerikiyoXD commentedon Jul 31, 2026
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)
kt-dev-ds commentedon Jul 31, 2026
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.
kt-dev-ds commentedon Aug 5, 2026
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.kt-dev-ds commentedon Aug 17, 2026
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!
DimaBogis commentedon Oct 10, 2026
Additional retained-thread reproduction / question for the maintainers and people who tested the fix (sanitized, no workspace or account details):
[windows] sandbox="unelevated"received the exact errorwindows unelevated restricted-token sandbox cannot enforce split writable root sets directly; refusing to run unsandboxedbefore the child process started.elevatedrestored sandboxed execution for an independent local Codex session (exit 0). However, we cannot establish from currently exposed read-only thread metadata which effective permission profile, backend, filesystem/network/deny-read restrictions the original retained task would actually use. We have not repeated its refused operation under the changed state, and have not disabled protections, modified roots, or used Full Access.Could someone familiar with the current Windows Desktop/app-server implementation advise a supported read-only way to inspect the selected effective profile/backend/revision and its filesystem/network enforcement for an existing saved thread, without spawning a replacement thread or weakening the permission policy? Is an existing retained thread expected to pick up a repaired
[windows] sandbox="elevated"after Desktop restart, or must its session profile be explicitly rebound through a supported product action? If no such API exists, could you point to the tracked issue/release addressing it?We want to preserve the original thread and the fail-closed restrictions; a documented answer would help separate a real vendor sandbox limitation from a stale per-thread configuration.