CVE-2026-125120
JSON

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 packageVersionsReported by
Automattic mongoose< 6.13.11, >= 7.0.0, < 7.8.12, >= 8.0.0, < 8.24.3, >= 9.0.0, < 9.9.2CVE 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.2GitHub 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.2Bitnami Vulnerability Database

All scores

GitHub_M9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Bitnami Vulnerability Databasecritical rating

Classification

CWE-943

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.

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

References

Sources

SourceRecordLicence
CVE ListCVE-2026-125120 changed 2026-11-13CVE Terms of Use
GitHub Advisory DatabaseGHSA-pcrw-h46h-c93h changed 2026-11-27CC-BY-4.0
NVDCVE-2026-125120 changed 2026-11-13Public domain
Bitnami Vulnerability DatabaseBIT-MONGOOSE-2026-125120 changed 2026-11-27Apache-2.0