Mongoose: Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection
Automattic mongoose
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| mongoose npm |
|
|
Original 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.
From the CVE record · GitHub_M
References
- github.com/Automattic/mongoose/security/advisories/GHSA-wpg9-53fq-2r8hVendor advisory
- github.com/CVEProject/cvelistV5/tree/main/cves/2026/42xxx/CVE-2026-42334.json
- nvd.nist.gov/vuln/detail/CVE-2026-42334
- github.com/Automattic/mongoose
- mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.sanitizeFilter()
- thecodebarbarian.com/whats-new-in-mongoose-6-sanitizefilter.html