Apply_Patch is not working at all on windows system
What version of Codex is running?
codex-cli 0.88.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.2-codex
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What terminal emulator and version are you using (if applicable)?
PowerShell 7
What issue are you seeing?
Issue: apply_patch Failed with Windows Sandbox Error
Error Message
execution error: Io(Custom { kind: Other, error: "windows sandbox: CryptUnprotectData failed: 2148073483" })
What Happened
Attempted to add comment // Hyy G! to persistence/src/main/java/com/topedge/persistence/model/BusinessEntity.kt
Patch attempted:
5
6 -@Entity(tableName = "business_profiles")
6 +// Hyy G!
7 +@Entity(tableName = "business_profiles")
8 data class BusinessEntity(
Result: Failed twice (including retry with escalated permissions)
apply_patch fails due to Windows sandbox CryptUnprotectData error. Cannot escalate privileges to bypass.
What steps can reproduce the bug?
Please enable the Windows Sandbox experimental feature and elevate permissions. Then, try to edit files; it will attempt to use apply_patch but will fail.
Keep in mind that I am working on a company PC, which has both administrator and user accounts. I encounter this issue while logged in as a user.
What is the expected behavior?
It should edit files or read through using apply_patch. It fails and then continues working with commands that take extra time. Additionally, it has worsened the Codex CLI experience as well.
Additional information
<img width="841" height="831" alt="Image" src="https://github.com/user-attachments/assets/c16faab6-a2b4-467c-a96b-b0ea5a927660" />
My Config.toml files:
[features]
web_search_request = true
check_for_update_on_startup = true
unified_exec = true
shell_snapshot = true
powershell_utf8 = true
collab = true
steer = true
experimental_windows_sandbox = true
elevated_windows_sandbox = true
4 Comments
Thanks for the bug report. Assuming that you're able to repro this on demand, please use the
/feedbackslash command to upload logs and session details, then post the thread ID here.Here is the thread ID: 019be434-e140-7502-aec2-d34b4b65ed81
Hi @umairshahid-1! That
CryptUnprotectDataerror (2148073483 / 0x8009000B) usually indicates a DPAPI "Key Not Valid" state. This often happens if the encryption keys used to store the sandbox login secrets become stale after a major Windows update or a hardware/OS change.I'm working on a patch in #10648 to add a more robust fallback mechanism so Codex doesn't fail the entire tool call when DPAPI is wonky.
Quick Workaround:
As a temporary fix, you can try deleting the
%USERPROFILE%\.codex\.sandbox-secretsdirectory. This will force Codex to re-run the elevated setup and regenerate fresh encryption keys, which usually clears this specific error.Hey @umairshahid-1, I've got a fix for this in PR #10648. I added a fallback that catches those DPAPI errors and automatically triggers a sandbox re-setup to refresh the keys. It should handle the recovery for you without having to manually regenerate anything. Just waiting on the merge now!