MongoDB Node.js CVE-2026-126837: Patch SRV host validation
Upgrade the mongodb npm package to 7.8.0 or a later supported release containing the fix if your application uses mongodb+srv://. MongoDB’s advisory for CVE-2026-126837 lists versions >=3.3.3 and <7.8.0 as affected and rates the flaw Critical, CVSS v4.0 9.1. The MongoDB CNA record also includes a CVSS v3.1 score of 7.4 High. The scores use different CVSS versions.
An attacker who can forge or change the DNS SRV responses received by the driver can redirect database connections outside the expected domain. MongoDB describes possible disclosure of application data and authentication credentials, and altered query results. TLS does not stop this redirection because the driver checks the certificate against the redirected hostname. The advisory says application input or a connection string alone cannot trigger the flaw. Applications using mongodb:// are not affected by this CVE.
Check the application and its dependencies
Inventory the driver in each deployed application or container, including copies brought in by database frameworks. Check the effective connection-string scheme privately; do not paste credentials or full connection strings into logs. A database server upgrade does not replace the vulnerable client library.
Save this read-only helper as inspect-mongodb-package.cjs in the application directory. It reads package metadata without loading driver code or contacting a database:
const fs = require("node:fs");
let packagePath;
try {
packagePath = require.resolve("mongodb/package.json", {
paths: [process.cwd()]
});
} catch (error) {
if (error.code !== "MODULE_NOT_FOUND") throw error;
console.error("No mongodb package is resolvable from this directory.");
process.exit(2);
}
const pkg = JSON.parse(fs.readFileSync(packagePath, "utf8"));
console.log(`Package: ${pkg.name}`);
console.log(`Version: ${pkg.version}`);
console.log(`Metadata: ${packagePath}`);Run it from that directory:
node inspect-mongodb-package.cjsActual output from a lab without an installed driver, on Debian 13 with Node.js v24.22.1:
No mongodb package is resolvable from this directory.The command exited with status 2, leaving the inventory unresolved. It says nothing about a deployed application’s safety. With a resolvable package, the helper prints its name, version and metadata path, but reports only one copy. Inspect the full dependency tree with your package manager and check the deployed artifact for nested, bundled or independently installed copies. Investigate any package-resolution errors. Delete the helper when finished.
Upgrade and verify the replacement
MongoDB identifies 7.8.0 as the fixed release. Update the application dependency and lockfile, or upgrade the framework that supplies the driver. Check runtime and framework compatibility before crossing major versions. Rebuild the deployable artifact and restart application processes so they load the replacement library. Verify every serving replica’s resolved driver version and run normal connection and query tests in staging before rollout.
Updating Linux packages alone does not establish that an application’s npm dependency is fixed. For a vendor-supplied application or modified driver build, obtain the supplier’s CVE-specific fixed build and verify that exact revision. The cited MongoDB advisory names 7.8.0; it does not establish a backport for an older branch or any third-party product.
If an upgrade must wait, MongoDB’s supported workaround is a mongodb:// connection string with an explicit host list, avoiding SRV lookup. Obtain the correct hosts and options from your database provider. SRV connection strings enable TLS by default and can obtain options through DNS TXT records. Preserve authentication and topology options and explicitly retain TLS; do not merely replace the URI prefix or disable certificate verification. Test connectivity and failover, then verify the effective configuration on every replica. This workaround changes service discovery and needs ongoing host-list maintenance.
Disclosure and verification limits
MongoDB published its GitHub advisory on November 12, 2026 at 17:21:44 UTC. Release 7.8.0 is dated October 30 and its current notes mention this CVE, but the available page does not establish when that warning was added. October 30 should not be treated as the initial security-disclosure date on that evidence alone.
The cited vendor advisory and CNA record do not report confirmed exploitation in the wild. That does not establish its absence. The local check above tested metadata resolution only; no database, malicious DNS response or vulnerability reproduction was tested.
NVD: CVE-2026-126837.
Acknowledgements
This post was created with assistance from AI.