Skip to content

Windows sandbox keeps locking itself out of .sandbox-bin — finally found why (and a fix that actually sticks) #51468

Open

Description

@dragon940111-bot

What version of the Codex App are you using?

Desktop 26.930.7945.0 from the Store, engine 0.160.1. Windows 11 Pro 26300. Plus plan.

What steps can reproduce the bug?

Honestly, just use it the way I do: a ChatGPT Work thread that runs on my PC plus some local tasks, switching back and forth during the day. Within a day or two every command starts failing with

Failed to create unified exec process: exec-server rejected request (-32603): sandbox provisioning failed

and attachments die with

cannot create attachment directory: failed to prepare fs sandbox: failed to prepare windows sandbox wrapper: sandbox provisioning failed

Clicking the "update sandbox" UAC prompt brings it back for a while, then it dies again. I reinstalled Windows over this. Didn't help — same thing again two days after a clean install.

What do you see instead?

After three days of this I started reading the logs in .codex\.sandbox and then the actual source for 0.160.1. This is what's going on:

  • The folder %USERPROFILE%\.codex\.sandbox-bin gets created by my user process before the service is ever called (gather_helper_read_roots() does a create_dir_all, and that runs inside require_logon_sandbox_creds() before require_sandbox_account()). So I own it.
  • The first time the service provisions, it works — the folder still inherits SYSTEM Full Control from my profile. Then lock_sandbox_bin_dir() slaps a protected DACL on it: SYSTEM 0x1301bf, Administrators 0x1301bf, me 0x1701bf, CodexSandboxUsers 0x1200a9. Notice neither SYSTEM nor Administrators gets WRITE_DAC.
  • Next time the service needs to provision again, it opens that same folder with READ_CONTROL | WRITE_DAC (lock_sandbox_dir, the ProvisionOnly branch). It's running as LocalSystem, it isn't the owner, it has no WRITE_DAC, inheritance is blocked. Open fails. Log says:
setup error: helper_sandbox_lock_failed: lock sandbox bin dir \\?\C:\Users\<user>\.codex\.sandbox-bin failed: open directory \\?\C:\Users\<user>\.codex\.sandbox-bin

and nothing else, because the real error gets dropped on the way out ({err} only prints the outer context). Took me a while to figure out it was an access denied.

  • Worst part: prepare_setup_marker() deletes setup_marker.json before provisioning. So when provisioning fails, the marker is a 0-byte file and from then on every single command says sandbox setup marker missing or incompatible → calls the service → fails again. Everything is bricked until I click the UAC setup, which works because that one runs as me (the owner). But the UAC setup stores proxy_ports=[], and my cloud-connected Work thread wants [3128, 8081], so the very next command from that thread triggers offline firewall settings changed → service → dead again. That's the whole "intermittent" thing. I counted: every one of the 6 "settings changed" events in my logs was followed by a failed provisioning.

  • I also tried what people suggested in the other issues — adding a SYSTEM WRITE_DAC ACE by hand. It worked for exactly one provisioning and then vanished, because lock_sandbox_bin_dir() is also called from the per-command refresh (run_setup_full) and rewrites the whole DACL every time. Watched it happen: ACE added 18:13:25, one successful provisioning 18:15:19, ACE gone, failure at 18:15:24.

Numbers from my sandbox-*.log files before the fix: 17 service provisioning attempts over 3 days, 15 failed, 2 succeeded (the very first one after install, and the two minutes the hand-added ACE existed).

What fixed it

One command, as admin:

takeown /F "%USERPROFILE%\.codex\.sandbox-bin" /A

Owner becomes BUILTIN\Administrators. LocalSystem has Administrators in its token, so it gets implicit READ_CONTROL/WRITE_DAC as owner. I didn't touch the DACL at all (backed up the SDDL first). This sticks because Codex only ever rewrites the DACL — never the owner.

Since then: 4 full re-provisionings (3 of them were the normal settings flips in both directions while I just used the thing) — 4 for 4, zero lock failures, 59 sandboxed commands, setup_error.json gone, and the attachment download that started all this works again in the same thread. Someone in #50520 did basically the same owner change and reports it survived a reboot and a desktop update too.

Why the other workarounds don't last: renaming/recreating .sandbox-bin (#45734, #46380) only buys you one provisioning — my user process recreates it user-owned and the service locks itself out again on the next round. icacls /setowner "NT AUTHORITY\SYSTEM" fails with error 5 (needs SeRestorePrivilege); takeown /A doesn't need that.

What is the expected behavior?

Re-provisioning should just work. Or at the very least, failing to provision shouldn't nuke the previous working setup.

Additional information

If it helps, the fix on your side looks small:

  1. Give SYSTEM (or Administrators) WRITE_DAC in that DACL, or have the service take ownership of .sandbox-bin before locking it.
  2. Don't delete setup_marker.json until the new provisioning actually succeeded.
  3. Put the real io::Error in the helper_sandbox_lock_failed message so the next person doesn't have to guess.

Checked codex-rs/windows-sandbox-rs/src/{setup.rs, identity.rs, setup_provisioning.rs, no_reparse_dir.rs, setup_provisioning/sandbox_users.rs} and windows-sandbox-service/src/provisioning.rs at rust-v0.160.1; same code on main as of Oct 6.

Same symptom reports: #50520 #46380 #36475 #45734 #45153 #49025 #51111. Please don't close this as a duplicate — those describe the symptom, this one is the cause.

Activity

  1. ShinaRera commented on Oct 10, 2026

    @ShinaRera

    Windows sandbox: SYSTEM denied WRITE_DAC on user-owned .sandbox-bin; owner-only A/B test

    Related: #51468 and #50520

    Independent local evidence supporting the access-rights mismatch reported here. Directory access recovery and natural service re-provisioning are separate acceptance criteria.

    Environment at diagnosis

    • Native Windows / PowerShell; kernel reported 10.0.26200.0.
    • Service image in Desktop package OpenAI.Codex_26.930.4958.0; service account LocalSystem.
    • Runtime logs/source review: 0.160.0. A source tag does not prove byte-for-byte correspondence with all installed binaries.
    • Default CODEX_HOME under the user profile. Existing .sandbox-bin initially user-owned with a protected DACL.

    Service failure evidence

    Application provider CodexSandboxService.OpenAI.Codex, event 2001:

    Codex sandbox provisioning failed: helper_sandbox_lock_failed:
    lock sandbox bin dir <CODEX_HOME>/.sandbox-bin failed:
    open directory <CODEX_HOME>/.sandbox-bin
    

    The Oct 5 service event at 15:22:55.7429735 UTC (record 48124) matched the helper failure at approximately 15:22:55.737 UTC. An Oct 6 query found 240 retained matching events, all 2001, spanning Sep 28 through Oct 5. This is not proof that every historical service attempt failed.

    Pre-change allow masks:

    Principal Mask WRITE_DAC
    SYSTEM 0x001301BF absent
    Administrators 0x001301BF absent
    Interactive user 0x001701BF present
    Sandbox users group 0x001200A9 absent

    Real identity A/B test, Oct 6

    A read-only NtCreateFile probe used FILE_OPEN on the existing directory and closed the handle. The device-path variant also used OBJ_DONT_REPARSE. It did not create directories or alter permissions.

    Identity / state READ_CONTROL READ_CONTROL + WRITE_DAC Same rights, device path + OBJ_DONT_REPARSE
    Ordinary user, before success success success
    SYSTEM, before (13:47:48 UTC) success 0xC0000022 0xC0000022
    SYSTEM, after (15:33:40 UTC) success success success
    Ordinary user, after success success success

    The sole production change was the top-level directory owner, changed to Administrators (S-1-5-32-544). DACL bytes, DACL control flags, primary group, and owners/security descriptors of 21 direct child files were verified unchanged. Marker contents/mtime were unchanged during this test. Temporary SYSTEM probe tasks were removed.

    Normal sandbox execution and a real apply_patch edit succeeded afterward. This confirms removal of the directory access obstacle, not full service re-provisioning.

    Manual recovery and limits

    On Oct 7 at 23:31 UTC, user-requested manual repair ran official setup through a fixed privileged task. Official setup and worker returned 0; the run log contained setup provisioning binary completed. Marker was valid, 255 bytes, proxy_ports=[], allow_local_binding=false; setup_error.json was absent. Ordinary sandbox execution and actual apply_patch succeeded after reopening.

    This was manual intervention, not natural service success. The repair used the subsequently installed runtime 0.162.0-alpha.2 and does not establish that the original runtime was fixed.

    As of the Oct 10 06:29 UTC read-only capture, no new matching service events followed record 48125; marker and permissions remained unchanged. An Oct 7 15:15 UTC run-only candidate remains unattributed: restart/repair attempts occurred during that session with unknown timing. Natural, intervention-free service re-provisioning acceptance remains pending. Cross-update durability and network isolation have not been accepted either.

    Expected behavior / investigation targets

    Re-provisioning should remain possible under the official service identity after Codex protects its helper directory. Please review required access rights for the existing-directory lock operation, failure handling that leaves a truthful recoverable setup state, and retention of the underlying access error in diagnostics.

    Source reviewed: https://github.com/openai/codex/blob/rust-v0.160.0/codex-rs/windows-sandbox-rs/src/setup_provisioning.rs and the legacy service provisioning path. These are investigation pointers, not a claim that every similarly worded lock error has this cause.

    User/machine names, machine-specific SIDs, credentials, command payloads and full logs are omitted. Raw local probe/event evidence is retained privately. No destructive reproduction or deliberate marker corruption was performed for this report.

  2. CTS-Engineering commented on Oct 24, 2026

    @CTS-Engineering

    I ran into the same helper_sandbox_lock_failed error on Windows 11 Pro. Codex was unable to start PowerShell commands because it was getting access denied when opening %USERPROFILE%\.codex\.sandbox-bin.

    After reading through the findings here, I checked the directory permissions on my machine. The folder was owned by my Windows user account, with inheritance disabled, which seems consistent with the issue described.

    I tried the suggested ownership change from an elevated PowerShell session:

    takeown /F "$env:USERPROFILE\.codex\.sandbox-bin" /A
    

    The owner changed to BUILTIN\Administrators. I compared the DACL before and after using SDDL, and it remained unchanged. No recursive changes or additional permissions were needed.

    I also updated Codex Desktop afterward. On relaunch, it prompted me to complete the Windows sandbox installation, which finished successfully. I then ran two separate sandboxed Git commands in the same worktree. Both completed with exit code 0, without any provisioning errors.

    One important caveat: since I updated Codex and completed its sandbox setup before retesting, I can't isolate the ownership change as the sole reason it started working. I also haven't verified whether it survives repeated reprovisioning.

    There is still a separate issue with an older chat that won't resume because the elevated sandbox requires effective :root read access. That appears to be the compatibility issue discussed in #46312 rather than the .sandbox-bin problem.

    I thought I'd share the results since the initial directory ownership and ACL state matched what others have reported here. The recovery worked on my machine, although I wouldn't consider the underlying issue resolved until it survives reprovisioning without manual intervention.

    Make the recovery sequence clearerSeparate confirmed results from caveats

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions