All vulnerabilities

npm

CVE-2026-142595

Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`

Severity
Medium 6.5
Published
4 Dec 2026
Last changed
4 Dec 2026
Added to UpHeron
4 Dec 2026
Fixed in
6.13.13, 7.8.14, 8.24.10, 9.12.2
Weakness
NoSQL injection (CWE-943)
Attack
Over the network · Only under certain conditions · No login needed · No user action needed
Attacker can
Read data · Change some data
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Also known as
GHSA-25v4-hrwm-qj9f
Sources
OSV.dev and GitHub

Description

Mongoose's sanitizeFilter option is meant to block query selector injection. Before this fix, it only refused four top-level operators by name: $jsonSchema, $where, $expr and $text. Any other top-level $ operator was passed to MongoDB unchanged. That includes undocumented internal operators like $_internalSchemaXor and $_internalSchemaCond, which take sub-filters, and sanitizeFilter never inspected those sub-filters. An attacker who controls the keys of a query filter could use them to slip arbitrary query selectors like $ne or $regex past sanitizeFilter.

With sanitizeFilter enabled, Mongoose:

  • wraps any object value containing $ keys in $eq, so { password: { $ne: null } } becomes { password: { $eq: { $ne: null } } };
  • recurses into $and, $or and $nor;
  • throws on $jsonSchema, $where, $expr and $text unless the value is wrapped in mongoose.trusted().
From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Affected software

SoftwareAffected versions
mongoosenpm · osv:npm:mongoose
  • Every version before 6.13.13
  • From 7.0.0 before 7.8.14
  • From 8.0.0 before 8.24.10
  • From 9.0.0 before 9.12.2

About mongoose

Weekly downloads (npm)
8,359,311npm, 1 Dec 2026

References