Skip to content

fix(windows): resolve sandbox access, keyring limits, and concurrency race conditions - #10648

Closed
Ashutosh0x wants to merge 3 commits into
openai:mainfrom
Ashutosh0x:fix/windows-keyring-chunking
Closed

Ashutosh0x wants to merge 3 commits into
openai:mainfrom
Ashutosh0x:fix/windows-keyring-chunking

Conversation

@Ashutosh0x

@Ashutosh0x Ashutosh0x commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR addresses several critical Windows-specific issues identified in the sandbox and credential management systems. These fixes significantly improve reliability for Windows users, especially when working in large repositories or active development environments.

Major Changes

1. Windows Sandbox Root Access (#10352, #7151)

  • Problem: The restricted token used in ReadOnly and WorkspaceWrite modes lacked standard Windows SIDs (Everyone, Authenticated Users), causing "Access Denied" errors when accessing root directories or using compiler toolchains like Dotnet.
  • Fix: Added these well-known SIDs to the sandbox restricted token and ensured default DACL access is granted during setup.

2. Windows Keyring Length Limit (#10353)

  • Problem: Windows Credential Manager has a ~2.5KB limit for generic credentials, causing authentication failures when OAuth tokens exceed this size.
  • Fix: Implemented transparent token chunking in keyring-store. Large tokens are now split into 2KB segments and reassembled automatically upon retrieval.

3. Sandbox Setup Reliability & Diagnostics (#10601, #9744, #9661)

  • Concurrency: Implemented cross-process synchronization using named Windows Mutexes (Local\CodexSandboxSetupRefresh) to prevent "exit code 1" collisions during concurrent refreshes.
  • Actionable Errors (VS Code extension (Windows sandbox): apply_batch rejected because codex-windows-sandbox-setup.exe is missing #9744): Added proactive verification for the codex-windows-sandbox-setup.exe helper. Instead of a generic "rejected" status, users now receive a clear error if the binary is missing (common in extension-bundled CLI versions).
  • DPAPI Robustness: Added fallback logic to handle DPAPI decryption failures gracefully.

4. Git & Edit Inconsistency

Verification

  • Test Suite: Verified with a passing test suite of 975 tests on Windows 11.
  • Manual Verification: Confirmed dotnet build works in the sandbox and edit application is reliable even with CRLF files.

Addresses #10352, #10353, #10601, #7151, #9661, #9744.

Fixes openai#10353

Windows Credential Manager has a 2560-byte limit for UTF-16 encoded passwords.
OAuth tokens often exceed this limit, causing authentication failures.

This change implements transparent chunking for large values:
- Values exceeding 1024 characters are split into chunks
- Main key stores header with chunk count and first chunk
- Additional chunks stored in account:1, account:2, etc.
- Load/delete operations automatically handle chunked values

Tested on Windows 11 with values up to 5000 characters.
…profile loading

This commit addresses two issues:

1. **Windows Sandbox Root Access (fixes openai#10352)**
   - Added standard Windows SIDs (Everyone, Authenticated Users, Builtin Users) to
     restricted tokens to enable read access to root directories
   - Sandbox can now list C:\ and read system files like win.ini

2. **Default Shell Profile Loading (addresses openai#4843)**
   - Changed experimental_use_profile default to 	rue so shell profiles
     (.bashrc, conda, etc.) are loaded by default
   - Users can still opt out with explicit login: false

3. **Test Fixes**
   - Fixed git_info tests to skip when running inside existing git repos
   - Fixed turn_diff_tracker tests for Windows temp path normalization
   - Fixed PowerShell safe command test to use standard Windows PowerShell path
   - Fixed skills loader test for non-git workspace scenarios

All 972 tests pass with 0 failures.
@Ashutosh0x

Copy link
Copy Markdown
Contributor Author

Closing this as I see the team has updated contribution guidelines to invitation-only. I've shared the analysis and root-cause findings in issue #10352 instead. Happy to submit a PR if invited!

@Ashutosh0x Ashutosh0x closed this Feb 4, 2026
@Ashutosh0x Ashutosh0x reopened this Feb 4, 2026
@Ashutosh0x Ashutosh0x changed the title fix(windows-sandbox): enable root directory access and default shell profile loading fix(windows): sandbox root access and keyring token chunking Feb 4, 2026
- Implemented named mutexes for sandbox refresh and elevated setup
- Orchestrator now skips redundant refreshes instead of colliding
- Cleaned up named mutex logic for reuse across sandbox components
- Verified fix resolves 'exit code 1' reported in issue openai#10601 when running alongside dev servers like Bun
@Ashutosh0x
Ashutosh0x force-pushed the fix/windows-keyring-chunking branch from d80970d to b10b753 Compare February 4, 2026 18:17
@Ashutosh0x Ashutosh0x changed the title fix(windows): sandbox root access and keyring token chunking fix(windows): resolve sandbox access, keyring limits, and concurrency race conditions Feb 4, 2026
@etraut-openai

Copy link
Copy Markdown
Contributor

We've updated our contribution guidelines to indicate that we're no longer accepting unsolicited code contributions. All code contributions are by invitation only. To read more about why we've taken this step, please refer to this announcement.

@Ashutosh0x

Copy link
Copy Markdown
Contributor Author

Hello @etraut-openai,

In line with the updated contribution guidelines, I've prepared a detailed analysis for PR #10648 (Fixes #10352 and #4843). This addresses core Windows stability issues in the sandbox and shell environments.

What?

Enable root directory access in the Windows sandbox and ensure default shell profiles (like .bashrc) are loaded during task execution.

Why?

  1. Sandbox: The existing restricted tokens were too tight, preventing standard operations like listing drive roots or reading system configuration files.
  2. Shell: Developmental environments (e.g., Conda) rely on shell profiles. Disabling them by default prevents the CLI from correctly identifying installed tools in many Windows setups.

How?

  1. SID Expansion: Added Everyone, Authenticated Users, and Builtin Users SIDs to the Windows sandbox restricted tokens.
  2. Profile Loading: Enabled experimental_use_profile by default to ensure parity with the standard user shell experience.
  3. Test Stability: Fixed multiple Windows-specific test failures related to path normalization and PowerShell core availability.

These changes significantly improve the Windows "out-of-the-box" experience. If this aligns with your roadmap for platform stability, I'd appreciate the opportunity to reopen this discussion.

@wuqiqi-hub

Copy link
Copy Markdown

/Codex Desktop sandbox command runner appears broken on Windows, while non-sandbox execution works.

Minimal repro:
cmd /c echo ok

Observed behavior in sandbox:

  • Fails before the command actually runs
  • Error: CreateProcessWithLogonW failed: 1326
  • Sometimes also shows: Internal Windows PowerShell error ... 8009001d
  • In one case also saw: windows sandbox: setup refresh failed with status exit code: 1

Observed behavior outside sandbox:

  • The same command succeeds
  • Output returned was: ok"

What I already checked:

  • Local manual cmd execution works normally outside Codex
  • Restarting Codex Desktop did not fix it
  • Starting a new thread did not fix it
  • Using C:\Windows as workdir did not fix it
  • Omitting workdir did not fix it
  • Setting login=false did not fix it
  • Non-sandbox execution succeeds, so this seems specific to the sandbox execution path

Additional note:

  • The internal terminal sometimes shows a path like \?\C:\Users...\ and cmd falls back to C:\Windows because it says the path is unsupported. That looks like a secondary path-handling issue, but not the main cause, because the failure still happens even without passing a workdir.

This looks like a Windows sandbox / process-launch issue in Codex Desktop rather than a local cmd or project problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants