Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Affected versions of this package are vulnerable to Prototype Pollution. The Schema.path() function is vulnerable to prototype pollution when setting the schema object. This vulnerability allows modification of the Object prototype and could be manipulated into a Denial of Service (DoS) attack.
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
Affected versions of this package are vulnerable to Prototype Pollution. The Schema.path() function is vulnerable to prototype pollution when setting the schema object. This vulnerability allows modification of the Object prototype and could be manipulated into a Denial of Service (DoS) attack.
Proof of Concept
// poc.jsconstmongoose=require('mongoose');constschema=newmongoose.Schema();malicious_payload='__proto__.toString'schema.path(malicious_payload,[String])x={}console.log(x.toString())// crashed (Denial of service (DoS) attack)
Impact
This vulnerability can be manipulated to exploit other types of attacks, such as Denial of service (DoS), Remote Code Execution, or Property Injection.
Mongoose versions prior to 8.9.5, 7.8.4, and 6.13.6 are vulnerable to improper use of the $where operator. This vulnerability arises from the ability of the $where clause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.
NOTE: this issue exists because of an incomplete fix for CVE-2024-53900.
Mongoose versions prior to 8.8.3, 7.8.3, 6.13.5, and 5.13.23 are vulnerable to improper use of the $where operator. This vulnerability arises from the ability of the $where clause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.
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.
feat(model): add throwOnValidationError option for opting into getting MongooseBulkWriteError if all valid operations succeed in bulkWrite() and insertMany() #14599#14587#14572#13410
fix(schema): make Schema.prototype.clone() avoid creating different copies of subdocuments and single nested paths underneath single nested paths #13671#13626
fix: custom debug function not processing all args #13418
fix(collection): handle creating model when connection disconnected with bufferCommands = false #12889
fix(populate): merge instead of overwrite when match is on _id #12891
fix: add guard to stop loadClass copying Document if Document is used as base of loaded class (same hack as implemented for Model already) #12820sgpinkus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
automattic/mongoose vulnerable to Prototype pollution via Schema.path
CVE-2022-2564 / GHSA-f825-f98c-gj3g
More informationDetails
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Affected versions of this package are vulnerable to Prototype Pollution. The Schema.path() function is vulnerable to prototype pollution when setting the schema object. This vulnerability allows modification of the Object prototype and could be manipulated into a Denial of Service (DoS) attack.
Severity
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose Prototype Pollution vulnerability
CVE-2023-3696 / GHSA-9m93-w8w6-76hh
More informationDetails
Prototype Pollution in GitHub repository automattic/mongoose prior to 7.3.3, 6.11.3, and 5.13.20.
Severity
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose Vulnerable to Prototype Pollution in Schema Object
CVE-2022-24304 / GHSA-h8hf-x3f4-xwgp
More informationDetails
Description
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
Affected versions of this package are vulnerable to Prototype Pollution. The Schema.path() function is vulnerable to prototype pollution when setting the schema object. This vulnerability allows modification of the Object prototype and could be manipulated into a Denial of Service (DoS) attack.
Proof of Concept
Impact
This vulnerability can be manipulated to exploit other types of attacks, such as Denial of service (DoS), Remote Code Execution, or Property Injection.
Severity
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose search injection vulnerability
CVE-2025-23061 / GHSA-vg7j-7cwx-8wgw
More informationDetails
Mongoose versions prior to 8.9.5, 7.8.4, and 6.13.6 are vulnerable to improper use of the $where operator. This vulnerability arises from the ability of the $where clause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.
NOTE: this issue exists because of an incomplete fix for CVE-2024-53900.
Severity
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose search injection vulnerability
CVE-2024-53900 / GHSA-m7xq-9374-9rvx
More informationDetails
Mongoose versions prior to 8.8.3, 7.8.3, 6.13.5, and 5.13.23 are vulnerable to improper use of the $where operator. This vulnerability arises from the ability of the $where clause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.
Severity
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection
CVE-2026-42334 / GHSA-wpg9-53fq-2r8h
More informationDetails
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:
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:
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
Severity
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
Automattic/mongoose (mongoose)v6.13.9
Compare Source
6.13.9 / 2026-02-04
v6.13.8
Compare Source
===================
v6.13.7
Compare Source
===================
v6.13.6
Compare Source
===================
v6.13.5
Compare Source
===================
v6.13.4
Compare Source
===================
v6.13.3
Compare Source
===================
v6.13.2
Compare Source
===================
v6.13.1
Compare Source
===================
v6.13.0
Compare Source
===================
v6.12.9
Compare Source
===================
v6.12.8
Compare Source
===================
v6.12.7
Compare Source
===================
v6.12.6
Compare Source
===================
v6.12.5
Compare Source
===================
v6.12.4
Compare Source
===================
v6.12.3
Compare Source
===================
v6.12.2
Compare Source
===================
v6.12.1
Compare Source
===================
v6.12.0
Compare Source
===================
v6.11.6
Compare Source
===================
v6.11.5
Compare Source
===================
v6.11.4
Compare Source
===================
v6.11.3
Compare Source
===================
v6.11.2
Compare Source
===================
v6.11.1
Compare Source
===================
v6.11.0
Compare Source
===================
v6.10.5
Compare Source
===================
v6.10.4
Compare Source
===================
v6.10.3
Compare Source
===================
v6.10.2
Compare Source
===================
v6.10.1
Compare Source
===================
v6.10.0
Compare Source
===================
v6.9.3
Compare Source
==================
v6.9.2
Compare Source
==================
v6.9.1
Compare Source
==================
v6.9.0
Compare Source
==================
v6.8.4
Compare Source
==================
v6.8.3
Compare Source
==================
v6.8.2
Compare Source
==================
v6.8.1
Compare Source
==================
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.