Skip to content

Windows sandbox: elevated setup for one CODEX_HOME rotates a machine-wide secret and UAC-storms every other home #40627

Open

Description

@Epyov

Summary

The Windows restricted-token sandbox stores per-home setup state
($CODEX_HOME/.sandbox/setup_marker.json) but manages MACHINE-WIDE
sandbox accounts (CodexSandboxOffline / CodexSandboxOnline). An
elevated sandbox setup run for one CODEX_HOME rotates a machine-wide
secret and records it only in that home's marker, invalidating every
other home's marker. Any subsequent run under a different CODEX_HOME
logs sandbox setup required: sandbox users missing or incompatible with marker version and attempts elevated re-setup — which raises a UAC
consent prompt PER COMMAND for non-interactive exec runs. Two concurrent
codex exec sessions under different homes produce a continuous UAC
prompt storm on the user's desktop, and validity ping-pongs to whichever
home ran elevated setup last.

Reproduction (measured)

  1. Three homes: ~/.codex, ~/.codex-overflow, ~/.codex-overflow2,
    each authenticated, same Windows user. Markers initially valid.
  2. Run an elevated codex sandbox cmd /c exit 0 with
    CODEX_HOME=~/.codex-overflow2 (its first-time setup).
    → ~/.codex-overflow2/.sandbox/setup_marker.json created.
  3. Start codex exec ... -s workspace-write runs under ~/.codex and
    ~/.codex-overflow.
    → both homes log sandbox setup required: sandbox users missing or incompatible with marker version on every command; each attempt
    raises a UAC prompt (observed ~9 s cadence; 30+ prompts in minutes).
  4. Elevated re-setup per home (writing that home's marker with the new
    secret) ends its storm; refined measurement an hour later: once every
    home's marker holds the CURRENT secret, a marker-version mismatch
    self-heals silently and unelevated on the next run (marker rewritten,
    no prompt). The storm flavor occurs when a home's marker holds a
    ROTATED-AWAY secret: the unelevated refresh exits -1
    (ExitStatus(4294967295)) and the run escalates to a UAC consent per
    command.
  5. Copying a valid setup_marker.json byte-identical to a sibling home
    does NOT directly revalidate it (sandbox setup required still
    logged once), but the next run self-heals it silently — consistent
    with per-home fields inside the marker plus a shared secret.

Log evidence (representative lines, ~/.codex-overflow/.sandbox/sandbox.2026-08-24.log):

[... codex.exe] sandbox setup required: sandbox users missing or incompatible with marker version
[...] read-acl-only mode: applying read ACLs
[...] read ACL run completed
[... codex.exe] setup refresh: exited with status ExitStatus(ExitStatus(4294967295))

Healthy sibling in the same minutes:

[...] granting write ACE to C:\dev\wt\<worktree> for sandbox group and capability SID
[...] setup refresh: processed 2 write roots (read roots delegated); errors=[]
[... codex-windows-sandbox-setup.exe] setup binary completed

Impact

  • A first-time sandbox setup for a NEW CODEX_HOME (which resets the
    shared accounts' secret) instantly breaks every other home on the
    machine until each is re-set-up elevated — during which any running
    codex exec sessions on those homes storm the desktop with UAC
    consents.
  • Headless/automation runs on a stale home escalate to interactive UAC
    prompts — a prompt storm on whatever desktop is logged in, and the
    runs fail closed (Failed to write file ...) when declined.
  • Read-only runs still pass on a stale home, so simple health probes
    report healthy while builds storm — the failure is invisible until
    write time.

Asks

  1. Store the sandbox secret so multiple CODEX_HOMEs on one machine can
    share the accounts (machine-scoped state keyed off the accounts, not
    per-home markers), or namespace the sandbox accounts per home.
  2. Never raise interactive elevation from non-interactive codex exec
    runs — fail with a typed error instead.
  3. Document the one-home-at-a-time constraint if it is intended.

Environment

  • codex-cli 0.149.0 (npm @openai/codex), Windows 11 Home 10.0.26200
  • Sandbox binaries: codex-windows-sandbox-setup.exe,
    codex-command-runner-0.149.0.exe (vendored)
  • One Windows user; homes provisioned per Codex-bank pattern; setup
    markers version 5.
  • Related open issue: [Windows] Desktop and npm CLI alternate elevated sandbox marker state, causing repeated setup/UAC prompts #36865
    (desktop app vs npm CLI ping-ponging one shared ~/.codex marker).
    This report is the multi-CODEX_HOME form of the same class: three
    CLI homes, one Windows user, machine-wide sandbox accounts, per-home
    markers. 36865 does not cover that repro.

Addendum 2026-08-25: elevated from-scratch recreate fails (CreateProcessAsUserW: 2)

Measured 2026-08-25 ~10:27 AM on the same machine, attended and
elevated. With one home (.codex-overflow2) reset to from-scratch
state (its setup_marker.json and deny_read_acl_state.json
deleted), an ELEVATED codex sandbox windows setup run from an
administrator PowerShell fails immediately:

windows sandbox failed: CreateProcessAsUserW failed: 2 (The system
cannot find the file specified.) | cwd=C:\dev\wt\worktree-reaper |
cmd=windows setup | env_u16_len=4506 | si_flags=256 |
creation_flags=525312

The home's own sandbox log records only START: windows setup and
nothing further. Read-only probes on the same home still pass
(cmd /c exit 0 spawns fine), so the failure is specific to the
setup path's spawn-as-sandbox-user. Practical consequence: on a
machine in this state there is NO working recovery path for a broken
home short of reinstalling the codex runtime — per-home state deletion
plus elevated re-setup, the documented recovery, cannot complete.
This compounds the marker-rotation defect above: any home that loses
the current machine-wide secret cannot be re-qualified.

Activity

  1. added
    bug
    CLI
    windows-os
    sandbox
    exec
    on Aug 25, 2026
  2. bielxdh3 commented on Sep 19, 2026

    @bielxdh3

    Independent multi-CODEX_HOME orchestration use case that may be useful for impact/testing.

    I am running a local configured-actor orchestrator with two separately authenticated Codex profiles under different CODEX_HOME roots (primary orchestrator + secondary App Server actor). On Codex 0.154.0, a real read-only App Server Architect turn under the secondary profile completes successfully.

    That is a useful negative control, but importantly it does not prove the multi-home write path is healthy. It reinforces the warning in this issue that read-only probes can look fine while the failure only appears when a home needs the Windows write sandbox.

    This matters directly for failover orchestration: if an external Executor is unavailable, I want an explicitly user-authorized Codex profile to be eligible for the Executor role. That requires workspace-write under a second CODEX_HOME. I am deliberately not treating the successful read-only turn as a green light for that.

    Current design is fail-closed: no automatic substitution, and only profiles explicitly allowed for a fallback role can be selected.

    If there is a candidate fix/branch for the machine-wide secret / per-home marker interaction, I can test it against:

    • two isolated CODEX_HOME profiles;
    • App Server headless turns;
    • read-only Architect/Reviewer;
    • workspace-write Executor;
    • sequential and concurrent profile use.

    No credentials or auth files need to be shared for the repro.

  3. JeffLepp commented on Sep 27, 2026

    @JeffLepp

    Source-level follow-up: the cross-home credential mismatch still appears present in rust-v0.157.1 and main at 819cdb7.

    I also checked #47695. It improves recovery when stored passwords are rejected, but does not appear to reconcile credential records across sibling homes. Serializing provisioning alone would not keep another home's stored credentials current after a password rotation.

    A regression check worth covering is: provision home A, provision home B, then alternate sandbox commands between A and B; both homes should remain usable without repeated password rotation.

    This is source analysis, not a fresh runtime reproduction.

  4. bielxdh3 commented on Oct 1, 2026

    @bielxdh3

    @JeffLepp I now have a fresh runtime reproduction that matches your source analysis and appears to confirm that #47695 did not fix the multi-CODEX_HOME case.

    Environment:

    • Windows 11
    • Codex standalone runtime 0.157.0
    • two separately authenticated CODEX_HOME profiles on the same Windows user
    • secondary profile used headlessly through App Server for a workspace-write Executor

    On the secondary home, the sandbox log shows a successful refresh first:

    read-acl-only mode: applying read ACLs
    read ACL run completed
    setup refresh: processed 4 write roots (read roots delegated); errors=[]
    setup binary completed
    

    The command runner is then copied/reused under that secondary CODEX_HOME, but the very next trivial probes still report:

    START: cmd.exe /d /c exit 0
    sandbox setup required: sandbox users missing or incompatible with marker version
    
    START: node -e process.exit(0)
    sandbox setup required: sandbox users missing or incompatible with marker version
    

    The same state is visible through App Server:

    • Windows sandbox mode: elevated
    • readiness: updateRequired
    • direct command/exec probes for both cmd.exe and Node fail before any process result, with JSON-RPC -32603 and a Windows-sandbox setup error
    • the result is the same with and without a request-level sandboxPolicy, so this is not caused by the caller's workspace-write policy override

    I also tried the supported recovery command for the secondary home from an elevated PowerShell:

    codex sandbox setup --elevated --current-user --codex-home "<secondary CODEX_HOME>"

    It exits with:

    orchestrator_helper_exit_nonzero: setup helper exited with status Some(1)
    

    I checked current source again. The default branch still uses the fixed machine-wide account names CodexSandboxOffline / CodexSandboxOnline, while sandbox_users.json remains per-CODEX_HOME; provisioning generates fresh passwords and calls NetUserSetInfo for existing accounts before persisting those secrets only into the requesting home. That still looks structurally capable of invalidating sibling homes exactly as described in this issue.

    So from my repro, #47695's rejected-credential repair is useful, but it does not reconcile credentials across sibling CODEX_HOME roots.

    I can test a candidate fix against:

    1. provision/use home A,
    2. provision/use home B,
    3. alternate workspace-write App Server commands A -> B -> A,
    4. then run both sequentially and concurrently,
    5. verify neither home rotates the other out and neither returns updateRequired.

    No credentials or auth files need to be shared.

  5. Isajunsei commented on Oct 2, 2026

    @Isajunsei

    Additional report from October 2, 2026, with a Windows desktop app and a separate CLI home under the same Windows user.

    Environment observed:

    • Windows 11
    • Desktop app package 26.930.2377.0
    • Bundled command runner 0.159.0-alpha.12.1
    • Two separate CODEX_HOME roots, with separate application authentication, configuration, and history

    After initially recovering sandbox setup, initialization state alternated between the app home and the independent CLI home. App Server commands failed before the requested process started, including a trivial Get-Location, with:

    exec-server rejected request (-32603): sandbox provisioning failed
    sandbox setup required: sandbox users missing or incompatible with marker version
    

    Our local diagnosis identified the same machine-wide CodexSandboxOffline / CodexSandboxOnline accounts with per-home sandbox credential state described here. A temporary local mitigation kept the sandbox credential store consistent across the two homes. The repair record documents tests of the shared-path state and subsequent successful CLI sandbox execution and app commands. Application authentication and configuration remained separate.

    This is evidence from our installed runtime and local repair record, not a clean-machine reproduction on current main or a recommendation to change credential storage manually. The account/subscription plan was not established as the cause.

    A separate initial setup failure matched #49299: an unmanaged full-access profile prevented provisioning; using a managed profile for the setup invocation recovered that stage but did not by itself address the cross-home recurrence.

    The key regression case for an upstream resolution seems to be provision A, provision B, then alternate actual workspace-write execution A → B → A without re-provisioning invalidating the other home. A readiness flag or a read-only probe alone is insufficient. Please clarify the supported multi-home isolation/credential model so desktop and independent CLI use can coexist reliably.

  6. MeroZemory commented on Oct 3, 2026

    @MeroZemory

    Corroborated on Windows 11 / codex-cli 0.160.0, native elevated sandbox, with several active sessions using the default CODEX_HOME and a separate account manager's CODEX_HOME. Both homes had version-5 metadata and referenced the same fixed machine-wide CodexSandboxOffline / CodexSandboxOnline accounts.

    At the same observation time, directly validating each home's encrypted sandbox credentials with LogonUserW gave:

    • Default home: offline and online both failed, error 1326.
    • Other active home: offline and online both succeeded, error 0.

    The matching rust-v0.160.0 source uses machine-wide account names and home-local credential files; provisioning can reset those shared passwords and persist only the caller's record. I did not attribute the conflict to the model proxy, nor infer validity solely from file timestamps.

    A one-time local recovery copied only the record proven valid by both logon checks into the stale home. Windows account passwords were not changed, and the target record's owner and DACL were preserved. Both homes then validated successfully. Subsequent explicit managed/elevated workspace-write checks in A -> B -> A all wrote/read successfully (2.18 / 1.90 / 2.35 seconds), and both credential-file modification times stayed unchanged. The existing default-home session also resumed normal sandbox commands. No hardlinks, symlinks or credential-sync service were installed.

    This is a measured reproduction of this existing issue, not a new issue. The reconciliation restores current state but does not permanently solve later password rotation by another home. Manual validation only; no Codex/Rust build or Rust test execution for this investigation. A separate large protected-tree ACL propagation/capacity outage was investigated under #50349 and required a separate repair.

  7. Nexvorn commented on Oct 10, 2026

    @Nexvorn

    Additional reproduction: two VS Code Codex instances with separate CODEX_HOME directories (October 10, 2026)

    I can reproduce the cross-home elevated Windows Sandbox/UAC behavior using the Codex VS Code extension, with two concurrent VS Code windows, separate projects, separate ChatGPT sign-ins, and separate CODEX_HOME directories. Both windows previously operated concurrently without repeated UAC prompts; this behavior appeared recently.

    Environment

    • Windows 11 x64, build 10.0.26200; VS Code 1.141.0 (User Setup)
    • Codex extension 26.1007.21434; also reproduced after downgrading to 26.930.61225
    • Native Windows elevated sandbox, WSL execution disabled, UAC enabled
    • Two homes: ~/.codex and ~/.codex-plus2

    Controlled reproduction

    1. Close the secondary VS Code window and execute whoami once in the primary window's normal sandbox. It succeeds as CodexSandboxOffline without a UAC prompt.
    2. Open the secondary VS Code window, then execute the same whoami again in the primary window. Windows prompts to elevate codex-windows-sandbox-setup.exe; the command completes after consent.
    3. On extension 26.930.61225, with both windows running, alternating read-only whoami probes in primary → secondary → primary produced a UAC prompt in all three attempts. Older chat histories remained accessible in both instances.

    Sandbox state measured at the reproduction time (October 10, local time UTC+3)

    Artifact Last modified
    Primary ~/.codex/.sandbox-secrets/sandbox_users.json 14:41:03
    Primary ~/.codex/.sandbox/setup_marker.json 14:41:04
    Secondary ~/.codex-plus2/.sandbox-secrets/sandbox_users.json 14:56:02
    Secondary ~/.codex-plus2/.sandbox/setup_marker.json 14:56:03

    Both machine-local Windows accounts, CodexSandboxOffline and CodexSandboxOnline, were enabled and reported PasswordLastSet = 14:56:02, exactly matching the secondary home's credential-file update, while the primary home's stored artifacts remained at 14:41. Both marker files existed, and the primary marker was readable from normal PowerShell.

    This is strong timestamp and behavioral evidence consistent with one home re-provisioning the machine-global accounts and making the other home's persisted state stale. It does not, by itself, cryptographically establish that the old credentials were invalid: I did not inspect/decrypt credentials or attempt LogonUserW.

    Additional potentially related per-command symptom: In the last 3,000 lines of the latest inspected sandbox log, setup refresh: spawning occurred 91 times, setup binary completed and errors=[] each occurred 91 times, while sandbox users missing or incompatible occurred 14 times, marker missing 0, and hide users: failed to hide current user profile dir 77 times. This also resembles the distinct recurring-successful-refresh behavior in #42233; I cannot yet isolate how much of the UAC frequency belongs to each mechanism.

    Expected: two Codex VS Code windows using separate CODEX_HOME directories and accounts should be able to run concurrently with the elevated sandbox, preserving their independent authentication and conversation history, without each home triggering UAC reprovisioning for the other.

    Please investigate machine-global sandbox credential lifecycle across independent CODEX_HOME instances and the apparently excessive successful setup refreshes. No raw logs, credentials, hostnames, personal account details, or project contents are attached.

  8. removed
    exec
    on Nov 29, 2026
  9. onmateco commented on Nov 30, 2026

    @onmateco

    Multica tracks the task-home side of this issue in multica-ai/multica#5876. On Windows with Multica 0.13.0 and standalone Codex 0.172.0, two task-local Codex homes each performed full elevated sandbox provisioning. Windows recorded account password resets followed by failed logons for an incorrect password. Native commands then failed to start with Win32 error 1326.

    In a separate setup attempt, the standalone client requested Registered Core provisioning and reported that the app runtime provisioning service was unavailable and helper fallback was refused. The available evidence does not identify the failing IPC step.

    Is there a supported, authenticated way for an external Codex app-server with a task-local CODEX_HOME to reuse compatible Desktop-owned Windows sandbox provisioning? If a Codex change is needed, could it verify caller identity and filesystem/network policy compatibility, keep account secrets private, and reject incompatible requests before rotating accounts or changing Desktop policy?

    The integration needs to preserve per-task configuration, tokens, session history and checkout boundaries even when Desktop and the task run sequentially. openai/codex#62397 describes a related case involving different proxy settings.

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

    CLIbugsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions