mongoose
Ecosystem: npm
Downloads: 33.89 Mln
- 5CriticalAffects 14 versions
- 5HighAffects 18 versions
- 0MediumAffects 0 versions
- 4ModerateAffects 14 versions
- 0LowAffects 0 versions
- Critical5 (35.7%)
- High5 (35.7%)
- Medium0 (0.0%)
- Moderate4 (28.6%)
- Low0 (0.0%)
Monthly breakdown
- Critical
- High
- Medium
- Moderate
- Low
- 5 vulnerabilities
- Critical: 1
- High: 2
- Medium: 0
- Moderate: 2
- Low: 0
- 1 vulnerabilities
- Critical: 0
- High: 0
- Medium: 0
- Moderate: 1
- Low: 0
- 1 vulnerabilities
- Critical: 0
- High: 1
- Medium: 0
- Moderate: 0
- Low: 0
- 1 vulnerabilities
- Critical: 1
- High: 0
- Medium: 0
- Moderate: 0
- Low: 0
- 1 vulnerabilities
- Critical: 0
- High: 1
- Medium: 0
- Moderate: 0
- Low: 0
- 1 vulnerabilities
- Critical: 1
- High: 0
- Medium: 0
- Moderate: 0
- Low: 0
- 1 vulnerabilities
- Critical: 1
- High: 0
- Medium: 0
- Moderate: 0
- Low: 0
- 1 vulnerabilities
- Critical: 0
- High: 1
- Medium: 0
- Moderate: 0
- Low: 0
- 1 vulnerabilities
- Critical: 0
- High: 0
- Medium: 0
- Moderate: 1
- Low: 0
- 1 vulnerabilities
- Critical: 1
- High: 0
- Medium: 0
- Moderate: 0
- Low: 0
Vulnerabilities (14)
Known vulnerabilities affecting mongoose, based on data from OSV.
| ID | Severity | Summary | Affected versions | Published | Source |
|---|---|---|---|---|---|
| GHSA-6972-9mcm-vhwj | Moderate | Mongoose: Prototype pollution via Schema.prototype.virtual()### Summary Prototype pollution via Schema.prototype.virtual() — the 2022 fix for CVE-2022-2564 / CVE-2022-24304 protected Schema.path()/add() but never virtual(), so the same class of bug is still exploitable in all maintained release lines. ### Details In lib/schema.js, Schema.prototype.virtual() (defined at line 2643) builds the virtual path via: ```javascript virtuals[name] = parts.reduce(function(mem, part, i) { mem[part] || (mem[part] = (i === parts.length - 1) ? new VirtualType(options, name) : {}); return mem[part]; }, this.tree); // lines 2755-2759 ``` Unlike `path()`/`add()`, `v |
| GitHub (opens in a new tab) | |
| GHSA-8332-j7wj-wjw4 | High | Mongoose walks into inherited properties when hydrating, setting, and merging, allowing overwrites of built-in functions (denial of service) and shared schema state### Summary Three Mongoose code paths copy data into objects by property name without checking whether the property is the object's own or inherited from its prototype: 1. Loading a document from the database (`init()`, also used by `Model.hydrate()`) 2. Setting a dotted path on a document (`$__set`, used by `new Model(obj)`, `doc.set()` and `doc.$set()`) 3. Merging update documents (`utils.mergeClone`, used by `findOneAndReplace()`, chained update calls and `Query.prototype.merge()`) When a key names an inherited property, such as `toString` or `valueOf`, or a document internal such as `$_ |
| GitHub (opens in a new tab) | |
| GHSA-gg4r-jv3p-qx3c | High | Mongoose: Connection-level sanitizeFilter not applied### Summary sanitizeFilter exists to stop query selector injection: it wraps operator objects such as `{ $ne: null }` in filter values in `$eq`, so they are matched literally. Set on a connection with `mongoose.connect()` or `createConnection(uri, { sanitizeFilter: true })`, the connection reports it as enabled but queries never apply it. An application that relies on the connection-level option and passes an attacker-controlled object into a filter therefore remains open to selector injection, and a password value of `{ $ne: null }` returns the account record without the password. ### Detai |
| GitHub (opens in a new tab) | |
| GHSA-pcrw-h46h-c93h | Critical | Mongoose: sanitizeFilter not applied on countDocuments### Impact `sanitizeFilter` is Mongoose's mechanism for protecting against query selector injection attacks. In older versions of Mongoose, `sanitizeFilter` was not applied for `countDocuments()` queries. ### Patches Patches have been released for all supported Mongoose major release lines. Please upgrade to the following versions depending on which major version of Mongoose applications are using. 1. `^9.9.2` 2. `^8.24.3` 3. `^7.8.12` 4. `^6.13.11` ### Workarounds Middleware: ```javascript mongoose.plugin(function() { schema.pre('countDocuments', function() { // This will always |
| GitHub (opens in a new tab) | |
| GHSA-wr5m-5jph-8m96 | Moderate | Mongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collections### Summary Mongoose chooses which discriminator model or schema to use by looking up the discriminator key value (`__t` by default) in a plain object of registered discriminators, for example `Model.discriminators[doc.__t]`. That value comes from user documents and query filters. Because the lookup did not check own properties, a value that names a property inherited from `Object.prototype` resolves to that inherited value instead of a discriminator. Examples are `'constructor'`, `'toString'` and `'hasOwnProperty'`. - `__t: 'constructor'` resolves to the global `Object` function. Mongoose t |
| GitHub (opens in a new tab) | |
| GHSA-664h-wqgq-64gw | Moderate | Mongoose: Prototype pollution in mongoose update casting via __proto__-prefixed dotted path (Schema._getSchema/path getter)### Impact _What kind of vulnerability is it? Who is impacted?_ Prototype pollution in update casting: passing a user-controlled update to a Mongoose update, like `MyModel.updateOne(filter, req.body)`, can cause Mongoose to set `$fullPath` and `$parentSchemaDocArray` on `Object.prototype`. Example: ```javascript const mongoose = require('mongoose'); console.log('before:', Object.prototype.$fullPath); // undefined const User = mongoose.model('User', new mongoose.Schema({ name: String })); const malicious = JSON.parse('{"$set": {"__proto__.x": "anything"}}'); // attacker-control |
| GitHub (opens in a new tab) | |
| GHSA-wpg9-53fq-2r8h | High | 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: - Authentication bypas |
| GitHub (opens in a new tab) | |
| GHSA-vg7j-7cwx-8wgw | Critical | Mongoose search injection vulnerabilityMongoose 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. |
| GitHub (opens in a new tab) | |
| GHSA-m7xq-9374-9rvx | High | Mongoose search injection vulnerabilityMongoose 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. |
| GitHub (opens in a new tab) | |
| GHSA-9m93-w8w6-76hh | Critical | Mongoose Prototype Pollution vulnerabilityPrototype Pollution in GitHub repository automattic/mongoose prior to 7.3.3, 6.11.3, and 5.13.20. |
| GitHub (opens in a new tab) |
- GHSA-6972-9mcm-vhwjModerateMongoose: Prototype pollution via Schema.prototype.virtual()
< 6.13.12>= 7.0.0, < 7.8.13- +2 more
Affected versions:< 6.13.12>= 7.0.0, < 7.8.13>= 8.0.0, < 8.24.7>= 9.0.0, < 9.11.4
### Summary Prototype pollution via Schema.prototype.virtual() — the 2022 fix for CVE-2022-2564 / CVE-2022-24304 protected Schema.path()/add() but never virtual(), so the same class of bug is still exploitable in all maintained release lines. ### Details In lib/schema.js, Schema.prototype.virtual() (defined at line 2643) builds the virtual path via: ```javascript virtuals[name] = parts.reduce(function(mem, part, i) { mem[part] || (mem[part] = (i === parts.length - 1) ? new VirtualType(options, name) : {}); return mem[part]; }, this.tree); // lines 2755-2759 ``` Unlike `path()`/`add()`, `v
CVE: CVE-2026-125118
- GHSA-8332-j7wj-wjw4HighMongoose walks into inherited properties when hydrating, setting, and merging, allowing overwrites of built-in functions (denial of service) and shared schema state
< 6.13.12>= 7.0.0, < 7.8.13- +2 more
Affected versions:< 6.13.12>= 7.0.0, < 7.8.13>= 8.0.0, < 8.24.7>= 9.0.0, < 9.11.4
### Summary Three Mongoose code paths copy data into objects by property name without checking whether the property is the object's own or inherited from its prototype: 1. Loading a document from the database (`init()`, also used by `Model.hydrate()`) 2. Setting a dotted path on a document (`$__set`, used by `new Model(obj)`, `doc.set()` and `doc.$set()`) 3. Merging update documents (`utils.mergeClone`, used by `findOneAndReplace()`, chained update calls and `Query.prototype.merge()`) When a key names an inherited property, such as `toString` or `valueOf`, or a document internal such as `$_
CVE: CVE-2026-125117
- GHSA-gg4r-jv3p-qx3cHighMongoose: Connection-level sanitizeFilter not applied
>= 6.0.0, < 6.13.12>= 7.0.0, < 7.8.13- +2 more
Affected versions:>= 6.0.0, < 6.13.12>= 7.0.0, < 7.8.13>= 8.0.0, < 8.24.7>= 9.0.0, < 9.11.4
### Summary sanitizeFilter exists to stop query selector injection: it wraps operator objects such as `{ $ne: null }` in filter values in `$eq`, so they are matched literally. Set on a connection with `mongoose.connect()` or `createConnection(uri, { sanitizeFilter: true })`, the connection reports it as enabled but queries never apply it. An application that relies on the connection-level option and passes an attacker-controlled object into a filter therefore remains open to selector injection, and a password value of `{ $ne: null }` returns the account record without the password. ### Detai
CVE: CVE-2026-125119
- GHSA-pcrw-h46h-c93hCriticalMongoose: sanitizeFilter not applied on countDocuments
< 6.13.11>= 7.0.0, < 7.8.12- +2 more
Affected versions:< 6.13.11>= 7.0.0, < 7.8.12>= 8.0.0, < 8.24.3>= 9.0.0, < 9.9.2
### Impact `sanitizeFilter` is Mongoose's mechanism for protecting against query selector injection attacks. In older versions of Mongoose, `sanitizeFilter` was not applied for `countDocuments()` queries. ### Patches Patches have been released for all supported Mongoose major release lines. Please upgrade to the following versions depending on which major version of Mongoose applications are using. 1. `^9.9.2` 2. `^8.24.3` 3. `^7.8.12` 4. `^6.13.11` ### Workarounds Middleware: ```javascript mongoose.plugin(function() { schema.pre('countDocuments', function() { // This will always
CVE: CVE-2026-125120
- GHSA-wr5m-5jph-8m96ModerateMongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collections
< 6.13.12>= 7.0.0, < 7.8.13- +2 more
Affected versions:< 6.13.12>= 7.0.0, < 7.8.13>= 8.0.0, < 8.24.7>= 9.0.0, < 9.11.4
### Summary Mongoose chooses which discriminator model or schema to use by looking up the discriminator key value (`__t` by default) in a plain object of registered discriminators, for example `Model.discriminators[doc.__t]`. That value comes from user documents and query filters. Because the lookup did not check own properties, a value that names a property inherited from `Object.prototype` resolves to that inherited value instead of a discriminator. Examples are `'constructor'`, `'toString'` and `'hasOwnProperty'`. - `__t: 'constructor'` resolves to the global `Object` function. Mongoose t
CVE: CVE-2026-125116
- GHSA-664h-wqgq-64gwModerateMongoose: Prototype pollution in mongoose update casting via __proto__-prefixed dotted path (Schema._getSchema/path getter)
< 6.13.10>= 7.0.0, < 7.8.10- +2 more
Affected versions:< 6.13.10>= 7.0.0, < 7.8.10>= 8.0.0, < 8.24.1>= 9.0.0, < 9.7.2
### Impact _What kind of vulnerability is it? Who is impacted?_ Prototype pollution in update casting: passing a user-controlled update to a Mongoose update, like `MyModel.updateOne(filter, req.body)`, can cause Mongoose to set `$fullPath` and `$parentSchemaDocArray` on `Object.prototype`. Example: ```javascript const mongoose = require('mongoose'); console.log('before:', Object.prototype.$fullPath); // undefined const User = mongoose.model('User', new mongoose.Schema({ name: String })); const malicious = JSON.parse('{"$set": {"__proto__.x": "anything"}}'); // attacker-control
CVE: CVE-2026-73562
- GHSA-wpg9-53fq-2r8hHighMongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection
< 6.13.9>= 7.0.0, < 7.8.9- +2 more
Affected versions:< 6.13.9>= 7.0.0, < 7.8.9>= 8.0.0, < 8.22.1>= 9.0.0, < 9.1.6
### 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 bypas
CVE: CVE-2026-42334
- GHSA-vg7j-7cwx-8wgwCriticalMongoose search injection vulnerability
>= 8.0.0-rc0, < 8.9.5>= 7.0.0-rc0, < 7.8.4- +1 more
Affected versions:>= 8.0.0-rc0, < 8.9.5>= 7.0.0-rc0, < 7.8.4< 6.13.6
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.
CVE: CVE-2025-23061
- GHSA-m7xq-9374-9rvxHighMongoose search injection vulnerability
>= 8.0.0-rc0, < 8.8.3>= 7.0.0-rc0, < 7.8.3- +2 more
Affected versions:>= 8.0.0-rc0, < 8.8.3>= 7.0.0-rc0, < 7.8.3>= 6.0.0-rc0, < 6.13.5>= 3.6.0-rc0, < 5.13.23
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.
CVE: CVE-2024-53900
- GHSA-9m93-w8w6-76hhCriticalMongoose Prototype Pollution vulnerability
>= 7.0.0, < 7.3.3>= 6.0.0, < 6.11.3- +1 more
Affected versions:>= 7.0.0, < 7.3.3>= 6.0.0, < 6.11.3< 5.13.20
Prototype Pollution in GitHub repository automattic/mongoose prior to 7.3.3, 6.11.3, and 5.13.20.
CVE: CVE-2023-3696