CVE-2026-125120 is a critical-severity (CVSS 9.8) CWE-943 vulnerability in mongoose. A fix is available for mongoose — see the affected versions and patch details below.
Mongoose: sanitizeFilter not applied on countDocuments
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
mongoosenpmDescription
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 Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | mongoose | all versions | 6.13.11npm install mongoose@6.13.11 |
| 📦npm | mongoose | ≥ 7.0.0&&< 7.8.12 | 7.8.12npm install mongoose@7.8.12 |
| 📦npm | mongoose | ≥ 8.0.0&&< 8.24.3 | 8.24.3npm install mongoose@8.24.3 |
| 📦npm | mongoose | ≥ 9.0.0&&< 9.9.2 | 9.9.2npm install mongoose@9.9.2 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for mongoose, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update mongoose to 6.13.11 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-125120 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Frequently Asked Questions
Is CVE-2026-125120 in your dependencies?
Find it across npm, including transitive dependencies.