HighGHSA-wpg9-53fq-2r8hBIT-mongoose-2026-42334CVE-2026-42334

Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection

Published 5 May 2026 · Updated 18 May 2026

Affected packages

Affected
<6.13.9
Fixed in
6.13.9
Update to the fixed version for your release line, for example:npm install mongoose@6.13.9
Affected
>=7.0.0 <7.8.9
Fixed in
7.8.9
Update to the fixed version for your release line, for example:npm install mongoose@7.8.9
Affected
>=8.0.0 <8.22.1
Fixed in
8.22.1
Update to the fixed version for your release line, for example:npm install mongoose@8.22.1
Affected
>=9.0.0 <9.1.6
Fixed in
9.1.6
Update to the fixed version for your release line, for example:npm install mongoose@9.1.6

Details

Impact

This vulnerability allows bypassing Mongoose’s sanitizeFilter query sanitization mechanism via the $nor operator.

When sanitizeFilter is enabled, Mongoose wraps query operators in $eq to neutralize them. However, prior to the fix, $nor was not included in the set of logical operators that are recursively sanitized. Because $nor accepts an array (like $and and $or), and arrays do not trigger hasDollarKeys(), malicious operators such as $ne, $gt, or $regex could be injected inside a $nor clause without being sanitized.

This may lead to:

  • Authentication bypass
  • Unauthorized data access
  • Data exfiltration

Affected users:

Applications that:

  • Explicitly enable sanitizeFilter
  • Pass unsanitized user-controlled input directly into query methods (e.g., Model.findOne(req.body)) and rely on sanitizeFilter to strip out query selectors

Applications that validate input schemas, whitelist fields, or avoid passing raw request bodies into queries are not affected. For example, Model.findOne({ user: req.body.user, pwd: req.body.pwd }) is not affected.

Patches

Patches have been released for all supported Mongoose release lines:

  • ^6.13.9
  • ^7.8.9
  • ^8.22.1
  • ^9.1.6

Workarounds

Delete $nor keys, use an additional schema validation library, or write middleware to strip out $nor from query filters.

Resources

sanitizeFilter documentation: https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.sanitizeFilter()

Original blog post on sanitizeFilter: https://thecodebarbarian.com/whats-new-in-mongoose-6-sanitizefilter.html

Is GHSA-wpg9-53fq-2r8h in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected mongoose, and gives you the command that fixes it.

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.