MEDIUM · CVSS 3.1 6.5 EPSS 0.6% · 45th percentile CWE-1321

CVE-2026-125118: Mongoose: Prototype pollution via Schema.prototype.virtual()

Published 2026-11-10 · Updated 2026-11-27 · Also known as BIT-mongoose-2026-125118, GHSA-6972-9mcm-vhwj

Summary

Mongoose contains a prototype pollution vulnerability via Schema.prototype.virtual() due to missing special property checks on parsed path segments. All engineering teams utilizing dynamic schema definitions or untrusted input for Mongoose virtuals must update their dependencies.

Who is affected

Affected deployments are those where attacker-influenced schema field names are passed to Schema.prototype.virtual(), such as in dynamic schemas, CMS form builders, or schema-as-code scenarios. This allows pollution of Object.prototype and Function.prototype, potentially enabling property spoofing or leveraging function prototype gadgets.

Exploitability

The vulnerability has a CVSS 3.1 base score of 6.5 (Medium) with a vector indicating network attack vector, low complexity, and no privileges or user interaction required. The EPSS score is 0.006, and CISA Known Exploited Vulnerabilities status is no.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-27. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
npm mongoose >= 0, < 6.13.12 6.13.12 npm install [email protected]
npm mongoose >= 7.0.0, < 7.8.13 7.8.13 npm install [email protected]
npm mongoose >= 8.0.0, < 8.24.7 8.24.7 npm install [email protected]
npm mongoose >= 9.0.0, < 9.11.4 9.11.4 npm install [email protected]

CVSS 3.1 vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L

Attack vectorNetwork
Attack complexityLow
Privileges requiredNone
User interactionNone
ScopeUnchanged
ConfidentialityNone
IntegrityLow
AvailabilityLow

FAQ

What causes the vulnerability in Mongoose?

Schema.prototype.virtual() fails to check for special properties like __proto__, constructor, and prototype when processing path segments, unlike path() and add() methods.

Is this vulnerability actively exploited in the wild?

No, CISA Known Exploited Vulnerabilities status is no.

What components of JavaScript are impacted by the pollution?

Object.prototype and Function.prototype can be polluted, introducing enumerable keys visible on every object or leveraging Function.prototype gadgets.

Original advisory description
### 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()`, `virtual()` never received the `specialProperties` check added for CVE-2022-2564/CVE-2022-24304 (`lib/schema.js` lines 806, 1308, 1331). A path containing `__proto__`/`constructor`/`prototype` segments resolves through the prototype chain and writes onto `Object.prototype` / `Function.prototype`. ### Proof of concept ```javascript const mongoose = require('mongoose'); const schema = new mongoose.Schema({}); schema.virtual('__proto__.polluted'); console.log(({}).polluted); // VirtualType instance console.log(Object.prototype.hasOwnProperty('polluted')); // true console.log(Object.getOwnPropertyDescriptor( Object.prototype, 'polluted').enumerable); // true schema.virtual('constructor.prototype.opol'); console.log(({}).opol); // true schema.virtual('hasOwnProperty.__proto__.fpol'); console.log((function(){}).fpol); // Function.prototype polluted ``` ### Impact Attacker-influenced schema field names (dynamic schemas, CMS form builders, schema-as-code) allow pollution of Object.prototype (own, enumerable keys visible on every object - e.g. `({}).isAdmin` checks can be spoofed) and Function.prototype (a known gadget primitive in server-side JS).

References

Source records: GHSA-6972-9mcm-vhwj (OSV.dev) · EPSS by FIRST, 2026-11-27.