Skip to content

[Windows Desktop] MCP OAuth secrets decryption requests 1 GiB and fatally crashes codex.exe #38435

Open

Description

@kutayilmaaz

Codex version

  • Codex Desktop: 26.803.10989.0
  • Platform: Windows 11 25H2, build 26200, x64
  • Bundled CLI observed around the incident: 0.147.0-alpha.1.2

What issue are you seeing?

Codex Desktop's native codex.exe backend terminated while loading encrypted MCP OAuth credentials.

The application reported:

memory allocation of 1073741824 bytes failed
code=3221226505

Windows recorded:

Exception code: 0xc0000409
FAST_FAIL_FATAL_APP_EXIT (exception information: 7)

The Desktop UI/backend later restarted and reconnected, but the active task was interrupted.

Root-cause evidence from the crash dump

I inspected the Windows minidump without publishing its contents. The failing thread shows this call path:

MCP client/tool initialization
  -> read OAuth tokens for server
  -> load MCP OAuth tokens from encrypted storage
  -> decrypt secrets file
  -> age 0.11.x scrypt recipient
  -> RustCrypto scrypt 0.11.x allocation
  -> Rust allocation error handler
  -> Windows fast-fail

The requested allocation size was also present in register R12 as:

0x40000000 = 1,073,741,824 bytes

The encrypted credential file itself was only about 6 KB. Its sanitized age header was:

age-encryption.org/v1
-> scrypt <salt-redacted> 20
--- <mac-redacted>

No OAuth token, passphrase, salt, MAC, username, local project name, or private server name is included in this report.

The allocation size follows exactly from the implementation parameters:

  • age uses ScryptParams::new(log_n, 8, 1, 32)
  • the file header has log_n = 20
  • RustCrypto allocates N * r * 128 bytes for v
  • 2^20 * 8 * 128 = 1,073,741,824 bytes

Relevant upstream code:

The age implementation benchmarks the machine and picks a work factor targeting roughly one second. On this machine that produced work factor 20, which also implies a temporary 1 GiB contiguous allocation.

Steps that led to the observed failure

  1. Use Codex Desktop on Windows with one or more OAuth-authenticated remote MCP servers/apps.
  2. Let Codex create its file-backed encrypted OAuth store with an age scrypt work factor of 20.
  3. Keep Codex running with normal desktop memory pressure.
  4. Trigger MCP/app initialization or refresh that reads the OAuth credential store.
  5. The 1 GiB scrypt allocation can fail.
  6. Rust's allocation failure path terminates the entire codex.exe backend with 0xc0000409.

The failure is intermittent because it depends on process/system memory and address-space conditions, but the minidump identifies the immediate caller and exact allocation deterministically.

Expected behavior

Failure to decrypt or allocate memory for an optional MCP OAuth credential store should not terminate the entire Codex backend.

Possible remedies:

  • Put a conservative memory/work-factor ceiling on programmatically generated credential stores.
  • Avoid CPU-only calibration that can choose a work factor requiring 1 GiB on a fast but memory-constrained Windows machine.
  • Catch credential-store/decryption failures and disable only the affected MCP connection.
  • Use a fallible/bounded allocation path where possible.
  • Prefer the native OS credential store when available, or provide a supported migration path for an existing high-cost encrypted file.
  • Log the selected work factor and estimated memory requirement without exposing secret material.

Additional diagnostics

Crash time: 2026-08-13 22:20:38 Europe/Istanbul.

Minidump SHA-256:

7899D64DBF35EB77B221D09D3D7A2DF5B4B9BC4A3ECE1EB253CB1F4FAA2ABE70

The dump is not attached publicly because process dumps can contain credentials or other private memory. I can provide additional sanitized stack offsets/disassembly if maintainers request them.

This is separate from the Windows legacy_notify / os error 206 issue: no notify-hook error occurred in this crash path.

Activity

  1. added
    bug
    app
    windows-os
    mcp
    auth
    on Aug 13, 2026
  2. ganzizi commented on Sep 28, 2026

    @ganzizi

    Additional reproduction on the current Desktop build. I could not open a pull request because this repository's pull request creation policy is COLLABORATORS_ONLY.

    Reproduction

    • Desktop MSIX OpenAI.Codex 26.924.2738.0 (About 26.924.22138), ChatGPT.exe 154.0.8037.57
    • bundled app-server codex.exe 0.158.0-alpha.2.1
    • Windows 10.0.26200

    At 2026-09-28T01:08:09.915Z, during MCP startup and immediately after unrelated plugin-load warnings, the app-server wrote:

    memory allocation of 1073741824 bytes failed
    

    The desktop connection then closed with 3221226505 (0xC0000409). The renderer had already mounted its routes after 5812 ms, and config/read plus model/list had completed, so this is not the cold-start loading hang in #48466.

    The secrets file was 692 bytes. Its age header was a scrypt stanza with work factor 20 (salt and MAC omitted). Same formula as above: 2^20 * 8 * 128 = 1,073,741,824.

    Patch

    main still uses age's one-second scrypt calibration for this passphrase. generate_passphrase stores 32 random bytes in the OS keyring, so that calibration does not protect a human-memorable secret, and on a fast CPU it writes log_n = 20.

    The change caps both encryption and decryption of this programmatic passphrase at log_n = 15 (32 MiB):

    • set_work_factor(15) so new files do not record a higher factor
    • set_max_work_factor(15) so age returns ExcessiveWork before RustCrypto allocates
    • that error becomes a normal Err instead of aborting the process

    rmcp-client already treats a decrypt error as a keyring load failure. Auto mode logs it and falls back to the file store. Keyring mode returns the error.

    No branch is published. The change is the log_n = 15 cap described above.

    Files already written above the cap, including a log_n = 20 mcp_oauth.age, will no longer decrypt. They are left on disk. Affected MCP servers need to be signed in again. The patch does not migrate old ciphertext, because reading a log_n = 20 file is the allocation that aborts the process. It also does not change the closed-source Electron shell.

    cargo test -p codex-secrets --lib was not run here (no MSVC linker). rustfmt --check passed for codex-rs/secrets/src/local.rs. The new tests round-trip a secret and assert the header factor is 15, and reject log_n = 16 (64 MiB) without constructing a log_n = 20 ciphertext.

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

    appauthbugmcpperformancewindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions