agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

bug(codex): Windows ancestor ACL validation rejects valid Codex home

Open nftkingiii opened this issue 2 months ago • 3 comments

Bug

On Windows, Codex account bootstrap can fail before any Codex process is launched because the private-directory admission check rejects an otherwise usable Codex home ancestor.

The observed path is:

  • ootstrapInner calls cleanupPendingCredentialHomes before econcileGlobal.
  • cleanupPendingCredentialHomes calls nsurePrivateDirectory.
  • nsurePrivateDirectory calls alidateCodexDirectoryAncestors before creating or launching the account app-server.
  • The validator can reject the volume root (C:\) based on its owner/ACL checks, producing ccount_storage_unsafe and the public CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE error.

This is a distinct pre-launch failure mode from account app-server environment handoff issues.

Impact

Users receive the generic account-management error even though Codex itself is installed and authenticated. No Codex process starts, so PATH propagation fixes cannot affect this path.

Relationship

This is related to #4989 but should be tracked separately because #4989 may include multiple Windows failure modes. Independent reproduction and trace: https://github.com/Untrivial-ai/agent-orchestrator/issues/4989#issuecomment-5576910008

Expected

Valid Windows installations should not be rejected solely because an ancestor such as C:\ has system-managed ownership or non-inherit-only ACL entries. If the directory cannot be safely accepted, the returned diagnostic should expose the specific ancestor and reason.

nftkingiii avatar Sep 08 '26 03:09 nftkingiii

Independent validation: the #5108-style ancestor-policy change fixes this failure on a real packaged Windows AO Desktop runtime.

I reproduced the original stock-Windows failure at the volume-root ancestor, then forward-ported the fix while preserving the strict private-vault policy.

The working distinction was:

FILE_ADD_FILE / FILE_ADD_SUBDIRECTORY on an ancestor do not by themselves allow replacement of an existing validated path component; DELETE, FILE_DELETE_CHILD, WRITE_DAC, WRITE_OWNER, and dangerous generic rights remain disqualifying; reparse-point checks remain enforced; private vault policy remains stricter than ancestor policy.

TrustedInstaller handling was scoped narrowly to the Windows system-owned ancestor case rather than relaxing private credential-home ownership.

With that in place, the real ancestor walk passed on stock Windows, Codex account bootstrap succeeded, and subsequent packaged-runtime Codex worker/orchestrator tests also passed. No changes to the ACL or ownership of C:\ were needed.

kou-keirei avatar Sep 12 '26 04:09 kou-keirei

Assigned to @somewherelostt.

Rishet11 avatar Sep 14 '26 14:09 Rishet11

Additional reproduction on AO 0.13.0 (packaged desktop) · Windows 11 Pro 10.0.26100 · Codex CLI 0.154.0 · Azure AD-joined machine, with two data points that may help narrow the fix.

Symptom is identical: every ao spawn --harness codex returns Codex account setup did not complete (CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE) from the first attempt after install (telemetry shows the first POST /api/v1/agents/codex/accounts/ensure → 503 one minute after installation), while ao doctor / ao agent ls report codex installed authorized and codex login status is Logged in using ChatGPT. GET /api/v1/agents/codex/accounts stays at accounts: [] with every capability "Codex capability detection has not completed."

Daemon log line (captured by running a throwaway daemon with AO_DATA_DIR/AO_PORT/AO_RUN_FILE pointed at an empty directory, since the packaged daemon's stderr is not persisted anywhere on Windows):

level=WARN msg="Codex account bootstrap failed" reasonCode=account_storage_unsafe retryable=false

Data point 1 — it is the volume-root ancestor, not the data dir or the Codex home. The same account_storage_unsafe fires, with a fresh empty data dir, for every location I tried: C:\ao-probe-root\data (only ancestor is C:\), C:\VSCodeProjects\ao-probe\data, %USERPROFILE%\Documents\ao-probe\data, %TEMP%\ao-probe\data, plus a run with an empty CODEX_HOME and a run with USERPROFILE/APPDATA/LOCALAPPDATA redirected to an empty folder. The only ancestor common to all of them is C:\, owner NT SERVICE\TrustedInstaller. This matches the #5080 description exactly.

Ownership chain here, for reference: C:\ = TrustedInstaller (protected), C:\Users = SYSTEM (protected), C:\Users\<me> = SYSTEM (protected), everything below = the user. The user's own SID is the Azure AD form (S-1-12-1-…) rather than S-1-5-21-…, in case the trusted-principal set is compared against a local-account SID pattern anywhere.

Data point 2 — the Codex sandbox ACL noise is NOT the trigger (relevant to the root-cause guess in #5306). ~/.codex here carried 204 explicit Deny ACEs for 102 orphaned per-run sandbox SIDs left behind by Codex's windows.sandbox = "unelevated" mode (they accumulate one pair per Codex run and are never removed). I removed all of them so ~/.codex and auth.json have only the three standard Allow entries (SYSTEM, Administrators, the user) — the failure is unchanged. So on this machine the check that trips is the ancestor walk, and cleaning ~/.codex is not a workaround.

Happy to test a nightly that carries the #5108-style ancestor-policy change; the throwaway-daemon method above makes it a 30-second check.

ryanlawyer avatar Sep 18 '26 18:09 ryanlawyer