9.8critical
Mongoose: sanitizeFilter not applied on countDocuments
- Severity
- 9.8critical CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.75% (higher than 56% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-pcrw-h46h-c93hBIT-MONGOOSE-2026-125120
Description
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.11, 7.8.12, 8.24.3, and 9.9.2, Mongoose countDocuments() does not apply the configured sanitizeFilter query selector injection defense. An application that enables sanitizeFilter and passes attacker-controlled filter values to countDocuments() can therefore process query operator objects as operators rather than literal values, causing the count to include documents that should not match and potentially undermining authorization or application logic based on that count. This issue is fixed in versions 6.13.11, 7.8.12, 8.24.3, and 9.9.2.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Automattic mongoose | < 6.13.11, >= 7.0.0, < 7.8.12, >= 8.0.0, < 8.24.3, >= 9.0.0, < 9.9.2 | CVE List |
| mongoose (npm) | before 6.13.11, from 7.0.0 before 7.8.12, from 8.0.0 before 8.24.3, from 9.0.0 before 9.9.2 | GitHub Advisory Database |
| mongoose (Bitnami) | before 6.13.11, from 7.0.0 before 7.8.12, from 8.0.0 before 8.24.3, from 9.0.0 before 9.9.2 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| GitHub | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| Bitnami Vulnerability Database | critical rating |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.
What each source says
CVE List
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.11, 7.8.12, 8.24.3, and 9.9.2, Mongoose countDocuments() does not apply the configured sanitizeFilter query selector injection defense. An application that enables sanitizeFilter and passes attacker-controlled filter values to countDocuments() can therefore process query operator objects as operators rather than literal values, causing the count to include documents that should not match and potentially undermining authorization or application logic based on that count. This issue is fixed in versions 6.13.11, 7.8.12, 8.24.3, and 9.9.2.
GitHub Advisory Database
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.
^9.9.2^8.24.3^7.8.12^6.13.11
Workarounds
Middleware:
mongoose.plugin(function() {
schema.pre('countDocuments', function() {
// This will always apply `sanitizeFilter` on `countDocuments`
mongoose.sanitizeFilter(this.getFilter());
});
});
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-125120 changed 2026-11-13 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-pcrw-h46h-c93h changed 2026-11-27 | CC-BY-4.0 |
| NVD | CVE-2026-125120 changed 2026-11-13 | Public domain |
| Bitnami Vulnerability Database | BIT-MONGOOSE-2026-125120 changed 2026-11-27 | Apache-2.0 |