CVE-2026-125120: Mongoose's countDocuments() Bypass of sanitizeFilter Opens NoSQL Injection
What's the vulnerability
CVE-2026-125120 is a NoSQL injection flaw (CWE-943) in the Mongoose ODM for MongoDB. Mongoose's sanitizeFilter option exists specifically to strip attacker-controlled query operators — $where, $gt, $ne, $regex, and similar — out of filter objects before they reach MongoDB. That protection was never wired into the countDocuments() code path.
The result: an application that explicitly enabled sanitizeFilter as a defense-in-depth control, then passed user-controlled input into Model.countDocuments(filter), remains fully injectable through that single call. Attackers can use operator injection to bypass authentication checks that rely on count-based logic, enumerate data via boolean/blind count oracles, or in the worst case trigger server-side JavaScript evaluation inside the Node.js process. With a CVSS score of 9.8, this is a critical, straightforward-to-trigger issue for any app that counts documents from user input.
Affected software
- Vendor/ecosystem: npm
- Product: mongoose
- Affected versions: < 6.13.11, 7.0.0–7.8.11, 8.0.0–8.24.2, and 9.0.0–9.9.1
No patched date has been recorded yet for this detection; treat any deployed mongoose version within the ranges above as exposed until confirmed otherwise against the maintainers' fix.
Exploitation status
Exploitation is currently classified as theoretical — there is no known weaponized exploit or public proof-of-concept in active use. That said, the vulnerability class (operator injection bypassing a sanitization control that developers trusted) is well understood and easy to exploit once a vulnerable countDocuments() call is identified in an application, so defenders should treat the window before broad patching as a real risk, not a purely academic one.
How our detection catches it
Because the injection happens inside the Node.js application process, there's no single log source that shows the full exploit — detection instead correlates two layers of evidence:
- Web/application logs: HTTP request bodies or query parameters containing JSON-structured, operator-laden values (keys like
$where,$gt,$ne,$regex) submitted to endpoints that plausibly feed a count operation. - MongoDB command logs:
count/countDocumentscommand invocations whose filter documents contain injected query operators rather than the expected scalar values. - Inventory signals: presence of a vulnerable mongoose package version in dependency manifests or SBOM data, used to scope and prioritize the alert.
This logic is shipped across seven SIEM dialects — Microsoft Sentinel (KQL), Splunk (SPL), Elastic (EQL), QRadar (AQL), Sumo Logic, Chronicle (YARA-L), and CrowdStrike (CQL) — so you can deploy the correlation in whichever platform already ingests your web and MongoDB logs.
Full detection
For the complete, per-SIEM detection logic, sample events, and investigation guidance, see the full detection page: df00tech.com/detections/CVE-2026-125120.