CRITICAL · CVSS 3.1 9.8 EPSS 0.9% · 59th percentile CWE-943

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

Published 2026-11-10 · Updated 2026-11-27 · Also known as BIT-mongoose-2026-125120, GHSA-pcrw-h46h-c93h

Summary

A query selector injection vulnerability exists in Mongoose because the sanitizeFilter mechanism is not automatically applied on countDocuments queries. Applications handling untrusted user input within Mongoose countDocuments queries should upgrade immediately.

Who is affected

Deployments using Mongoose to perform countDocuments operations with unsanitized user input are affected. This flaw allows potential query selector injection attacks, leading to high impacts on confidentiality, integrity, and availability.

Exploitability

The vulnerability is remotely exploitable over a network without requiring authentication or user interaction, resulting in a CVSS base score of 9.8. The EPSS score indicates a current low exploitation probability in the wild, and CISA KEV status is false.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-27. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
npm mongoose >= 0, < 6.13.11 6.13.11 npm install [email protected]
npm mongoose >= 7.0.0, < 7.8.12 7.8.12 npm install [email protected]
npm mongoose >= 8.0.0, < 8.24.3 8.24.3 npm install [email protected]
npm mongoose >= 9.0.0, < 9.9.2 9.9.2 npm install [email protected]

CVSS 3.1 vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Attack vectorNetwork
Attack complexityLow
Privileges requiredNone
User interactionNone
ScopeUnchanged
ConfidentialityHigh
IntegrityHigh
AvailabilityHigh

FAQ

What causes CVE-2026-125120?

The vulnerability is caused by the omission of the sanitizeFilter mechanism on `countDocuments()` queries in Mongoose.

Which versions of Mongoose are affected?

Versions introduced before 6.13.11, between 7.0.0 and 7.8.12, between 8.0.0 and 8.24.3, and between 9.0.0 and 9.9.2 are affected.

Is there a workaround if I cannot upgrade immediately?

Yes, you can use a middleware plugin to explicitly apply `mongoose.sanitizeFilter(this.getFilter())` on `countDocuments` pre-hooks.

Original advisory description
### Impact `sanitizeFilter` is Mongoose's mechanism for protecting against query selector injection attacks. In older versions of Mongoose, `sanitizeFilter` was not applied for `countDocuments()` queries. ### Patches Patches have been released for all supported Mongoose major release lines. Please upgrade to the following versions depending on which major version of Mongoose applications are using. 1. `^9.9.2` 2. `^8.24.3` 3. `^7.8.12` 4. `^6.13.11` ### Workarounds Middleware: ```javascript mongoose.plugin(function() { schema.pre('countDocuments', function() { // This will always apply `sanitizeFilter` on `countDocuments` mongoose.sanitizeFilter(this.getFilter()); }); }); ```

References

Source records: GHSA-pcrw-h46h-c93h (OSV.dev) · EPSS by FIRST, 2026-11-27.