mongoose · Vulnerability
cve-program · CVE-2026-125116
PublishedMongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index plain-object registries such as Model.discriminators and schema.discriminators without requiring an own property. Values such as constructor, toString, or hasOwnProperty can therefore resolve to inherited built-in functions instead of a registered discriminator, causing type confusion in model construction, document creation, hydration, query and update casting, embedded discriminators, and populate operations. In the bulkWrite() insertOne path with skipValidation enabled, a constructor value can cause a raw input object to be stored without schema casting or strict filtering, and a stored poisoned document can make every query that hydrates it fail until the document is removed. The weakness reads inherited properties but does not modify Object.prototype and is not prototype pollution. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.
Read the publisher's advisoryeuvd · EUVD-2026-120497
PublishedMongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index plain-object registries such as Model.discriminators and schema.discriminators without requiring an own property. Values such as constructor, toString, or hasOwnProperty can therefore resolve to inherited built-in functions instead of a registered discriminator, causing type confusion in model construction, document creation, hydration, query and update casting, embedded discriminators, and populate operations. In the bulkWrite() insertOne path with skipValidation enabled, a constructor value can cause a raw input object to be stored without schema casting or strict filtering, and a stored poisoned document can make every query that hydrates it fail until the document is removed. The weakness reads inherited properties but does not modify Object.prototype and is not prototype pollution. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.
Read the publisher's advisorynvd · CVE-2026-125116
PublishedMongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index plain-object registries such as Model.discriminators and schema.discriminators without requiring an own property. Values such as constructor, toString, or hasOwnProperty can therefore resolve to inherited built-in functions instead of a registered discriminator, causing type confusion in model construction, document creation, hydration, query and update casting, embedded discriminators, and populate operations. In the bulkWrite() insertOne path with skipValidation enabled, a constructor value can cause a raw input object to be stored without schema casting or strict filtering, and a stored poisoned document can make every query that hydrates it fail until the document is removed. The weakness reads inherited properties but does not modify Object.prototype and is not prototype pollution. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.
Read the publisher's advisoryosv · GHSA-wr5m-5jph-8m96
Published### 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 then calls `new Object(doc)`, which returns the raw user object where a Mongoose document is expected. - `__t: 'toString'` and similar names resolve to built-in functions that throw when used as a constructor or schema. The most serious effect: through `bulkWrite()` `insertOne` with `skipValidation: true`, the raw user object is stored as-is, without schema casting or `strict` filtering. After that, every query that returns the stored document throws, until the document is removed from the database. ### Details The registries that hold discriminators are plain objects: `Model.discriminators`, `schema.discriminators`, and the embedded discriminator registries on document arrays and single nested subdocuments. Several code paths indexed them directly with a value taken from the document or filter: | Code path | Input | |---|---| | Model constructor (`new Model(doc)`) | document | | `Model.create()`, `insertMany()`, `bulkWrite()`, `bulkSave()` | documents | | Hydrating query results (`find()`, `findOne()`, etc.) and `Model.hydrate()` | stored documents | | Casting query filters, including flat paths such as `'events.__t'` and `$elemMatch` | query filter | | Casting updates and array filters | update filter, `arrayFilters` | | Document array `push()` / `create()`, document array and single nested casting | subdocuments | | Populate on embedded discriminators | stored subdocuments | `getDiscriminatorByValue()` already iterated the registry's own keys safely. But most callers tried the direct lookup first and only fell back to it afterwards, so a truthy inherited value took precedence. The lookups only read inherited properties. They do not write to `Object.prototype` or any other shared object, and they do not change in-memory state that affects other requests. This is NOT a prototype pollution vector. ### Proof of concept ```js const mongoose = require('mongoose'); const Base = mongoose.model('Base', new mongoose.Schema({ name: String, age: Number })); Base.discriminator('Child', new mongoose.Schema({ extra: String })); // Type confusion: the "document" is the raw input object const doc = new Base({ name: 'x', __t: 'constructor' }); console.log(doc instanceof mongoose.Document); // false ``` ```js // Schema bypass and persistent poison document via bulkWrite + skipValidation await Base.bulkWrite([{ insertOne: { document: { name: 'x', age: 'not a number', notInSchema: true, __t: 'constructor' } } }], { skipValidation: true }); // Stored verbatim: { age: 'not a number', notInSchema: true, __t: 'constructor', ... } await Base.find(); // throws: Cannot read properties of undefined (reading 'eachPath') ``` ### Impact - **Crashing the request.** An attacker who controls the discriminator key of a document or filter can make the request fail. In most code paths that sent the value, this means a `TypeError` or a non-document object returned to application code. Ways in include `Model.create(req.body)`, `new Model(req.body)`, `Model.find(req.query)`-style filters, and pushing user input onto embedded discriminator arrays. The effect is limited to the request carrying the value. - **Schema bypass on `bulkWrite({ skipValidation: true })`.** When an application passes untrusted documents to `bulkWrite()` `insertOne` with `skipValidation: true`, the raw object is stored without casting or `strict` filtering. Fields the schema would normally strip are persisted, such as an `isAdmin` that isn't in the schema. Fields with wrong types are also persisted. - **Persistent denial of service for queries.** A stored document with such a discriminator key value makes hydration throw. Every query that returns that document fails, for all users, until the document is deleted directly in the database. Besides the `bulkWrite()` path above, the document can get into the collection through another application, the raw MongoDB driver, or any other writer that does not go through Mongoose casting. This issue doesn't let an attacker modify `Object.prototype`, built-in functions, schemas or other shared in-memory state. The schema bypass requires the application to opt in to `skipValidation` with untrusted input.
Read the publisher's advisoryAffected versions, risk and source history
Exploitation and risk
Source statusCISA KEV lists vulnerabilities known to be exploited. FIRST EPSS estimates the likelihood of exploitation in the next 30 days. An unavailable score does not mean zero risk.
Which CVEs have scores here?
This view includes predictions for CVE identifiers explicitly listed in public NuGet advisories. Microsoft release pages have their own prediction coverage. Check source status for the scope and latest checks.
No exploitation or prediction data is available here for these CVEs. This does not mean they are safe or unlikely to be exploited.
cve-program · CVE-2026-125116
PublishedMongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collections
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index plain-object registries such as Model.discriminators and schema.discriminators without requiring an own property. Values such as constructor, toString, or hasOwnProperty can therefore resolve to inherited built-in functions instead of a registered discriminator, causing type confusion in model construction, document creation, hydration, query and update casting, embedded discriminators, and populate operations. In the bulkWrite() insertOne path with skipValidation enabled, a constructor value can cause a raw input object to be stored without schema casting or strict filtering, and a stored poisoned document can make every query that hydrates it fail until the document is removed. The weakness reads inherited properties but does not modify Object.prototype and is not prototype pollution. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.
- Source published
- 9 Nov 2026 22:20:28 UTC
- Source modified
- 13 Nov 2026 13:37:18 UTC
- Saved here
- 13 Nov 2026 14:56:54 UTC
- Source terms
- CVE Program Terms of Use
Original source record · Cite this exact observation · Complete original publisher JSON
Source: cve-program · CVE Program Terms of Use. The publisher's wording is preserved. ChangeIntel groups the information and labels changes. The JSON record includes additional source fields.
CVSS 3.1 · 4.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L
euvd · EUVD-2026-120497
PublishedMongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index …
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index plain-object registries such as Model.discriminators and schema.discriminators without requiring an own property. Values such as constructor, toString, or hasOwnProperty can therefore resolve to inherited built-in functions instead of a registered discriminator, causing type confusion in model construction, document creation, hydration, query and update casting, embedded discriminators, and populate operations. In the bulkWrite() insertOne path with skipValidation enabled, a constructor value can cause a raw input object to be stored without schema casting or strict filtering, and a stored poisoned document can make every query that hydrates it fail until the document is removed. The weakness reads inherited properties but does not modify Object.prototype and is not prototype pollution. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.
Additional publisher context
EUVD source date text has no stated timezone and is retained without inventing a UTC instant. Related bulletin membership is not an alias, common cause or applicability claim. A missing vector with a zero score is treated as unrated. Complete vendor/product and underlying source evidence remains in the original JSON.
Original publisher date fields
datePublished: Nov 9, 2026, 10:20:28 PM
dateUpdated: Nov 13, 2026, 1:37:18 PM
- Source published
- Nov 9, 2026, 10:20:28 PM (timezone not stated)
- Source modified
- Nov 13, 2026, 1:37:18 PM (timezone not stated)
- Saved here
- 14 Nov 2026 22:24:02 UTC
- Source terms
- ENISA EUVD · source terms and attribution apply
Original source record · Cite this exact observation · Complete original publisher JSON
Source: euvd · ENISA EUVD · source terms and attribution apply. The publisher's wording is preserved. ChangeIntel groups the information and labels changes. The JSON record includes additional source fields.
EUVD CVSS 3.1 · 4.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L
nvd · CVE-2026-125116
PublishedMongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index …
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Prior to 6.13.12, 7.8.13, 8.24.7, and 9.11.4, Mongoose uses attacker-controlled discriminator key values, including the default __t field, to index plain-object registries such as Model.discriminators and schema.discriminators without requiring an own property. Values such as constructor, toString, or hasOwnProperty can therefore resolve to inherited built-in functions instead of a registered discriminator, causing type confusion in model construction, document creation, hydration, query and update casting, embedded discriminators, and populate operations. In the bulkWrite() insertOne path with skipValidation enabled, a constructor value can cause a raw input object to be stored without schema casting or strict filtering, and a stored poisoned document can make every query that hydrates it fail until the document is removed. The weakness reads inherited properties but does not modify Object.prototype and is not prototype pollution. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.
Additional publisher context
NVD analysis and CPE criteria are source context, not proof that a package or your environment is affected. Complete affected data, logical configurations and SSVC are retained in the original JSON.
Source analysis status: Awaiting Analysis
Weakness classifications: CWE-843
Original publisher date fields
published: 2026-11-09T23:17:21.907
lastModified: 2026-11-13T14:17:52.353
- Source published
- 9 Nov 2026 23:17:21 UTC
- Source modified
- 13 Nov 2026 14:17:52 UTC
- Saved here
- 14 Nov 2026 23:32:34 UTC
- Source terms
- NIST NVD usage terms; underlying source attribution retained
Original source record · Cite this exact observation · Complete original publisher JSON
Source: nvd · NIST NVD usage terms; underlying source attribution retained. The publisher's wording is preserved. ChangeIntel groups the information and labels changes. The JSON record includes additional source fields.
CVSS 3.1 · [email protected] · Secondary · 4.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L
osv · GHSA-wr5m-5jph-8m96
PublishedMongoose: 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 then calls `new Object(doc)`, which returns the raw user object where a Mongoose document is expected. - `__t: 'toString'` and similar names resolve to built-in functions that throw when used as a constructor or schema. The most serious effect: through `bulkWrite()` `insertOne` with `skipValidation: true`, the raw user object is stored as-is, without schema casting or `strict` filtering. After that, every query that returns the stored document throws, until the document is removed from the database. ### Details The registries that hold discriminators are plain objects: `Model.discriminators`, `schema.discriminators`, and the embedded discriminator registries on document arrays and single nested subdocuments. Several code paths indexed them directly with a value taken from the document or filter: | Code path | Input | |---|---| | Model constructor (`new Model(doc)`) | document | | `Model.create()`, `insertMany()`, `bulkWrite()`, `bulkSave()` | documents | | Hydrating query results (`find()`, `findOne()`, etc.) and `Model.hydrate()` | stored documents | | Casting query filters, including flat paths such as `'events.__t'` and `$elemMatch` | query filter | | Casting updates and array filters | update filter, `arrayFilters` | | Document array `push()` / `create()`, document array and single nested casting | subdocuments | | Populate on embedded discriminators | stored subdocuments | `getDiscriminatorByValue()` already iterated the registry's own keys safely. But most callers tried the direct lookup first and only fell back to it afterwards, so a truthy inherited value took precedence. The lookups only read inherited properties. They do not write to `Object.prototype` or any other shared object, and they do not change in-memory state that affects other requests. This is NOT a prototype pollution vector. ### Proof of concept ```js const mongoose = require('mongoose'); const Base = mongoose.model('Base', new mongoose.Schema({ name: String, age: Number })); Base.discriminator('Child', new mongoose.Schema({ extra: String })); // Type confusion: the "document" is the raw input object const doc = new Base({ name: 'x', __t: 'constructor' }); console.log(doc instanceof mongoose.Document); // false ``` ```js // Schema bypass and persistent poison document via bulkWrite + skipValidation await Base.bulkWrite([{ insertOne: { document: { name: 'x', age: 'not a number', notInSchema: true, __t: 'constructor' } } }], { skipValidation: true }); // Stored verbatim: { age: 'not a number', notInSchema: true, __t: 'constructor', ... } await Base.find(); // throws: Cannot read properties of undefined (reading 'eachPath') ``` ### Impact - **Crashing the request.** An attacker who controls the discriminator key of a document or filter can make the request fail. In most code paths that sent the value, this means a `TypeError` or a non-document object returned to application code. Ways in include `Model.create(req.body)`, `new Model(req.body)`, `Model.find(req.query)`-style filters, and pushing user input onto embedded discriminator arrays. The effect is limited to the request carrying the value. - **Schema bypass on `bulkWrite({ skipValidation: true })`.** When an application passes untrusted documents to `bulkWrite()` `insertOne` with `skipValidation: true`, the raw object is stored without casting or `strict` filtering. Fields the schema would normally strip are persisted, such as an `isAdmin` that isn't in the schema. Fields with wrong types are also persisted. - **Persistent denial of service for queries.** A stored document with such a discriminator key value makes hydration throw. Every query that returns that document fails, for all users, until the document is deleted directly in the database. Besides the `bulkWrite()` path above, the document can get into the collection through another application, the raw MongoDB driver, or any other writer that does not go through Mongoose casting. This issue doesn't let an attacker modify `Object.prototype`, built-in functions, schemas or other shared in-memory state. The schema bypass requires the application to opt in to `skipValidation` with untrusted input.
- Source published
- 10 Nov 2026 20:57:18 UTC
- Source modified
- 10 Nov 2026 21:15:03 UTC
- Saved here
- 10 Nov 2026 21:21:46 UTC
- Source terms
- GitHub Advisory Database · CC-BY-4.0
Original source record · Cite this exact observation · Complete original publisher JSON
Source: osv · GitHub Advisory Database · CC-BY-4.0. The publisher's wording is preserved. ChangeIntel groups the information and labels changes. The JSON record includes additional source fields.
CVSS_V3 · CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L
Publisher rating · MODERATE