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

Source: https://junglewise.ai/threats/cve-2026-125120-mongoose-sanitizefilter-not-applied-on-countdocuments  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-11-09. Updated: 2026-11-10  
License: CC BY 4.0 with a link back

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](https://junglewise.ai/threats/technologies/automattic-mongoose), [mongoose (npm)](https://junglewise.ai/threats/technologies/mongoose). Vendors: [Automattic](https://junglewise.ai/threats/vendors/automattic), [npm](https://junglewise.ai/threats/vendors/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

  ```sh
  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

- [https://api.github.com/users/koyokr](https://api.github.com/users/koyokr)

## Related threats

- [Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.0.0 until 6.13.12, 7.8.13, 8.24.7, and 9.](https://junglewise.ai/threats/cve-2026-125119-mongoose-connection-level-sanitizefilter-not-applied)
- [Mongoose prototype pollution in Schema.prototype.virtual()](https://junglewise.ai/threats/cve-2026-125118-mongoose-prototype-pollution-via-schema-prototype-virtual)
- [Mongoose prototype pollution in object initialization](https://junglewise.ai/threats/cve-2026-125117-mongoose-is-a-mongodb-object-modeling-tool-designed-to-work-in)
- [Mongoose discriminator key inheritance bypass](https://junglewise.ai/threats/cve-2026-125116-mongoose-discriminator-key-values-matching-inherited-properties)
- [Mongoose prototype pollution via __proto__ in update casting](https://junglewise.ai/threats/cve-2026-73562-mongoose-prototype-pollution-via-proto-in-update-casting)
