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
- Upgrade Mongoose to version 6.13.11, 7.8.12, 8.24.3, 9.9.2, or later depending on your major release line.
- Implement the recommended middleware workaround to apply sanitizeFilter to countDocuments queries if upgrading immediately is not possible.
How to check your project
- Inspect project dependency files (such as package.json) to check if the mongoose package version falls within the vulnerable ranges (introduced 0 to fixed 6.13.11, introduced 7.0.0 to fixed 7.8.12, introduced 8.0.0 to fixed 8.24.3, or introduced 9.0.0 to fixed 9.9.2).
- Audit application codebase for usages of `countDocuments()` that process unsanitized user input.
Automated analysis of the published advisory data, generated 2026-11-27. Not human-reviewed; verify against the official advisory. How this works.
Affected packages
| Ecosystem | Package | Affected versions | Fixed in | Upgrade |
|---|---|---|---|---|
| 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 vector | Network |
|---|---|
| Attack complexity | Low |
| Privileges required | None |
| User interaction | None |
| Scope | Unchanged |
| Confidentiality | High |
| Integrity | High |
| Availability | High |
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
References
- WEB https://github.com/Automattic/mongoose/security/advisories/GHSA-pcrw-h46h-c93h
- ADVISORY https://nvd.nist.gov/vuln/detail/CVE-2026-125120
- WEB https://github.com/Automattic/mongoose/commit/7e912af3fac52cb0eea4cd71e24d65318916831a
- WEB https://github.com/Automattic/mongoose/commit/8b10d5760bb181f5bf5d01495cde161c8aed0557
- WEB https://github.com/Automattic/mongoose/commit/b1df045aab076b740fdaec14a15a44c694b85b7d
- WEB https://github.com/Automattic/mongoose/commit/b5003d3915db1cf9209c38a4b93cf3a92cddd710
- PACKAGE https://github.com/Automattic/mongoose
- WEB https://github.com/Automattic/mongoose/releases/tag/6.13.11
- WEB https://github.com/Automattic/mongoose/releases/tag/7.8.12
- WEB https://github.com/Automattic/mongoose/releases/tag/8.24.3
- WEB https://github.com/Automattic/mongoose/releases/tag/9.9.2
Source records: GHSA-pcrw-h46h-c93h (OSV.dev) · EPSS by FIRST, 2026-11-27.