Skip to content

Windows sandbox is permanently unusable: setup refresh races the app's own runtime helpers and always fails with ERROR_SHARING_VIOLATION #52566

Open

Description

@huangprometheus-dotcom

Environment
OS: Windows 11 (10.0.26200), zh-CN
Codex desktop app: 26.908.70816
Codex CLI observed across: 0.154.0-alpha.6.2, 0.155.0-alpha.2.6, 0.155.0-alpha.9, 0.162.0-alpha.2
Runtime: %LOCALAPPDATA%\OpenAI\Codex\runtimes\cua_node\3dd31cfff853001c
Model provider: custom (DeepSeek via the native Responses API) — unrelated to this bug, see note at the end
Symptom
Every local-process capability fails at initialization, before any command runs:

代码块

Failed to create unified exec process: helper_unknown_error: setup refresh had errors
windows sandbox failed: helper_unknown_error: setup refresh had errors
Affects all three paths: shell command execution, the Node runtime, and file writes. The app's own file/thread APIs still work, so the failure is isolated to the sandbox helper bring-up.

Persists across app restart and machine reboot.

Root cause
setup refresh must open files inside the runtime directory to apply ACLs. Those same files are held open by processes the app has already spawned from that directory, so the open fails:

代码块

[2026-10-09T12:13:48.074258+00:00] runtime read/execute validation failed:
validate runtime read/execute access on
C:\Users<user>\AppData\Local\OpenAI\Codex\runtimes\cua_node\3dd31cfff853001c\bin\node_repl.exe:
open ACL target for root-only update:
另一个程序正在使用此文件,进程无法访问。 (os error 32)
["another program is using this file, the process cannot access it"]

[2026-10-09T12:13:48.078] setup refresh: processed 4 write roots (read roots delegated);
errors=["runtime read/execute validation failed: ..."]
[2026-10-09T12:13:48.078] setup refresh completed with errors: [...]
[2026-10-09T12:13:48.078] setup error: setup refresh had errors
[2026-10-09 20:13:48.082 codex.exe] setup refresh: exited with status ExitStatus(ExitStatus(1))
os error 32 is ERROR_SHARING_VIOLATION — the file is open by another process with a share mode that forbids the write/open the ACL update needs.

The ordering is the bug
代码块

20:12:46 codex.exe (app) starts
20:13:21 node_repl.exe spawned from the runtime dir ← locks its own executable
20:13:48 setup refresh runs ← tries to ACL node_repl.exe → fails
Files observed as the failing target across runs (whichever is locked first):

...\bin\node_repl.exe
...\bin\node.exe
...\bin\node_modules@oai\sky\bin\windows\swift\x64\VCRUNTIME140_1.dll (loaded by codex-computer-use-swift.exe)
Experiments that isolate it
Clean window ⇒ setup succeeds. With the app and all runtime processes stopped, and the CodexSandboxService.OpenAI.Codex service stopped, the same command produces:

代码块

setup refresh: processed 0 write roots (read roots delegated); errors=[]
and the stale %USERPROFILE%.codex.sandbox\setup_error.json disappears. So the ACL logic itself is fine — this is purely a race.

Pre-granting the ACLs does not help. I applied a non-inherited ReadAndExecute, ReadAttributes, Synchronize ACE for CodexSandboxUsers to all 2365 files under the runtime directory. Validation still failed on the locked file. So validation genuinely needs to open the target; it does not skip already-correct targets.

The app process itself holds the handle. With zero node_repl.exe processes running, an exclusive-open test on node_repl.exe still failed; terminating codex.exe released it immediately.

Reboot does not help because the app re-spawns the lockers, and setup refresh runs again on subsequent sessions.

No user-config workaround exists. Removing [mcp_servers.node_repl], disabling the computer-use@openai-bundled / unified-computer-use@openai-bundled plugins, and disabling the notify hook did not stop node_repl.exe or codex-computer-use-swift.exe from being spawned by the desktop app. The spawn is internal to the app.

Impact
The Windows sandbox feature cannot initialize at all, so no session can execute any local command. The app is effectively unusable for any task involving a shell, the Node runtime, or file writes.

Workaround
Bypassing the Windows sandbox entirely avoids setup refresh, and everything works:

toml

~/.codex/config.toml

sandbox_mode = "danger-full-access"
or per-invocation:

代码块

codex exec --dangerously-bypass-approvals-and-sandbox "..."
Verified: sandbox: danger-full-access then the command executes normally.

This is a workaround, not a fix — it removes OS-level isolation for every command.

Suggested fix
Any of these would resolve it:

Run setup refresh before spawning anything from the runtime directory. The current order (spawn first, ACL second) makes the failure deterministic.
Treat a locked target as non-fatal. If the required ACE is already present, or the file is simply in use, log and continue instead of failing the whole refresh. Right now one ERROR_SHARING_VIOLATION on one file aborts the entire sandbox bring-up.
Stage the ACL work off the live tree. ACL a staged copy (or a temp junction) and swap it in, so ACL application never touches in-use binaries.
Retry with backoff and don't fail the session on a transient sharing violation.
Note on the provider
This reproduces with the stock sandbox path and is unrelated to any custom model provider: the failures are in codex-windows-sandbox-setup.exe / codex-command-runner bring-up, which never reaches the model. I mention it only so the report isn't mistaken for a provider-integration issue.

Diagnostic commands used
powershell

failing target + reason

Get-Content "$env:USERPROFILE.codex.sandbox\sandbox.$(Get-Date -Format yyyy-MM-dd).log" |
Select-String 'setup refresh|validation failed'

reproduce quickly (no model turn needed)

codex sandbox -- echo test

confirm an exclusive lock on the failing target

$f = "\bin\node_repl.exe"
try { $fs=[IO.File]::Open($f,'Open','ReadWrite','None'); $fs.Close(); 'unlocked' }
catch { 'LOCKED: ' + $_.Exception.Message }

Activity

  1. added
    bug
    app
    windows-os
    sandbox
    on Oct 9, 2026
  2. huangprometheus-dotcom commented on Oct 9, 2026

    @huangprometheus-dotcom
    Author

    Environment

    Summary

    After the setup refresh issue in #52488 is worked around, sandboxed command execution works — but any Chromium-based browser launched inside the sandbox crashes immediately, so no HTML→PNG/PDF rendering and no browser automation is possible from a sandboxed command.
    This blocks an entire class of legitimate desktop work: generating slide/diagram assets, screenshotting local HTML, exporting PDFs, and any Playwright/Puppeteer-driven step.

    Symptom

    Launching Edge from a sandboxed command produces a Windows crash dialog:

    msedge.exe - 应用程序错误
    应用程序发生异常 unknown software exception (0x80000003),位置为 0x00007FFBA50C458D。
    

    0x80000003 is STATUS_BREAKPOINT. Codex's own commentary in-session reported:

    Playwright's spawn is blocked, but a direct Start-Process launch worked.
    Edge accepts the flags but its renderer sandbox can't get the accesses it needs, ...
    

    Root cause (from measured behavior)

    Sandboxed commands run as a restricted account (CodexSandboxOffline / CodexSandboxOnline). That identity has no write access to the real user's browser profile directory, and Chromium cannot initialize without it.

    Step 1 — default paths: profile/crashpad write denied

    [ERROR:third_party\crashpad\crashpad\util\file\file_io_win.cc:191]
    CreateFile C:\Users\<user>\AppData\Local\Microsoft\Edge\...   → denied
    

    Step 2 — --no-sandbox alone is not enough

    Chromium's own sandbox is disabled, but crashpad still targets %LOCALAPPDATA%\Microsoft\Edge.

    Step 3 — redirecting profile/crash dirs into the workspace also denied

    Flags used:

    --headless --disable-gpu --no-sandbox --disable-crash-reporter
    --user-data-dir=<workspace>\_edgetest\profile
    --crash-dumps-dir=<workspace>\_edgetest\crash
    --screenshot=<workspace>\_edgetest\out.png --window-size=600,200
    

    Result:

    [ERROR:third_party\crashpad\crashpad\client\crash_report_database_win.cc:685]
    CreateDirectory D:\...\_edgetest\profile\Crashpad: 拒绝访问。 (0x5)
    

    So even a path inside the workspace is not writable by the sandbox identity in this invocation.

    Step 4 — granting the restricted account access is not possible for the user

    Attempting to add a Modify ACE for CodexSandboxOffline on %LOCALAPPDATA%\Microsoft\Edge fails:

    该进程不具有执行此操作所需的 "SeSecurityPrivilege" 特权
    

    i.e. it requires administrator rights. Users cannot self-serve this fix.

    Step 5 — the same command outside the sandbox succeeds

    The identical headless Edge invocation, run as the normal user (outside the Codex sandbox), renders correctly:

    msedge.exe --headless --disable-gpu --no-sandbox --screenshot=out.png --window-size=800,400 file:///...
    → screenshot written (7 KB)
    

    This isolates the failure to the sandbox execution context, not to Edge, the flags, or the HTML.

    Reproduction

    1. Configure [windows] sandbox = "unelevated" so setup refresh no longer fails (per Windows sandbox unusable: setup refresh fails with os error 32 (app-tools MCP holds the cua_node runtime exe) #52488).
    2. From a sandboxed command, run:
      msedge.exe --headless --disable-gpu --no-sandbox --screenshot=out.png --window-size=800,400 file:///C:/path/page.html
      
    3. Expected: out.png written.
      Actual: msedge.exe crash dialog, 0x80000003; no output file.

    Impact

    • No HTML→PNG/PDF rendering from Codex on Windows (a primary workflow for document/slide/diagram generation).
    • No browser automation (Playwright/Puppeteer steps cannot start).
    • There is no user-side configuration that fixes it: sandbox mode, browser flags, profile redirection, and ACL changes all fail or require admin.

    Workaround (working, but should not be necessary)

    Run the browser outside the sandbox and pass content through the filesystem, so sandboxed commands never spawn a browser:

    1. A small local watcher service runs as the normal user (outside Codex), e.g. watching _render-inbox\*.html.
    2. The sandboxed agent only writes the HTML (a permitted workspace write).
    3. The service renders it with headless Edge and writes _render-outbox\<name>.png.
    4. The agent reads the PNG (a permitted workspace read).
      No network, no privilege escalation, no browser process inside the sandbox. Verified working end to end.
      (Relevant because it shows the capability gap can be closed by product design: if Codex shipped an out-of-sandbox render helper, users would not need to build one.)

    Suggested fix

    Any of these would resolve it:

    1. Add a supported out-of-sandbox path for local rendering / browser work, so sandboxed sessions can request it without weakening the sandbox for everything else.
    2. Allow-list the browser profile and crashpad directories for the sandbox identity, so Chromium can initialize. Today those ACL grants require admin, and users cannot apply them.
    3. Detect and report this specific failure clearly. The current outcome is a Windows crash dialog plus 0x80000003; a message such as "Chromium-based browsers cannot run inside the Windows sandbox; run this step outside the sandbox" would save users a long diagnosis.
    4. Document the limitation in the sandbox docs, alongside the existing Playwright's spawn is blocked notice, so the behaviour is expected rather than looking like a regression.

    Notes

    Diagnostic commands used

    $edge = 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'
    # 1) inside the sandbox (fails)
    codex sandbox -- $edge --headless --disable-gpu --no-sandbox `
      --user-data-dir=$env:TEMP\ep --crash-dumps-dir=$env:TEMP\ec `
      --screenshot=$env:TEMP\out.png --window-size=600,200 file:///C:/path/t.html
    # 2) outside the sandbox (succeeds)
    & $edge --headless --disable-gpu --no-sandbox `
      --screenshot=$env:TEMP\out.png --window-size=600,200 file:///C:/path/t.html
    # 3) confirm the ACL grant requires admin (fails without elevation)
    $acl = Get-Acl "$env:LOCALAPPDATA\Microsoft\Edge"
    $acl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(
      'CodexSandboxOffline','Modify','ContainerInherit, ObjectInherit','None','Allow')))
    Set-Acl "$env:LOCALAPPDATA\Microsoft\Edge" $acl   # → SeSecurityPrivilege required
  3. msggolden commented on Oct 28, 2026

    @msggolden

    Additional user-confirmed observation for the Chromium launch failure described in the October 9 comment (not confirmation of the separate runtime setup/OS error 32 issue):

    On a Windows machine running the Codex desktop app, Google Chrome launched by an agent shell command sometimes failed with a chrome.exe application-error dialog: unknown software exception 0x80000003. Launching Chrome manually from CMD worked. Restarting Windows and omitting the Chrome profile argument did not resolve the agent-initiated failure.

    The workaround that has worked in subsequent runs was to execute only the Chrome launcher through Codex's approved out-of-sandbox exec_command path (sandbox_permissions="require_escalated"), as the normal signed-in Windows user. This was not a PowerShell RunAs/administrator launch. The launcher could retain its existing profile-directory and starting-URL arguments.

    No browser --no-sandbox flag, profile reset, directory ACL changes, or global approval/sandbox bypass was needed. Once Chrome was launched this way, the official Chrome extension connection could read the task tab and the workflow completed. On October 28, the first scheduled connection attempt succeeded without restarting Codex.

    This is one machine's observed workaround, not a universal fix or proof that every earlier extension/controller failure had the same cause. It may be useful to distinguish browser-launch context failures from actual extension-connection failures, and to document a supported, approval-gated browser-launch path. The proposed profile/Crashpad write-access explanation remains a hypothesis for this particular case. Summary prepared with Codex assistance, based on this user-authorized troubleshooting session. Workaround observed through October 28, 2026; the exact Codex app and Chrome versions were not recorded for the original failing comparison.

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