---
title: "GHSA-pcrw-h46h-c93h: Mongoose: sanitizeFilter not applied on countDocuments"
description: "Critical severity. Mongoose: sanitizeFilter not applied on countDocuments. Affects mongoose; fixed in 9.9.2."
url: https://inlinr.com/advisories/GHSA-pcrw-h46h-c93h
lang: en
---

[Packages](https://inlinr.com/packages) / [mongoose](https://inlinr.com/packages/mongoose) / [Security](https://inlinr.com/packages/mongoose/security)

Critical Vulnerability GHSA-pcrw-h46h-c93h CVE-2026-125120 Published 10 Nov 2026

# Mongoose: sanitizeFilter not applied on countDocuments

Your version 

Affected releases · [mongoose](https://inlinr.com/packages/mongoose)

- 9.x 9.0.0 – 9.9.1 Fixed in 9.9.2
- 8.x 8.0.0 – 8.24.2 Fixed in 8.24.3
- 7.x 7.0.0 – 7.8.11 Fixed in 7.8.12
- 6.x 6.0.0 – 6.13.10 Fixed in 6.13.11
- 5.x and older 0.0.1 – 5.13.23 No fix, no longer updated

On 9.x, the newest line:

```
npm install mongoose@9.9.2
```

Every release on a timeline

9.x 

1. Affected

9.0.0 – 9.9.1  
35 releases
2. Fixed

9.9.2 – 9.13.0  
19 releases

8.x 

1. Affected

8.0.0 – 8.24.2  
104 releases
2. Fixed

8.24.3 – 8.24.11  
9 releases

7.x 

1. Affected

7.0.0 – 7.8.11  
57 releases
2. Fixed

7.8.12 – 7.8.14  
3 releases

6.x 

1. Affected

6.0.0 – 6.13.10  
120 releases
2. Fixed

6.13.11 – 6.13.13  
3 releases

5.x 

1. Affected

5.0.0 – 5.13.23  
255 releases

4.x 

1. Affected

4.0.0 – 4.13.21  
164 releases

3.x 

1. Affected

3.0.0 – 3.9.7  
104 releases

2.x 

1. Affected

2.0.0 – 2.9.10  
84 releases

1.x 

1. Affected

1.0.0 – 1.8.4  
64 releases

0.x 

1. Affected

0.0.1 – 0.0.6  
6 releases

1027 stable releases of mongoose, oldest to newest, one row per major.

## What happens

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:

```
mongoose.plugin(function() {
  schema.pre('countDocuments', function() {
    // This will always apply `sanitizeFilter` on `countDocuments`
    mongoose.sanitizeFilter(this.getFilter());
  });
});
```

## How it is exploited

Exploitable over the network, with no account and no action from a user.

- **Confidentiality**: high
- **Integrity**: high
- **Availability**: high

CVSS:3.1/​AV:N/​AC:L/​PR:N/​UI:N/​S:U/​C:H/​I:H/​A:H

## References

- [Reference](https://github.com/Automattic/mongoose/security/advisories/GHSA-pcrw-h46h-c93h "https://github.com/Automattic/mongoose/security/advisories/GHSA-pcrw-h46h-c93h")  
github.com/Automattic/mongoose/security/advisor…
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-125120 "https://nvd.nist.gov/vuln/detail/CVE-2026-125120")  
nvd.nist.gov/vuln/detail/CVE-2026-125120
- [Fix commit](https://github.com/Automattic/mongoose/commit/7e912af3fac52cb0eea4cd71e24d65318916831a "https://github.com/Automattic/mongoose/commit/7e912af3fac52cb0eea4cd71e24d65318916831a")  
7e912af
- [Fix commit](https://github.com/Automattic/mongoose/commit/8b10d5760bb181f5bf5d01495cde161c8aed0557 "https://github.com/Automattic/mongoose/commit/8b10d5760bb181f5bf5d01495cde161c8aed0557")  
8b10d57
- [Fix commit](https://github.com/Automattic/mongoose/commit/b1df045aab076b740fdaec14a15a44c694b85b7d "https://github.com/Automattic/mongoose/commit/b1df045aab076b740fdaec14a15a44c694b85b7d")  
b1df045
- [Fix commit](https://github.com/Automattic/mongoose/commit/b5003d3915db1cf9209c38a4b93cf3a92cddd710 "https://github.com/Automattic/mongoose/commit/b5003d3915db1cf9209c38a4b93cf3a92cddd710")  
b5003d3
- [Package](https://github.com/Automattic/mongoose "https://github.com/Automattic/mongoose")  
github.com/Automattic/mongoose
- [Reference](https://github.com/Automattic/mongoose/releases/tag/6.13.11 "https://github.com/Automattic/mongoose/releases/tag/6.13.11")  
github.com/Automattic/mongoose/releases/tag/6.1…
- [Reference](https://github.com/Automattic/mongoose/releases/tag/7.8.12 "https://github.com/Automattic/mongoose/releases/tag/7.8.12")  
github.com/Automattic/mongoose/releases/tag/7.8…
- [Reference](https://github.com/Automattic/mongoose/releases/tag/8.24.3 "https://github.com/Automattic/mongoose/releases/tag/8.24.3")  
github.com/Automattic/mongoose/releases/tag/8.2…
- [Reference](https://github.com/Automattic/mongoose/releases/tag/9.9.2 "https://github.com/Automattic/mongoose/releases/tag/9.9.2")  
github.com/Automattic/mongoose/releases/tag/9.9…

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
