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 package | Versions | Reported by |
|---|---|---|
| Automattic mongoose | < 6.13.9, >= 7.0.0, <= 7.8.8, >= 8.0.0, <= 8.22.0, >= 9.0.0, <= 9.1.5 | CVE 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.6 | GitHub Advisory Database |
| mongoosejs mongoose | 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.6 | NVD |
| 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.6 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| Bitnami Vulnerability Database | high rating |
Classification
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 onsanitizeFilterto 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
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-42334 changed 2026-05-14 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-wpg9-53fq-2r8h changed 2026-05-18 | CC-BY-4.0 |
| NVD | CVE-2026-42334 changed 2026-10-26 | Public domain |
| Bitnami Vulnerability Database | BIT-MONGOOSE-2026-42334 changed 2026-09-08 | Apache-2.0 |