# CVE-2026-118383: Use-after-free vulnerability in MongoDB

Use-after-free in MongoDB replica set primary catch-up; two unauthenticated ping requests with readConcern.afterOpTime plant stale waiters that crash the new primary on election.

- Payout: Research
- Severity: critical
- Program: MongoDB Server
- Write-up by: Datadog Security Labs
- Disclosed: 2026-11-11
- CVE: CVE-2026-118383
- Write-up quality: 8/10
- Original: https://securitylabs.datadoghq.com/articles/cve-2026-118383-mongodb-server-use-after-free/
- Library page: https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free
- Tags: area:cloud domain:infra impact:dos kind:research platform:threat-intel sev:critical tech:linux technique:race-window technique:source-review vuln:auth-bypass vuln:dos vuln:memory-corruption

**Target:** mongod replica set member (primary catch-up / CatchupState)
**Root cause:** Stale waiters planted via unauthenticated ping with readConcern.afterOpTime survive until a member wins an election while lagging; at catch-up completion the cleanup runs twice and uses freed memory in CatchupState::abort_inlock().
**Steps:**
1. Send two unauthenticated `ping` commands with a `readConcern.afterOpTime` value and `maxTimeMS` to a reachable vulnerable replica set member; waiters persist (they time out with MaxTimeMSExpired but remain).
2. Wait for the member to fall behind on replication and win an election (attacker cannot cause either).
3. When catch-up finishes, the new primary runs cleanup twice, logs SIGSEGV, and crashes before accepting writes.
**How found:** Researchers reasoned that ping is accepted pre-auth and that readConcern.afterOpTime creates persistent waiters; hypothesized they'd survive into catch-up cleanup, then reproduced by inducing lag and failover in a four-member lab replica set.
**Exploitation:** Attacker plants two abandoned waiters pre-election with no credentials; when the lagging member later becomes primary and completes catch-up, double cleanup frees and reuses memory, crashing mongod (SIGSEGV at CatchupState::abort_inlock()). Vendor notes possible arbitrary code execution; not demonstrated.
**Insight:** Pre-auth commands that register persistent server-side state (waiters, cursors, subscriptions) can outlive their request and interact with internal lifecycle transitions like election catch-up; look for cleanup paths that can run twice.

