CVE-2026-42334
JSON

7.5high

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

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
0.46% (higher than 32% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-wpg9-53fq-2r8hBIT-MONGOOSE-2026-42334

Description

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.9, 7.8.9, 8.22.1, and 9.1.6, a 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 vulnerability is fixed in 6.13.9, 7.8.9, 8.22.1, and 9.1.6.

Affected

Product or packageVersionsReported by
Automattic mongoose< 6.13.9, >= 7.0.0, <= 7.8.8, >= 8.0.0, <= 8.22.0, >= 9.0.0, <= 9.1.5CVE List
mongoose (npm)before 6.13.9, from 7.0.0 before 7.8.9, from 8.0.0 before 8.22.1, from 9.0.0 before 9.1.6GitHub Advisory Database
mongoosejs mongoosebefore 6.13.9, from 7.0.0 before 7.8.9, from 8.0.0 before 8.22.1, from 9.0.0 before 9.1.6NVD
mongoose (Bitnami)before 6.13.9, from 7.0.0 before 7.8.9, from 8.0.0 before 8.22.1, from 9.0.0 before 9.1.6Bitnami Vulnerability Database

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Bitnami Vulnerability Databasehigh rating

Classification

CWE-74

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.9, 7.8.9, 8.22.1, and 9.1.6, a 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 vulnerability is fixed in 6.13.9, 7.8.9, 8.22.1, and 9.1.6.

GitHub Advisory Database
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

NVD (es)

Mongoose es una herramienta de modelado de objetos de MongoDB diseñada para funcionar en un entorno asíncrono. Antes de las versiones 6.13.9, 7.8.9, 8.22.1 y 9.1.6, una vulnerabilidad permite eludir el mecanismo de saneamiento de consultas sanitizeFilter de Mongoose a través del operador $nor. Cuando sanitizeFilter está habilitado, Mongoose envuelve los operadores de consulta en $eq para neutralizarlos. Sin embargo, antes de la corrección, $nor no estaba incluido en el conjunto de operadores lógicos que son saneados recursivamente. Debido a que $nor acepta un array (como $and y $or), y los arrays no activan hasDollarKeys(), operadores maliciosos como $ne, $gt o $regex podrían ser inyectados dentro de una cláusula $nor sin ser saneados. Esta vulnerabilidad está corregida en las versiones 6.13.9, 7.8.9, 8.22.1 y 9.1.6.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-42334 changed 2026-05-14CVE Terms of Use
GitHub Advisory DatabaseGHSA-wpg9-53fq-2r8h changed 2026-05-18CC-BY-4.0
NVDCVE-2026-42334 changed 2026-10-26Public domain
Bitnami Vulnerability DatabaseBIT-MONGOOSE-2026-42334 changed 2026-09-08Apache-2.0