Repository navigation
Description
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 * 128bytes forv 2^20 * 8 * 128 = 1,073,741,824bytes
Relevant upstream code:
- https://github.com/str4d/rage/blob/v0.11.1/age/src/primitives.rs
- https://github.com/str4d/rage/blob/v0.11.1/age/src/scrypt.rs
- https://github.com/RustCrypto/password-hashes/blob/scrypt-v0.11.0/scrypt/src/lib.rs
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
- Use Codex Desktop on Windows with one or more OAuth-authenticated remote MCP servers/apps.
- Let Codex create its file-backed encrypted OAuth store with an age scrypt work factor of 20.
- Keep Codex running with normal desktop memory pressure.
- Trigger MCP/app initialization or refresh that reads the OAuth credential store.
- The 1 GiB scrypt allocation can fail.
- Rust's allocation failure path terminates the entire
codex.exebackend with0xc0000409.
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
ganzizi commentedon Sep 28, 2026
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
OpenAI.Codex26.924.2738.0(About26.924.22138),ChatGPT.exe154.0.8037.57codex.exe0.158.0-alpha.2.110.0.26200At
2026-09-28T01:08:09.915Z, during MCP startup and immediately after unrelated plugin-load warnings, the app-server wrote:The desktop connection then closed with
3221226505(0xC0000409). The renderer had already mounted its routes after 5812 ms, andconfig/readplusmodel/listhad 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
mainstill uses age's one-second scrypt calibration for this passphrase.generate_passphrasestores 32 random bytes in the OS keyring, so that calibration does not protect a human-memorable secret, and on a fast CPU it writeslog_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 factorset_max_work_factor(15)so age returnsExcessiveWorkbefore RustCrypto allocatesErrinstead of aborting the processrmcp-clientalready treats a decrypt error as a keyring load failure.Automode logs it and falls back to the file store.Keyringmode returns the error.No branch is published. The change is the
log_n = 15cap described above.Files already written above the cap, including a
log_n = 20mcp_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 alog_n = 20file is the allocation that aborts the process. It also does not change the closed-source Electron shell.cargo test -p codex-secrets --libwas not run here (no MSVC linker).rustfmt --checkpassed forcodex-rs/secrets/src/local.rs. The new tests round-trip a secret and assert the header factor is15, and rejectlog_n = 16(64 MiB) without constructing alog_n = 20ciphertext.