Skip to content

Windows: shell commands fail with helper_sandbox_lock_failed (error 5) #45153

Open

Description

@kfb211-sys

What version of the Codex App are you using (From “About Codex” dialog)?

26.908.40834

What subscription do you have?

Plus

What platform is your computer?

windows

What issue are you seeing?

All local shell commands fail before execution, including read-only commands.

Error:
helper_sandbox_lock_failed
lock sandbox bin dir C:/Users//.codex/.sandbox-bin failed
SetNamedSecurityInfoW sandbox dir failed: 5

Sandbox setting: workspace-write.

The built-in dependency diagnostic reports that Codex dependencies are healthy. The displayed dependency bundle version is 26.909.12148.

The affected directory is owned by BUILTIN\Administrators. The reported permissions are:

  • SYSTEM: Modify, Synchronize
  • Administrators: Modify, Synchronize
  • Current user: Modify, Synchronize
  • CodexSandboxUsers: ReadAndExecute, Synchronize

The sandbox.log file was not found at the default .codex/.sandbox/sandbox.log location.

Expected: local commands should start within the permitted workspace.
Actual: every command fails during sandbox initialization.

Feedback ID: 01a08b52-fc41-7b61-a2f9-45373dced88f

What steps can reproduce the bug?

Feedback ID: 01a08b52-fc41-7b61-a2f9-45373dced88f

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    app
    on Sep 13, 2026
  2. added
    bug
    windows-os
    sandbox
    on Sep 13, 2026
  3. github-actions commented on Sep 13, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. butayamada commented on Sep 14, 2026

    @butayamada

    I can reproduce this on the same Codex App build (26.908.40834) on Windows.

    Observed behavior:

    • Every local command, including harmless read-only commands, fails before execution.
    • Error:
      helper_sandbox_lock_failed: lock sandbox bin dir C:\Users\<user>\.codex\.sandbox-bin failed: SetNamedSecurityInfoW sandbox dir failed: 5
    • The failure persists after a normal Windows restart, app Repair, and app Reset.

    Read-only ACL inspection of C:\Users\<user>\.codex\.sandbox-bin showed:

    • Owner: BUILTIN\Administrators
    • Principals include CodexSandboxUsers, SYSTEM, Administrators, and the current user.
    • The current user's advanced permissions do not include Change permissions (WRITE_DAC). No ACL/ownership changes were made.

    This is notable because the current Windows sandbox implementation appears to expect the real-user mask on .sandbox-bin to include WRITE_DAC so the unelevated refresh can reapply the protected DACL.

    I have intentionally not tried manual ACL repair, sandbox-directory deletion, Defender/security-control changes, privilege escalation, or alternate-shell bypasses.

    A supported recovery path would be very helpful, especially a documented way in Codex Desktop to re-run/reprovision the Windows Agent sandbox when this ACL state is encountered. The internal WindowsSandboxSetupStart path exists, but I could not establish a documented user-facing Desktop action that reliably invokes it for this case.

  5. butayamada commented on Sep 14, 2026

    @butayamada

    Follow-up with a more specific local reproduction from the same machine.

    I was able to capture the transition in Codex's own Windows sandbox log. This now looks less like a repository/command-specific problem and more like a sandbox refresh / ACL lifecycle issue on .sandbox-bin.

    Environment at the time of the captured failure:

    • Windows 11 25H2
    • OS build: 26200.9445
    • Codex Desktop: 26.908.4834.0
    • command runner observed in the log: codex-command-runner-0.154.0-alpha.6.2.exe

    Timeline (local time, JST / UTC+9):

    20:39:09.159
    Codex starts a sandbox setup refresh:

    setup refresh: spawning ...\codex-windows-sandbox-setup.exe
    

    20:39:09.726
    The refresh completes successfully:

    setup refresh: processed 3 write roots (read roots delegated); errors=[]
    setup binary completed
    

    20:39:09.743 - 20:39:09.750
    Read ACL handling also completes:

    read-acl-only mode: applying read ACLs
    read ACL run completed
    

    20:39:09.803 - 20:39:09.813
    Codex validates and recopies the command runner into:

    C:\Users\<user>\.codex\.sandbox-bin\codex-command-runner-0.154.0-alpha.6.2.exe
    

    The corresponding exec command then completes successfully at 20:39:14.071:

    Script completed
    Wall time 5.0 seconds
    

    The next command begins only a few seconds later.

    20:39:20.839
    Codex starts another sandbox setup refresh.

    20:39:20.870
    That refresh fails immediately with:

    helper_sandbox_lock_failed:
    lock sandbox bin dir C:\Users\<user>\.codex\.sandbox-bin failed:
    SetNamedSecurityInfoW sandbox dir failed: 5
    

    20:39:20.874
    The setup refresh exits with status 1.

    The exact same failure occurs again at:

    • 20:39:25.220
    • 20:40:09.953
    • 20:40:13.166
    • 21:11:53.026
    • 21:11:58.906
    • 21:12:26.159

    and continues afterward.

    The successful command immediately before the failure was a normal read-only Get-Content operation.

    The command that first failed was also a normal local inspection command (Git state / file hashes / file reads).

    The immediate retry was only:

    Get-Date
    

    and it also failed before command execution with the same sandbox lock error.

    So the failure does not appear to depend on repository contents or command complexity.

    One additional warning occurs during the successful run:

    hide users: failed to hide current user profile dir (C:\Users\Default):
    SetFileAttributesW failed ... error 5
    

    However, the command still completes successfully afterward, so this does not appear to be the immediate blocking failure.

    The important observed transition is:

    successful sandbox refresh
    -> command runner copied into .sandbox-bin
    -> command executes successfully
    -> next sandbox refresh attempts to lock .sandbox-bin
    -> SetNamedSecurityInfoW fails with ERROR_ACCESS_DENIED (5)
    -> subsequent exec attempts keep failing the same way
    

    This is consistent with a possible non-idempotent ACL/DACL refresh issue on .sandbox-bin, although I cannot confirm the root cause from the client side.

    Additional timing: Codex Desktop had been updated earlier that evening from 26.903.9818.0 to 26.908.4834.0. I am not claiming the app update alone is the root cause, because one sandboxed command still succeeded after the update. The more specific trigger appears to be the transition between the successful refresh and the immediately following refresh.

    The problem persists across:

    • Codex restart
    • Windows reboot
    • Windows app Repair
    • Windows app Reset

    I have deliberately not changed the .sandbox-bin ACL manually or disabled the sandbox, to avoid modifying the security boundary before the underlying cause is understood.

    If useful, I can provide a sanitized excerpt of C:\Users\<user>\.codex\.sandbox\sandbox.2026-09-12.log showing the successful refresh immediately followed by the failing refresh.

  6. kangx584 commented on Sep 15, 2026

    @kangx584

    I am seeing the same helper_sandbox_lock_failed / Windows error 5 failure on the latest Codex Desktop for Windows.

    Environment

    • Windows 11 Professional, build 26200
    • Codex Desktop: 26.908.40834
    • Codex CLI doctor version when diagnosed: 0.149.0
    • Approval policy: OnRequest
    • Sandbox backend: elevated

    Exact failure

    codex doctor reports:

    sandbox provisioning = failed
    error code = helper_sandbox_lock_failed
    rerun elevated setup for the authoritative Codex home or ask IT
    

    Manual elevated sandbox setup also fails:

    helper_sandbox_lock_failed:
    lock sandbox bin dir C:\Users\<user>\.codex\.sandbox-bin failed:
    SetSecurityInfo sandbox dir failed: 5
    

    The Codex Desktop Finish Windows setup flow also fails.

    Rebooting Windows did not resolve the issue.

    Workspace ownership

    The affected project itself appears normal:

    C:\agent-work                         <machine>\<user>
    C:\agent-work\<project>      <machine>\<user>
    C:\agent-work\<project>\.git <machine>\<user>
    

    Sandbox accounts

    Both sandbox accounts exist and are enabled:

    CodexSandboxOffline  True
    CodexSandboxOnline   True
    

    Both are members of CodexSandboxUsers.

    .sandbox-bin ownership and ACL

    Owner: <machine>\<user>
    AreAccessRulesProtected: True
    
    NT AUTHORITY\SYSTEM        Modify
    BUILTIN\Administrators     Modify
    <user>                     Modify
    CodexSandboxUsers          ReadAndExecute
    

    icacls confirms:

    CodexSandboxUsers:(OI)(CI)(RX)
    SYSTEM:(OI)(CI)(M)
    Administrators:(OI)(CI)(M)
    <user>:(OI)(CI)(M)
    

    So the expected ACLs appear to already be present, but the sandbox setup still fails while attempting to apply security information.

    Other diagnostics

    • Codex Workspace dependency diagnostic reports healthy.
    • Authentication and connectivity are healthy.
    • Project files are accessible.
    • The failure affects even simple read-only shell commands, which then require the fallback approval path.
    • Rebooting did not fix the problem.
    • I have not manually modified the sandbox ACLs.
    • I have not run takeown, deleted .sandbox-bin, or manually deleted/recreated the sandbox accounts.
    • The repository root and .git directory are owned by my normal Windows user, not by CodexSandboxOffline or CodexSandboxOnline.

    This appears consistent with reports where .sandbox-bin already has the expected ACLs but the refresh/setup path still returns Windows error 5.

    Please let me know if any additional diagnostic output would be useful. I can provide a redacted codex doctor --json report if needed.

  7. fox8329td commented on Sep 15, 2026

    @fox8329td

    Additional reproducible diagnostic from Windows app 26.908.4834.0:

    We isolated the minimum ACL right required to make the sandbox start. In the failing state, .codex\.sandbox-bin is ACL-protected (AreAccessRulesProtected=True), owner is BUILTIN\Administrators, and the ACL is:

    • SYSTEM: Modify, Synchronize
    • Administrators: Modify, Synchronize
    • current user: Modify, Synchronize
    • CodexSandboxUsers: ReadAndExecute, Synchronize

    With that ACL, the next sandbox initialization fails with:
    helper_sandbox_lock_failed: ... SetNamedSecurityInfoW sandbox dir failed: 5.

    Instead of granting Full Control, we added ONLY WRITE_DAC to the current user:
    icacls "$env:USERPROFILE\.codex\.sandbox-bin" /grant "DOMAIN\user:(WDAC)"

    Get-Acl then showed an additional Allow ChangePermissions ACE. Without restarting Windows/app, a Codex task successfully performed two consecutive read-only file reads in the same execution.

    Immediately afterward, Get-Acl showed that Codex/helper had removed the ChangePermissions ACE and restored the user to Modify only. A new Codex task then immediately failed again with helper_sandbox_lock_failed / SetNamedSecurityInfoW error 5.

    Reproduction cycle:

    1. ACL = Modify only -> sandbox initialization fails.
    2. Add only WRITE_DAC -> sandbox initialization succeeds and task runs.
    3. Codex/helper rewrites .sandbox-bin ACL and removes WRITE_DAC.
    4. Next task -> sandbox initialization fails with error 5 again.

    This strongly suggests a self-lockout in the Windows sandbox ACL hardening/refresh path: setup requires WRITE_DAC on .sandbox-bin, but the ACL it leaves behind removes that capability before the next refresh. Full Control is not required; WRITE_DAC alone is sufficient in this reproduction.

  8. DarioScibetta commented on Sep 15, 2026

    @DarioScibetta

    I am also experiencing this Windows sandbox initialization failure. It blocks ordinary local shell commands and the browser-reading/computer-use runtime.

    Observed error (user path redacted):

    helper_sandbox_lock_failed:
    lock sandbox bin dir C:\Users\<user>\.codex\.sandbox-bin failed:
    SetNamedSecurityInfoW sandbox dir failed: 5
    

    The browser tool fails on await cua.getState() before inspecting any page. Diagnostics report that the Node kernel exits with code 1 and the sandbox error above. A separate minimal Node runtime test also fails, so the failure occurs before interacting with the target website. Resetting the browser runtime did not resolve it.

    Read-only inspection of .sandbox-bin showed:

    • Owner: BUILTIN\Administrators
    • AreAccessRulesProtected: True
    • SYSTEM, Administrators and current user: Modify, Synchronize
    • CodexSandboxUsers: ReadAndExecute, Synchronize

    No ACL, ownership or security-setting changes were made during this diagnosis.

    In-app feedback ID: 019e4a0b-6501-7b13-9531-2094a70d00e7

    Please use the feedback to correlate the diagnostics. A supported recovery procedure or a fix for the sandbox initialization issue would be appreciated.

  9. Ray-iTech commented on Sep 15, 2026

    @Ray-iTech

    I’m reproducing this failure in the VS Code extension, not just the desktop app.

    Environment:

    • Windows 11 Pro, version 25H2, OS build 26200.9168
    • Extension: openai.chatgpt, version 26.908.40401
    • Native Windows / PowerShell

    Error:
    helper_sandbox_lock_failed: lock sandbox bin dir C:\Users\[USER]\.codex\.sandbox-bin failed: SetNamedSecurityInfoW sandbox dir failed: 5

    The initial administrator-approved setup logged successful firewall configuration and “setup provisioning binary completed.” The subsequent setup refresh failed with the error above.

    Restarting VS Code and retrying did not resolve it. Running VS Code as administrator once allowed the setup warning to disappear, but after closing all windows and reopening normally, every tested command was blocked before execution:

    • Get-Location
    • git --no-optional-locks status --short
    • git log -2 --oneline

    The session reported workspace-write with restricted network access, but sandbox initialization failed.

    The folder owner is BUILTIN\Administrators. SYSTEM, Administrators, and my user have Modify/Synchronize; CodexSandboxUsers has ReadAndExecute/Synchronize.

    I have not manually changed ACLs or ownership, selected the unelevated fallback, or enabled Full access. Please provide a supported repair that preserves the stronger native sandbox while running VS Code normally.

  10. LeLiuUnimelb commented on Sep 16, 2026

    @LeLiuUnimelb

    I can reproduce this on Windows Codex Desktop with the same failure, and it affects more than shell commands.

    Observed behavior

    • The built-in patch tool can sometimes create a new temporary file, but then cannot reliably read or delete an existing .md file. The app reports that the same sandbox lock error causes the read/delete phase to be denied.
    • Built-in browser / computer-use initialization also fails.
    • This began within the last few days after a Codex desktop update. The app was repaired once through Windows Settings after that update, but the issue persists.

    Local evidence

    Current copied runner:

    codex-command-runner-0.154.0-alpha.6.2.exe
    

    %USERPROFILE%\\.codex\\.sandbox\\setup_error.json:

    {
      "code": "helper_sandbox_lock_failed",
      "message": "lock sandbox bin dir C:\\Users\\<user>\\.codex\\.sandbox-bin failed: SetNamedSecurityInfoW sandbox dir failed: 5"
    }

    The contemporaneous sandbox log shows:

    setup refresh: spawning ...\\codex-windows-sandbox-setup.exe
    setup error: helper_sandbox_lock_failed: lock sandbox bin dir ...\\.sandbox-bin failed: SetNamedSecurityInfoW sandbox dir failed: 5
    setup refresh: exited with status ExitStatus(1)
    read-acl-only mode: applying read ACLs
    read ACL run completed
    

    The fallback to read-acl-only mode appears to explain why temporary-file creation can succeed but existing-file read/delete operations are later denied.

    The affected .sandbox-bin directory is owned by BUILTIN\\Administrators. Its normal ACL matches the pattern reported here:

    • SYSTEM: Modify
    • Administrators: Modify
    • current Windows user: Modify
    • CodexSandboxUsers: ReadAndExecute

    As an experiment, I granted the current user Full Control on only .sandbox-bin through an elevated UAC prompt. The grant succeeded, but Codex still reproduced the same SetNamedSecurityInfoW ... 5 setup failure and then reverted the effective current-user rule to Modify during its fallback flow. Therefore a one-off current-user ACL grant is not a durable workaround.

    No project data was changed as part of the diagnosis.

  11. zhenglitian commented on Sep 16, 2026

    @zhenglitian

    delete C:\Users\Zheng.codex.sandbox-bin
    right click create folder .sandbox-bin
    but .sandbox-bin is also empty ,it's normally?

  12. DarioScibetta commented on Sep 19, 2026

    @DarioScibetta

    Retested on September 19, 2026, at approximately 16:25 UTC after receiving a couple of app updates. The current installed app version is not yet verified.

    Two consecutive attempts to open Google Search in the built-in browser failed:

    let tab = await cua.createBrowserTab("iab", "https://www.google.com/", { visible: true });

    Both returned:

    trusted Node process exited unexpectedly; kernel reset, rerun your request
    

    The second attempt followed the automatic kernel reset reported by the tool. Neither attempt returned page or tab state, so browser navigation and button interactions could not be tested.

    A subsequent read-only attempt to retrieve the installed Codex app version also failed before command execution with the original error (user path redacted):

    helper_sandbox_lock_failed: lock sandbox bin dir C:\Users\<user>\.codex\.sandbox-bin failed: SetNamedSecurityInfoW sandbox dir failed: 5
    

    The original sandbox failure therefore remains reproducible. I cannot establish whether the browser runtime exit has the same root cause or is a separate issue.

    No ACL, ownership, or security-setting changes were made during this retest. Could the team confirm whether the browser runtime symptom belongs in this issue and advise on a supported recovery or fix?

  13. Migbal commented on Sep 28, 2026

    @Migbal

    On 28 September 2026, Codex Desktop on Windows reproduced helper_sandbox_lock_failed when opening .codex/.sandbox-bin. Even read-only shell commands fail before execution.

    Restarting the app and its sandbox service did not resolve the earlier failure. A temporary permission adjustment restored normal operation, but the problem returned later that day and interrupted an active workflow.

    Current permissions and the trigger for this recurrence could not be re-verified because command execution is blocked. Please investigate and provide a supported, durable recovery procedure. The temporary recovery has not resolved the underlying problem.

  14. hjachoe commented on Oct 5, 2026

    @hjachoe

    Follow-up: targeted permission repair retained after a normal desktop restart.

    On Windows 11, Codex Desktop 26.930.3930.0 still failed before launching even Get-Date with the elevated Windows sandbox selected:

    helper_sandbox_lock_failed
    SetNamedSecurityInfoW sandbox dir failed: 5

    The existing .codex/.sandbox-bin directory was owned by BUILTIN\Administrators with protected inheritance. The interactive user had Modify/Synchronize but lacked ChangePermissions (WRITE_DAC). CodexSandboxUsers had ReadAndExecute/Synchronize.

    An earlier attempt through the documented windowsSandbox/setupStart interface reported success, but the folder permissions remained unchanged and actual command execution still failed.

    After saving the original security descriptor, a user-approved administrator process added only a non-inheriting ChangePermissions allow entry for the interactive user on the helper directory. Ownership, existing rules and inheritance protection were preserved; no Full Control grant or recursive manual permission edit was used.

    Separate Get-Date and Get-Location calls then succeeded. Codex's normal refresh consolidated the user's entry into inheritable Modify/ChangePermissions/Synchronize. Other accounts' folder rules remained identical to the original; CodexSandboxUsers retained only ReadAndExecute/Synchronize on both the folder and the inspected helper executable.

    After fully quitting and reopening the desktop app normally, both commands still succeeded separately. Commands used a dedicated CodexSandboxUsers account distinct from the interactive user, without administrator privileges. The repaired permission was retained and the folder descriptor matched its pre-restart state. The sandbox setting remained elevated.

    This is a tested local workaround, not proof of a permanent fix or a comprehensive isolation assessment. No raw logs, account identifiers, configuration files or security descriptors are attached.

    Could maintainers confirm this is the intended permission state and provide a supported migration/recovery path for existing helper directories lacking WRITE_DAC?

  15. DarioScibetta commented on Oct 7, 2026

    @DarioScibetta

    Retest on 7 October 2026: local shell commands now succeed, but two attempts to open LinkedIn through the in-app browser failed before page access. The retry reported windows sandbox failed: helper_unknown_error: setup refresh had errors. No permissions or sandbox settings were changed during this test. Is there a supported recovery procedure, or should this remaining browser failure be tracked separately?

  16. butayamada commented on Oct 18, 2026

    @butayamada

    Update — 18 October 2026: MXC-selected execution has allowed development to resume on the machine from my earlier reports.

    The change was to select the MXC Windows sandbox and restart the app:

    [windows]
    sandbox = "mxc"

    Explicit CLI launches with -c windows.sandbox=mxc were also used during testing. Since the switch on 16 October, local file operations and compilation/build work have been able to proceed, rather than every shell command failing before execution. On 18 October, ordinary PowerShell file reads and local checkpoint/archive operations also completed successfully.

    Current OS version/build read from the registry: 25H2, 26200.9711. I have not re-verified the current Desktop package version because the package query was denied in the sandbox.

    Important limits:

    • I have not switched back to the previous sandbox implementation to retest the original .sandbox-bin / WRITE_DAC failure. This is an update about a usable alternative path, not confirmation that the original defect is fixed.
    • The saved MXC setting alone is not independent proof of the effective backend of every app session. The positive observation is successful work after MXC selection, including explicit MXC CLI testing.
    • This is not a comprehensive isolation assessment or a claim that every workflow now works.

    Thank you for the MXC path—it has been useful in restoring practical development work. Is there any additional diagnostic information that would help distinguish this improvement from a fix to the legacy sandbox issue?

  17. ckvupu0 commented on Oct 20, 2026

    @ckvupu0

    I encountered the same Windows sandbox setup failure on the Codex desktop app.

    Environment

    • Windows 11 Pro, build 26200.9445 (25H2)
    • Codex MSIX package version: 26.1013.4894.0

    Error
    helper_sandbox_lock_failed
    SetNamedSecurityInfoW sandbox dir failed: 5

    The existing %USERPROFILE%\.codex\.sandbox-bin directory was owned by BUILTIN\Administrators, had inheritance disabled, and had explicit Modify access for SYSTEM, Administrators, and my user, with ReadAndExecute for CodexSandboxUsers. Running PowerShell elevated did not resolve the setup failure.

    Workaround that made the setup warning disappear
    I fully closed Codex, renamed .sandbox-bin to a timestamped backup (did not delete it), relaunched Codex, and retried setup. The “Windows setup incomplete” prompt no longer appeared afterward.

    This suggests the setup flow cannot reliably recover from an existing helper directory ACL/security-descriptor state. It would be better if the helper detected/repaired this state itself, or provided a clear recovery path, rather than requiring users to manually rename a security-sensitive directory. I have not yet established whether this fully prevents recurrence, but the workaround is reproducible in principle and avoids deleting the original directory.

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

    appbugsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions