codex-security icon indicating copy to clipboard operation
codex-security copied to clipboard

Windows: default state directory fails credential-home validation once Codex's elevated sandbox has a Modify ACE on the user profile

Open lumatic2 opened this issue 1 month ago • 0 comments

Summary

Every codex-security command fails on my Windows machine, login status included. My profile root has explicit Modify ACEs for CodexSandboxUsers and a sandbox capability SID, and the default state directory under ~/.codex inherits them.

Same cause as #1782, on the profile instead of %TEMP%. #1803 only moved the bootstrap workspace out of TEMP.

Environment

  • Windows 11 Home 10.0.26200, PowerShell 7, Node.js 24.22.1
  • @openai/codex-security 0.7.0 (also 0.6.0), run with npx
  • codex-cli 0.164.0, [windows] sandbox = "elevated"
  • CODEX_SECURITY_STATE_DIR unset unless noted

Steps to reproduce

  1. Profile root ACL (abridged, SIDs replaced):

    > icacls $HOME
    C:\Users\<user> <HOST>\CodexSandboxUsers:(OI)(CI)(M,DC)
                    S-1-5-21-1111111111-1111111111-1111111111-1111111111:(OI)(CI)(M,DC)
                    NT AUTHORITY\SYSTEM:(OI)(CI)(F)
                    BUILTIN\Administrators:(OI)(CI)(F)
                    <HOST>\<user>:(OI)(CI)(F)
    

    I didn't add these. The Codex sandbox log has them from a session I started in ~ back in April:

    ~/.codex/.sandbox/sandbox.log
    [2026-04-10 12:05:12.339 codex.exe] setup refresh: spawning ...\codex-windows-sandbox-setup.exe (cwd=C:\Users\<user>, ...
    [2026-04-10T03:05:12.374788400+00:00] granting write ACE to C:\Users\<user> for sandbox group and capability SID
    
  2. npx @openai/[email protected] login status

Actual result

codex-security: Unable to create a private Windows credential home: C:\Users\<user>\.codex\state\plugins\codex-security\codex-home. Windows private-directory ancestor could not be trusted: C:\Users\<user>\.codex\state\plugins\codex-security. Windows credential-home ancestor allows another identity to replace the directory. Choose a location outside this ancestor with trusted ownership and permissions.

What I tried with CODEX_SECURITY_STATE_DIR:

Location Result
new folder under $HOME fails, names that folder
new folder under $HOME, inheritance removed fails, names C:\Users\<user>
new folder on D:\ fails, Authenticated Users:(M) from the volume root (fair)
C:\cs-state, inheritance removed works

Expected result

Rejecting these ancestors is fine. The problem is that the default location can't work once a Codex session has run in ~, and the error names the nearest folder, not C:\Users\<user> where the ACE is set. So moving "outside this ancestor" just fails again.

#2065 changes the error to name the outermost rejected ancestor. I left the default location alone in that PR.

Workaround

New-Item -ItemType Directory C:\cs-state | Out-Null
icacls C:\cs-state /inheritance:r /grant:r "${env:USERNAME}:(OI)(CI)F" "SYSTEM:(OI)(CI)F" "Administrators:(OI)(CI)F"
$env:CODEX_SECURITY_STATE_DIR = "C:\cs-state"
npx @openai/[email protected] login status

lumatic2 avatar Oct 27 '26 02:10 lumatic2