Skip to content

fix(keyring): increase chunk size to prevent Windows credential limit issues - #10732

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

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

Conversation

@Ashutosh0x

Copy link
Copy Markdown
Contributor

Fixes #10353.

Problem

Windows Credential Manager has a hard limit of 2560 UTF-16 code units for the password field. OAuth tokens often exceed this limit. While chunking was implemented, the previous 512-character chunk size was too small and correctly handling the header overhead was brittle.

Solution

  • Increased MAX_KEYRING_VALUE_LEN from 512 to 1200 characters.
  • This ensures even the header chunk (~1220 chars) stays well under the 2560 UTF-16 limit, even with non-BMP characters.
  • Added unit tests to verify chunking of values up to 1500 characters.

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.
- 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
… issues

Fixes openai#10353

- Increase MAX_KEYRING_VALUE_LEN from 512 to 1200 characters
- Add documentation explaining the rationale
- Add root-cause analysis document
@etraut-openai

Copy link
Copy Markdown
Contributor

@Ashutosh0x, please do not post PRs without an invitation. This one is going to require more work, and it's not a high priority for us at the moment.

@Ashutosh0x

Copy link
Copy Markdown
Contributor Author

Apologies for the clutter in this PR! I unintentionally included several unrelated local commits in the branch when pushing. I'm glad the TUI fix in #10729 was merged.

Regarding the keyring issue (#10353), the suggested fix is simply to increase the chunk size (e.g. MAX_KEYRING_VALUE_LEN from 512 to 1200) to ensure the header chunk stays well under the 2560 UTF-16 limit of Windows Credential Manager, even with non-BMP expansion.

I'll wait for further discussion on the issue before submitting any more PRs. If you decide to move forward with this, I can provide a clean, single-commit PR. Thanks!

@Ashutosh0x

Copy link
Copy Markdown
Contributor Author

Hello @etraut-openai,

Following up on the new contribution guidelines, I've prepared a focused analysis for PR #10732 (Fixes #10353). This fix is critical for Windows users who use OAuth providers with large token payloads.

What?

Implement transparent token chunking for the Windows keyring to bypass the hard 2560-byte limit of the Windows Credential Manager.

Why?

Modern OAuth tokens often exceed the Windows limit. Without chunking, authentication fails silently for Windows users, creating a major platform disparity.

How?

  1. Chunking Mechanism: Splits tokens into 1024-char chunks stored as multi-part credentials (e.g., token, token:1).
  2. Transparent Reconstruction: Uses a CODEX_CHUNKED: header to automatically reconstruct the full token during load operations.
  3. Comprehensive Logic: Handles load, save, and delete operations to ensure orphaned chunks are correctly cleaned up.

I have verified this implementation with tokens up to 5000 chars on Windows 11. If this fits the team's intended approach for #10353, I would value an invitation to move this forward.

@etraut-openai

Copy link
Copy Markdown
Contributor

@Ashutosh0x, please put your analysis in the issue tracker, not in these closed PRs.

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.

OAuth tokens too long for Windows keyring

2 participants