mongoose
Affected
- introduced
0, fixed6.13.9(semver)
Fixed versions
6.13.9
Fix
- Fixed version
6.13.9npm install [email protected]
Advisory
Also known as: BIT-mongoose-2026-42334, CVE-2026-42334
Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection
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:
Affected users:
Applications that:
Model.findOne(req.body)) and rely on sanitizeFilter to strip out query selectorsApplications 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
High Basis: The source's own band: HIGH
0, fixed 6.13.9 (semver)6.13.9
6.13.9npm install [email protected]7.0.0, fixed 7.8.9 (semver)7.8.9
7.8.9npm install [email protected]8.0.0, fixed 8.22.1 (semver)8.22.1
8.22.1npm install [email protected]9.0.0, fixed 9.1.6 (semver)9.1.6
9.1.6npm install [email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0