Advisory

GHSA-pcrw-h46h-c93h

Also known as: CVE-2026-125120

Summary

Mongoose: sanitizeFilter not applied on countDocuments

Details

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

Severity

Critical Basis: The source's own band: CRITICAL

Dates

Published
2026-11-10 19:37 UTC
Modified
2026-11-10 19:45 UTC

Affected packages and fixes

mongoose

npm · All systems

Affected

  • introduced 0, fixed 6.13.11 (semver)

Fixed versions

6.13.11

Fix

mongoose

npm · All systems

Affected

  • introduced 7.0.0, fixed 7.8.12 (semver)

Fixed versions

7.8.12

Fix

mongoose

npm · All systems

Affected

  • introduced 8.0.0, fixed 8.24.3 (semver)

Fixed versions

8.24.3

Fix

mongoose

npm · All systems

Affected

  • introduced 9.0.0, fixed 9.9.2 (semver)

Fixed versions

9.9.2

Fix

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences