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().
Affected software
| Software | Affected versions |
|---|---|
mongoosenpm · osv:npm:mongoose |
|
About mongoose
- Weekly downloads (npm)
- 8,359,311npm, 1 Dec 2026
Vulnerabilities in mongoose
- In our list
- 8
- Published in the last 12 months
- 8
- Critical, last 12 months
- 1
- High, last 12 months
- 3
- Known exploited
- 0
- CVE-2026-142596Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`High 7.5 4 Dec 2026
- CVE-2026-142608Mongoose: Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other commandLow 3 Dec 2026
- CVE-2026-125116Mongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collectionsMedium 4.8 10 Nov 2026
- CVE-2026-125117Mongoose walks into inherited properties when hydrating, setting, and merging, allowing overwrites of built-in functions (denial of service) and shared schema stateHigh 8.2 10 Nov 2026
- CVE-2026-125118Mongoose: Prototype pollution via Schema.prototype.virtual()Medium 6.5 10 Nov 2026
- CVE-2026-125119Mongoose: Connection-level sanitizeFilter not appliedHigh 7.5 10 Nov 2026
References
- CVE.org https://www.cve.org/CVERecord?id=CVE-2026-142595
- GitHub Advisory Database https://github.com/advisories/GHSA-25v4-hrwm-qj9f