Packages / mongoose / Security

HighVulnerabilityGHSA-wpg9-53fq-2r8hBIT-mongoose-2026-42334CVE-2026-42334Published 5 May 2026

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

Your version

Affected releases · mongoose

  • 9.x9.0.0 – 9.1.5Fixed in 9.1.6
  • 8.x8.0.0 – 8.22.0Fixed in 8.22.1
  • 7.x7.0.0 – 7.8.8Fixed in 7.8.9
  • 6.x6.0.0 – 6.13.8Fixed in 6.13.9
  • 5.x and older0.0.1 – 5.13.23No fix, no longer updated

On 9.x, the newest line:

npm install mongoose@9.1.6
Every release on a timeline
9.x
  1. Affected

    9.0.0 – 9.1.5

    9 releases

  2. Fixed

    9.1.6 – 9.11.4

    40 releases, latest

8.x
  1. Affected

    8.0.0 – 8.22.0

    98 releases

  2. Fixed

    8.22.1 – 8.24.7

    11 releases

7.x
  1. Affected

    7.0.0 – 7.8.8

    54 releases

  2. Fixed

    7.8.9 – 7.8.13

    5 releases

6.x
  1. Affected

    6.0.0 – 6.13.8

    118 releases

  2. Fixed

    6.13.9 – 6.13.12

    4 releases

5.x
  1. Affected

    5.0.0 – 5.13.23

    255 releases

4.x
  1. Affected

    4.0.0 – 4.13.21

    164 releases

3.x
  1. Affected

    3.0.0 – 3.9.7

    104 releases

2.x
  1. Affected

    2.0.0 – 2.9.10

    84 releases

1.x
  1. Affected

    1.0.0 – 1.8.4

    64 releases

0.x
  1. Affected

    0.0.1 – 0.0.6

    6 releases

1016 stable releases of mongoose, oldest to newest, one row per major.

What happens

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: mongoosejs.com/docs/api/mongoose.html

Original blog post on sanitizeFilter: thecodebarbarian.com/whats-new-in-mongoose-6-sa…