Advisory Database
  • Advisories
  • Dependency Scanning
  1. npm
  2. ›
  3. mongoose
  4. ›
  5. CVE-2026-42334

CVE-2026-42334: Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection

May 5, 2026

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.

References

  • github.com/Automattic/mongoose
  • github.com/Automattic/mongoose/security/advisories/GHSA-wpg9-53fq-2r8h
  • github.com/advisories/GHSA-wpg9-53fq-2r8h
  • mongoosejs.com/docs/api/mongoose.html
  • nvd.nist.gov/vuln/detail/CVE-2026-42334
  • thecodebarbarian.com/whats-new-in-mongoose-6-sanitizefilter.html

Code Behaviors & Features

Detect and mitigate CVE-2026-42334 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 6.13.9, all versions starting from 7.0.0 before 7.8.9, all versions starting from 8.0.0 before 8.22.1, all versions starting from 9.0.0 before 9.1.6

Fixed versions

  • 6.13.9
  • 7.8.9
  • 8.22.1
  • 9.1.6

Solution

Upgrade to versions 6.13.9, 7.8.9, 8.22.1, 9.1.6 or above.

Impact 7.5 HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Learn more about CVSS

Weakness

  • CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')

Source file

npm/mongoose/CVE-2026-42334.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sat, 09 May 2026 00:19:10 +0000.