Skip to content

Windows sandbox spawn fails with SetTokenInformation(TokenDefaultDacl) error 1344 when workdir is the home directory (and 1920 via per-user WindowsApps pwsh) #36328

Closed as duplicate

Description

@moxiespirit

What version of Codex CLI is running?

Reproduced on 0.144.0, 0.145.0, and 0.146.0 (identical behavior on all three).

Platform

Windows 11 Pro (10.0.22000), x64. codex exec (headless, approval: never).

What happened?

Any model-generated shell command fails before the child process starts:

windows sandbox: runner failed during SpawnChild: SetTokenInformation(TokenDefaultDacl) failed: 1344

Error 1344 is ERROR_ALLOTTED_SPACE_EXCEEDED — the default DACL being set does not fit the token's fixed dynamic buffer.

Root cause (isolated)

The failure is working-directory dependent, not version dependent:

  • Launching codex with the workdir set to the user's home directory (C:\Users\<user>), the sandbox setup enumerates ~147 write roots (setup refresh: processed 147 write roots in ~/.codex/.sandbox/sandbox.<date>.log). The DACL composed from that many roots exceeds the sandbox token's allotted space → 1344 on every spawn, both windows.sandbox = "elevated" and "unelevated".
  • Launching from a normal, narrower project directory, 1344 disappears.

A second, independent failure then surfaces:

windows sandbox: runner error: CreateProcessAsUserW failed: 1920 (The file cannot be accessed by the system.)

because codex resolves pwsh.exe from the per-user Store alias directory (C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\pwsh.exe), which the sandbox's separate user account cannot read by design. Removing WindowsApps from PATH for the codex process (so it falls back to a machine-wide shell) fixes it.

Interactive TUI sessions mask both failures: the sandbox error triggers an approval escalation and the command runs unsandboxed after user approval. Headless exec with approval: never has no escalation path and hard-fails.

Repro steps

  1. On Windows, cd %USERPROFILE% (a home directory with a typical number of subdirectories).
  2. echo "Run the shell command 'echo hello' and report its output." | codex exec -
  3. Observe 1344 before the child starts. Repeat from a small project directory → 1344 gone; if pwsh resolves from per-user WindowsApps, observe 1920 instead.

Expected behavior

The sandbox should either cap/aggregate write-root ACEs so the token DACL fits (or fail with an actionable message naming the workdir breadth as the cause), and should not select a shell binary the sandbox user cannot access.

Workaround (verified)

  • Launch codex exec from a scoped project directory, never the home directory.
  • Strip per-user WindowsApps entries from PATH for the codex process.

With both applied, the sandbox works fully (verified with large multi-hour headless workloads).

Logs

~/.codex/.sandbox/sandbox.<date>.log shows the 147-write-root setup passes and repeated hide users: failed to hide current user profile dir ... 5 (Access is denied.) warnings preceding the spawn failures. Happy to attach full logs on request.

Activity

  1. added
    bug
    CLI
    windows-os
    exec
    sandbox
    on Jul 31, 2026
  2. github-actions commented on Jul 31, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. willribeiro09 commented on Aug 9, 2026

    @willribeiro09

    I tested the suggested workaround from #36328 by starting a new ChatGPT Work chat explicitly attached to a narrow project folder (C:\Users\aginf\pulse) instead of the user home directory.

    The built-in browser still fails to initialize before opening a tab.

    This indicates that, in the ChatGPT Work desktop app, the browser failure persists even with a scoped project directory and is not resolved by the CLI workaround in #36328.

  4. samiko121 commented on Sep 7, 2026

    @samiko121

    I reproduced this on Windows 11 Pro (10.0.22631), Codex Desktop 26.901.6511.0, with codex-cli 0.153.4.

    The failure was identical:

    SetTokenInformation(TokenDefaultDacl) failed: 1344
    

    Local evidence:

    • The working directory was the user profile root: C:\Users\SamiPC.
    • ~/.codex/.sandbox/sandbox.2026-09-07.log reported setup refresh: processed 135 write roots (read roots delegated); errors=[].
    • ~/.codex/cap_sid had grown to 14,912 bytes and contained capability SID mappings for a very large number of paths under the profile.
    • Both ordinary shell execution and the filesystem helper failed before starting the requested process.
    • Switching [windows] sandbox from elevated to unelevated did not resolve an already affected workspace-write session.
    • A direct read-only codex sandbox cmd.exe /d /c echo sandbox-ok invocation succeeded.
    • Resetting the generated cap_sid cache and using sandbox_mode = "read-only" avoids the failure.
    • A narrower project/workspace directory is required before returning to workspace-write; using the whole home directory recreates the large writable-root set.

    This strongly matches the reported default-DACL size exhaustion. It would help if Codex rejected or aggregated overly broad home-directory writable roots before minting one capability SID/ACE per child path, and surfaced a specific diagnostic suggesting a narrower workspace.

  5. superandylin commented on Sep 10, 2026

    @superandylin

    Confirming this on a different machine, and adding a nuance to the "every command fails" framing.

    Environment

    • codex-cli 0.154.0 (npm install), Windows 11 Enterprise 10.0.26200 x64
    • [windows] sandbox = "elevated"; codex doctor reports ✓ sandbox / restricted fs + restricted network, sandbox backend = elevated, sandbox provisioning = complete
    • Interactive CLI session launched with cwd = the user home directory (C:\Users\<user>)
    • Not desktop-app-specific: reproduces in a terminal-launched CLI session, and the MSIX desktop app was not running

    Write-root count is even higher here

    ~/.codex/.sandbox/sandbox.2026-09-10.log:

    setup refresh: spawning ...\codex-windows-sandbox-setup.exe (cwd=C:\Users\<user>, payload_len=12972)
    setup refresh: processed 250 write roots (read roots delegated); errors=[]
    

    250 write roots from a home-directory cwd (this report cites 147), plus the same warning:

    hide users: failed to hide current user profile dir (C:\Users\Default): SetFileAttributesW failed for C:\Users\Default: 5 (Access is denied.)
    

    Worth adding: the setup refresh uses the session cwd, not the per-command working directory. Setting the tool call's workdir to a narrow project subdirectory did not change it — every refresh still logged cwd=C:\Users\<user> and processed 250 write roots.

    Nuance: failures are per-spawn and tool-path dependent, not "every command fails"

    In the same session, same minute:

    Operation Sandbox path Result
    shell command (exec tool) codex-command-runner.exe OK — runs normally
    apply_patch Add File direct write OK
    apply_patch Update / Delete codex.exe --codex-run-as-fs-helper FAIL 1344
    node_repl kernel spawn cua_node node kernel FAIL 1344

    Both failing paths spawn an extra helper process; the shell path keeps working throughout. codex sandbox <cmd> (read-only) also works, consistent with the writable-DACL-buffer theory in this thread.

    Ruled out

    • Runner version — the local runtime was refreshed from codex-command-runner-0.147.0-alpha.6.6.exe to the current 0.15x runner; symptom unchanged.
    • Desktop app build — the MSIX app is on the newest build its Store channel offers (its own log: [windows-store-updater] ... hasUpdate=false ... overallState=NoUpdates), and the newer CDN build is not installable on this device. The failure also reproduces without the app.
    • Resources / AV — 63.7 GB RAM (26.2 GB free), 158 GB free disk, no endpoint protection detected, codex doctor reports the sandbox/update config locally consistent.

    Next

    Re-testing from a scoped project directory to confirm the write-root count drops and the 1344 disappears on the fs-helper and node_repl paths.

  6. stanpoet commented on Sep 21, 2026

    @stanpoet

    Confirming on codex-cli 0.155.1, Windows 11 Pro 10.0.26220, [windows] sandbox = "elevated" and "unelevated" (both fail the same way).

    Token-free repro, no model call needed:

    cd %USERPROFILE%
    codex sandbox -P :workspace cmd /c "echo ok"    -> SetTokenInformation(TokenDefaultDacl) failed: 1344
    codex sandbox -P :read-only cmd /c "echo ok"    -> ok
    cd <any project folder>
    codex sandbox -P :workspace cmd /c "echo ok"    -> ok
    

    Two measurements that narrow it down:

    • It is the number of write roots, not the number of directory entries. A scratch folder holding 600 files and 300 subfolders runs fine under :workspace, because it is granted as a single root. With the profile root as cwd, each top-level child becomes its own write root with its own capability SID: CODEX_HOME/cap_sid holds 733 entries under writable_root_by_path here, and the profile root has 486 children.
    • set_default_dacl in windows-sandbox-rs/src/token.rs builds one EXPLICIT_ACCESS_W per capability SID and SetEntriesInAclW succeeds; it is the following SetTokenInformation(TokenDefaultDacl) that returns 1344, so the limit being hit is the token's dynamic quota for the default DACL, not the 64 KB ACL size.

    Reducing the profile root from 724 to 486 entries did not help, so tidying the folder is not a practical workaround. Starting Codex in a project folder is.

  7. etraut-openai commented on Oct 12, 2026

    @etraut-openai
    Contributor

    (response from codex)

    Closing as a duplicate for the TokenDefaultDacl 1344 failure in #26438. The home-directory/large write-root-count repro and codex sandbox command here narrow when that bug happens and should remain part of #26438. Please track the separate WindowsApps pwsh 1920 problem with #35871; it is not caused by the DACL overflow.

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

    CLIbugexecsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions