Skip to content

Windows sandbox users are created but their profiles are not initialized until manual first logon #17458

Open

Description

@eliotcougar

Summary

On Windows, Codex creates the local sandbox users:

  • CodexSandboxOnline
  • CodexSandboxOffline

but their user profiles are not initialized automatically. Before a manual first logon:

  • LastLogon is empty
  • C:\Users\CodexSandboxOnline does not exist
  • C:\Users\CodexSandboxOffline does not exist

After forcing a first logon with -LoadUserProfile, the profile directory is created and LastLogon updates.

This suggests the Windows sandbox setup leaves the sandbox users in a partially initialized state until they are manually logged in.

I investigated this because sandboxed HTTPS requests using the Windows Schannel stack were failing with SEC_E_NO_CREDENTIALS. Since Schannel often depends on per-user Windows profile state, the absence of C:\Users\CodexSandboxOnline / C:\Users\CodexSandboxOffline looked like a plausible explanation and was worth checking directly.

Version / platform

  • Date observed: April 11, 2026
  • Platform: Windows 11 / Windows 10.0.26200
  • PowerShell: 7.5.5

What I observed

The users do exist:

Get-LocalUser CodexSandboxOnline, CodexSandboxOffline

but initially:

  • LastLogon was empty for both
  • C:\Users\CodexSandboxOnline did not exist
  • C:\Users\CodexSandboxOffline did not exist

Then I forced first logon manually using the stored sandbox credentials and -LoadUserProfile.

After that:

  • C:\Users\CodexSandboxOnline existed
  • C:\Users\CodexSandboxOffline existed
  • LastLogon updated for both users

Expected behavior

If the Windows sandbox relies on dedicated local users, they should be fully initialized before first sandboxed use, or the first-use path should reliably initialize them automatically.

At minimum:

  • first sandbox use should not depend on a manual logon workaround
  • profile creation should be part of setup or first-run bootstrap

Actual behavior

The users are created, but their profiles are not initialized until manual first logon.

Why this matters

This appears to affect Windows sandbox reliability. In my testing, the sandbox users only started behaving like normal Windows users after profile creation.

That is especially relevant for any feature that depends on per-user Windows state, such as:

  • TLS/Schannel
  • user environment variables
  • AppData-backed state
  • DPAPI / profile-backed crypto state

Repro

Before manual first logon

Get-LocalUser CodexSandboxOnline, CodexSandboxOffline | Format-List Name,Enabled,LastLogon
Test-Path C:\Users\CodexSandboxOnline
Test-Path C:\Users\CodexSandboxOffline

Observed:

  • users exist
  • LastLogon empty
  • profile directories missing

Manual first logon workaround

Run a process as the sandbox user with -LoadUserProfile.

After that:

Get-LocalUser CodexSandboxOnline, CodexSandboxOffline | Format-List Name,LastLogon
Test-Path C:\Users\CodexSandboxOnline
Test-Path C:\Users\CodexSandboxOffline

Observed:

  • LastLogon populated
  • profile directories now exist

Suspected source area

The Windows sandbox code creates the users during setup, but profile creation seems to be deferred until first actual logon.

Relevant files:

  • codex-rs/windows-sandbox-rs/src/sandbox_users.rs
  • codex-rs/windows-sandbox-rs/src/elevated_impl.rs
  • codex-rs/windows-sandbox-rs/src/hide_users.rs

The code in hide_users.rs explicitly notes that Windows only creates the profile directory when the user first logs in.

Suggested fix direction

One of:

  1. initialize the sandbox-user profiles during setup
  2. explicitly bootstrap first logon/profile creation on first sandbox use
  3. fail with a clear diagnostic if profile initialization did not happen

Activity

  1. added
    bug
    CLI
    windows-os
    sandbox
    on Apr 11, 2026
  2. removed
    CLI
    on Apr 11, 2026
  3. Xymanek commented on May 23, 2026

    @Xymanek

    I've tried the manual logon approach, and

    Test-Path C:\Users\CodexSandboxOnline
    Test-Path C:\Users\CodexSandboxOffline

    both pass.

    However, Schannel still does not work (same error).

    I'm guessing there must be more to it

  4. artdedeco commented on Sep 2, 2026

    @artdedeco

    I've tried the manual logon approach, and

    Test-Path C:\Users\CodexSandboxOnline
    Test-Path C:\Users\CodexSandboxOffline
    both pass.

    However, Schannel still does not work (same error).

    I'm guessing there must be more to it

    That workaround didn't work for me either, unfortunately. At least what I think the workaround was. I decrypted the sandbox user password and performed manual logon. Logon was successful and it did create the folders, but Schannel still didn't work.

    I'm currently completely unable to effectively use a strict sandbox mode due to this bug. All alternatives I could find, in one way or another, require giving more permissions than should be necessary. Btw, weirdly enough, switching to unelevated did not fix it for me.

  5. mrciremaro commented on Sep 11, 2026

    @mrciremaro

    I can reproduce this profile-initialization problem on Codex CLI 0.154.0 / Windows 11 Pro 25H2.

    Additional evidence from my reproduction:

    • The restricted execution token SID matches the Codex CodexSandboxOffline account created by elevated sandbox provisioning.
    • That SID has no ProfileList entry under:
      HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
    • There is no loaded HKEY_USERS hive for the SID.
    • No registered profile path exists for that SID.
    • The inherited USERPROFILE environment variable still points to the normal interactive user's profile.

    Under the restricted Codex execution context:

    • GetUserProfileDirectoryW sizing call returns ERROR_INSUFFICIENT_BUFFER, but required size remains 0.
    • A large preallocated-buffer call fails with ERROR_FILE_NOT_FOUND.
    • SHGetKnownFolderPath(FOLDERID_Profile) returns 0x80070002 / FILE_NOT_FOUND.

    Under the normal approved outer context, both APIs resolve the user profile successfully.

    This provides a strong explanation for a separate sandbox startup failure I observed:

    Could not find home directory

    The Windows Job Object launcher, inherited environment, working directory, and filesystem access were controlled separately and do not explain the difference.

    The sandbox account exists, but its Windows profile is not registered/initialized.

    I have not manually created the profile, edited ProfileList, loaded the sandbox account hive, or accessed sandbox credentials.

    It appears the elevated sandbox provisioning path can successfully create the sandbox account without ensuring that the Windows profile required by later profile/home resolution is initialized.

    Happy to provide sanitized diagnostic artifacts if useful.

  6. slix commented on Sep 16, 2026

    @slix

    This makes it tough to run adb, which expects a user profile directory.

    Feedback ID: 01a0aba8-7d3f-7a42-b053-4612aded6096

  7. orazdow commented on Sep 29, 2026

    @orazdow

    Every day something new breaks you fucking people. Not only does nothing work, nothing works according to 5 different simultaneous current issues. This is the 3rd I'm addressing in a single day. WTF happened to OpenAI? UNFUCK YOURSELVES.

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

    bugsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions