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

- **Severity:** CRITICAL 9.8
- **CVSS:** 9.8 (v3.1, GitHub) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Network; Attack complexity: Low; Privileges required: None; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 0.94% (percentile 59, 2026-11-28)
- **CWE:** CWE-943
- **Aliases:** GHSA-pcrw-h46h-c93h
- **Published:** 2026-11-10T19:37:32.000Z
- **Modified:** 2026-11-10T19:37:33.000Z

## Who should check

- Projects that depend on npm package mongoose (\< 6.13.11)

## 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());
  });
});
\`\`\`

## Affected and fixed versions

- npm `mongoose`: affected \< 6.13.11; fixed 6.13.11, 7.8.12, 8.24.3, 9.9.2 (ghsa)

## Technologies

npm packages

## Mitigation

- Upgrade mongoose to one of 6.13.11, 7.8.12, 8.24.3, 9.9.2 (or later in the same release line).

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-125120. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-125120.md
Affected: mongoose < 6.13.11
Fixed in: 6.13.11, 7.8.12, 8.24.3, 9.9.2

Steps:
1. Search this machine and project for mongoose (npm): dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-125120 being exploited?

There is no confirmed exploitation: CVE-2026-125120 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.94% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2026-125120?

Critical: CVSS 9.8 (v3.1, scored by GitHub). Remote, no login needed.

### Which versions are affected by CVE-2026-125120?

mongoose \< 6.13.11.

### Is there a fix for CVE-2026-125120?

Yes. Fixed in 6.13.11, 7.8.12, 8.24.3, 9.9.2. Upgrade mongoose to one of 6.13.11, 7.8.12, 8.24.3, 9.9.2 (or later in the same release line).

### How do I check if I'm affected by CVE-2026-125120?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/Automattic/mongoose/security/advisories/GHSA-pcrw-h46h-c93h>
- patch: <https://github.com/Automattic/mongoose/commit/7e912af3fac52cb0eea4cd71e24d65318916831a>
- patch: <https://github.com/Automattic/mongoose/commit/8b10d5760bb181f5bf5d01495cde161c8aed0557>
- patch: <https://github.com/Automattic/mongoose/commit/b1df045aab076b740fdaec14a15a44c694b85b7d>
- patch: <https://github.com/Automattic/mongoose/commit/b5003d3915db1cf9209c38a4b93cf3a92cddd710>
- other: <https://nvd.nist.gov/vuln/detail/CVE-2026-125120>
- other: <https://github.com/Automattic/mongoose/releases/tag/6.13.11>
- other: <https://github.com/Automattic/mongoose/releases/tag/7.8.12>
- other: <https://github.com/Automattic/mongoose/releases/tag/8.24.3>
- other: <https://github.com/Automattic/mongoose/releases/tag/9.9.2>
- other: <https://github.com/advisories/GHSA-pcrw-h46h-c93h>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- GitHub Advisory Database: CC-BY 4.0 <https://github.com/advisories/GHSA-pcrw-h46h-c93h> (license: <https://creativecommons.org/licenses/by/4.0/>)
- FIRST EPSS: EPSS scores by FIRST <https://www.first.org/epss/>

HTML: <https://flawdb.com/CVE-2026-125120> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-125120>
