CVE-2026-125120: Mongoose sanitizeFilter not applied on countDocuments

CVE-2026-125120 · Severity: critical · CVSS 9.8 · Published 2026-11-09

Mongoose is a popular Node.js library for working with MongoDB databases. The library has a security feature called sanitizeFilter that protects against query injection attacks, where an attacker injects malicious query operators into database queries. This vulnerability bypasses that protection in the countDocuments() method, allowing attackers to inject arbitrary query operators and read, modify, or delete database records without authorization.

Technologies: Automattic Mongoose, mongoose (npm). Vendors: Automattic, npm.

Quick answers

Is CVE-2026-125120 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-125120 being exploited in the wild.
How severe is CVE-2026-125120?
Critical severity, with a CVSS score of 9.8, published 9 November 2026.
Which products and versions are affected?
Automattic Mongoose <6.13.11, >=7.0.0 <7.8.12, >=8.0.0 <8.24.3, >=9.0.0 <9.9.2; mongoose (npm) < 6.13.11, SEMVER:introduced=0,fixed=6.13.11.
Is there a fix for CVE-2026-125120?
Yes. mongoose (npm): upgrade to 6.13.11 or later. Until then: Until upgrading, apply a Mongoose schema plugin that wraps countDocuments() to manually call sanitizeFilter on the query filter object, ensuring injection protection is enforced. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-125120 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-125120?
Check whether you run Automattic Mongoose or mongoose (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • mongoose (npm): upgrade to 6.13.11 or later
    npm install mongoose@6.13.11

Until upgrading, apply a Mongoose schema plugin that wraps countDocuments() to manually call sanitizeFilter on the query filter object, ensuring injection protection is enforced.

Technical details

sanitizeFilter is Mongoose's defense against query selector injection (CWE-943). The countDocuments() method failed to apply this filter, allowing untrusted user input in query parameters to bypass injection protection. An unauthenticated remote attacker can inject query operators via the countDocuments filter parameter to extract sensitive data, modify records, or cause denial of service—no user interaction or privileges required.

Affected products

  • Automattic Mongoose <6.13.11, >=7.0.0 <7.8.12, >=8.0.0 <8.24.3, >=9.0.0 <9.9.2

Identifiers

  • CVE-2026-125120
  • GHSA-pcrw-h46h-c93h

Timeline

  • 2026-11-02: disclosed
  • 2026-11-10: advisory
  • 2026-11-10: patched: Fixed in versions 6.13.11, 7.8.12, 8.24.3, and 9.9.2

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.