CVE-2026-125118
Mongoose: Prototype pollution via Schema.prototype.virtual()
Also known as GHSA-6972-9mcm-vhwj
Mitigation
- Upgrade mongoose to one of 6.13.12, 7.8.13, 8.24.7, 9.11.4 (or later in the same release line).
Who should check
- Projects that depend on npm package mongoose (< 6.13.12)
Vulnerability facts
- Affected
- mongoose < 6.13.12
- Fixed in
- 6.13.12, 7.8.13, 8.24.7, 9.11.4
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Remote, no login needed
- CVSS
- 6.5 (v3.1, GitHub)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:LOpen in CVSS calculator
Show all 8 CVSS metrics
- Attack vector: Network
- Attack complexity: Low
- Privileges required: None
- User interaction: None
- Scope: Unchanged
- Confidentiality impact: None
- Integrity impact: Low
- Availability impact: Low
- EPSS
- 0.64% chance of exploitation in 30 days (percentile 45, 2026-11-28)
- CWE
- CWE-1321
- Modified
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).
Affected and fixed versions
| Package / product | Affected | Fixed | Source |
|---|---|---|---|
| npm mongoose | < 6.13.12 | 6.13.12, 7.8.13, 8.24.7, 9.11.4 | ghsa |
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2026-125118. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2026-125118.md Affected: mongoose < 6.13.12 Fixed in: 6.13.12, 7.8.13, 8.24.7, 9.11.4 Steps: 1. Search this machine and project for mongoose (npm): dependency manifests and lockfiles, installed packages, container images and running services. 2. For each match, note the installed version and whether it is inside the affected range. 3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
Technologies
References
Patches
- https://github.com/Automattic/mongoose/commit/318f7e09dd363a1dfddb8180878488dccd2796d1
- https://github.com/Automattic/mongoose/commit/74df7769b5a8d89c4413b764029911ee915ea467
- https://github.com/Automattic/mongoose/commit/7a2a6567abbb72c0430c8cc5b7942141844fecff
- https://github.com/Automattic/mongoose/commit/fb467e6d33174293dc0360649f20ce68d99117a9
Other
- https://nvd.nist.gov/vuln/detail/CVE-2026-125118
- https://github.com/Automattic/mongoose/releases/tag/6.13.12
- https://github.com/Automattic/mongoose/releases/tag/7.8.13
- https://github.com/Automattic/mongoose/releases/tag/8.24.7
- https://github.com/Automattic/mongoose/releases/tag/9.11.4
- https://github.com/advisories/GHSA-6972-9mcm-vhwj
FAQ
Is CVE-2026-125118 being exploited?
There is no confirmed exploitation: CVE-2026-125118 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.64% chance of exploitation in the next 30 days (as of 2026-11-28).
How serious is CVE-2026-125118?
Medium: CVSS 6.5 (v3.1, scored by GitHub). Remote, no login needed.
Which versions are affected by CVE-2026-125118?
mongoose < 6.13.12.
Is there a fix for CVE-2026-125118?
Yes. Fixed in 6.13.12, 7.8.13, 8.24.7, 9.11.4. Upgrade mongoose to one of 6.13.12, 7.8.13, 8.24.7, 9.11.4 (or later in the same release line).
How do I check if I'm affected by CVE-2026-125118?
Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.
More mongoose vulnerabilities
See all| Severity | Identifier / vulnerability | Technology | Signals | Age |
|---|---|---|---|---|
| MEDIUM 4.8 | CVE-2026-125116 Mongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collections | npm packages | EPSS 37% | |
| HIGH 8.2 | CVE-2026-125117 Mongoose walks into inherited properties when hydrating, setting, and merging, allowing overwrites of built-in functions (denial of service) and shared schema state | npm packages | EPSS 52% | |
| HIGH 7.5 | CVE-2026-125119 Mongoose: Connection-level sanitizeFilter not applied | npm packages | EPSS 47% | |
| CRITICAL 9.8 | CVE-2026-125120 Mongoose: sanitizeFilter not applied on countDocuments | npm packages | EPSS 59% |