Prototype Pollution lodash 4.17.15
The lodash functions setWith and set allow an attacker to add properties to the global Object.prototype by using a crafted path. This can cause a denial of service and may let an attacker control sensitive variables in an application.
- Triaged in 44 hours
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 4 months
I would like to report Prototype Pollution in lodash version 4.17.15 It allows Denial of Service and more.
Module
module name: lodash
version: 4.17.15
npm page: https://www.npmjs.com/package/lodash
Module Description
The Lodash library exported as Node.js modules.
Module Stats
27M in the last week
Vulnerability
Vulnerability Description
Steps To Reproduce:
- Create a JS file with this contents:
lod = require('lodash') lod.setWith({}, "proto[test]", "123") lod.set({}, "proto[test2]", "456") console.log(test) console.log(test2)
- Execute it with node
- Observe that test and test2 are now on the Object.prototype.
Supporting Material/References:
This is a variation on: https://hackerone.com/reports/380873
Wrap up
- I contacted the maintainer to let them know: N
- I opened an issue in the related repository: N
Impact
test and test2 could just have easily been toString(). This would allow an attacker to cause a denial of service as all objects inherit from the Object.prototype. Additionally, if there are sensitive variables and attributes in a particular application, these can be controlled via the prototype.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the library does not block the special __proto__ key when setting nested properties, so it writes directly onto Object.prototype.
Impact
An attacker could cause a denial of service, and if the application has sensitive variables, they could be controlled through the prototype.
What the attacker needed
Application uses lodash set or setWith; attacker can control the path argument
How it was found
- Create a JavaScript file that requires lodash and calls setWith and set with a path containing __proto__.
- Run the file with Node.js.
- Check that the new properties appear on Object.prototype.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Prototype pollution is a bug where an attacker can add or change properties on a base object that many other objects inherit from. In JavaScript, almost every object inherits from Object.prototype, so polluting it can break the whole application or let an attacker influence how it behaves.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.