Mongoose: sanitizeFilter not applied on countDocuments
CVE-2026-125120 · GHSA-pcrw-h46h-c93h · EUVD-2026-120503 · published 9 Nov 2026
How serious is it
- Severity: critical, CVSS score 9.8 out of 10.
- No exploit prediction (EPSS) score yet.
- Not on the CISA list of exploited vulnerabilities.
- No public exploit in Exploit-DB.
Is your app affected by CVE-2026-125120?
Paste this prompt into Claude Code, Cursor or any AI coding tool: it runs a free Shippable scan of your project and fixes what it finds. Built with Lovable, Bolt or v0? Scan your live app. Or upload your package file.
Who is affected
mongoose(npm) < 6.13.11mongoose(npm) >= 7.0.0, < 7.8.12mongoose(npm) >= 8.0.0, < 8.24.3mongoose(npm) >= 9.0.0, < 9.9.2
How to check
- Run
npm ls mongoosein your project to see the installed version, including copies pulled in by other packages. - Or paste your lockfile into the checker: it lists every package with a known vulnerability, this one included.
- Or run
npx shippable-dev scan localhost:3000in your project folder. It reads your lockfile and flags this vulnerability along with every other known one.
How to fix
Copies a prompt for Claude Code, Cursor or Codex: it checks your lockfiles for this and upgrades it.
- On < 6.13.11: Upgrade
mongooseto 6.13.11 or later, commit the lockfile and redeploy. - On >= 7.0.0, < 7.8.12: Upgrade
mongooseto 7.8.12 or later, commit the lockfile and redeploy. - On >= 8.0.0, < 8.24.3: Upgrade
mongooseto 8.24.3 or later, commit the lockfile and redeploy. - On >= 9.0.0, < 9.9.2: Upgrade
mongooseto 9.9.2 or later, commit the lockfile and redeploy. - If a vulnerable version was live, check your logs and rotate the secrets that server could read.
The advisory
### 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());
});
});
```
Check your whole app
Dependencies are only half of it. Free and read-only: before you push, run npx shippable-dev scan localhost:3000 in your project folder, no account needed. For your live app, you prove it's yours with a one-line tag first.
References
- github.com/Automattic/mongoose/security/advisories/GHSA-pcrw-h46h-c93h
- github.com/Automattic/mongoose/commit/7e912af3fac52cb0eea4cd71e24d65318916831a
- github.com/Automattic/mongoose/commit/8b10d5760bb181f5bf5d01495cde161c8aed0557
- github.com/Automattic/mongoose/commit/b1df045aab076b740fdaec14a15a44c694b85b7d
- github.com/Automattic/mongoose/commit/b5003d3915db1cf9209c38a4b93cf3a92cddd710
- github.com/Automattic/mongoose/releases/tag/6.13.11
- github.com/Automattic/mongoose/releases/tag/7.8.12
- github.com/Automattic/mongoose/releases/tag/8.24.3
- github.com/Automattic/mongoose/releases/tag/9.9.2
- nvd.nist.gov/vuln/detail/CVE-2026-125120
- github.com/advisories/GHSA-pcrw-h46h-c93h
- github.com/Automattic/mongoose
Merged from ENISA EUVD, GitHub Advisory Database, OSV. Last updated 11 Nov 2026. All vulnerabilities · RSS · JSON