Skip to content

Conversation

@huntr-helper
Copy link
Contributor

https://huntr.dev/users/arjunshibu has fixed the Prototype Pollution vulnerability 🔨. Think you could fix a vulnerability like this?

Get involved at https://huntr.dev/

Q | A
Version Affected | ALL
Bug Fix | YES
Original Pull Request | 418sec#1
Vulnerability README | https://github.com/418sec/huntr/blob/master/bounties/npm/libnested/1/README.md

User Comments:

📊 Metadata *

libnested is vulnerable to Prototype Pollution.

Bounty URL: https://www.huntr.dev/bounties/1-npm-libnested

⚙️ Description *

Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects.
JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain.

💻 Technical Description *

Fix implemented by not allowing to modify object prototype.

🐛 Proof of Concept (PoC) *

  1. Create the following PoC file:
// poc.js
var libnested = require("libnested")
var obj = {}
console.log("Before : " + {}.polluted);
libnested.set(obj, ['__proto__','polluted'], 'Yes! Its Polluted');
console.log("After : " + {}.polluted);
  1. Execute the following commands in terminal:
npm i libnested # Install affected module
node poc.js #  Run the PoC
  1. Check the Output:
Before: undefined
After: Yes! Its Polluted

🔥 Proof of Fix (PoF) *

image

+1 User Acceptance Testing (UAT)

  • I've executed unit tests.
  • After fix the functionality is unaffected.

else if(null == obj[path[i]])
obj = (obj[path[i]] = isNonNegativeInteger(path[i+1]) ? [] : {})
else
else if (!(isPrototypePolluted(path[i])))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good solution to guarding against prototype mutation

@mixmix
Copy link

mixmix commented Nov 22, 2021

Have DM'd @ahdinosaur about this, he's going to get to this soon

@ahdinosaur ahdinosaur merged commit 9619863 into dominictarr:master Nov 24, 2021
@ahdinosaur
Copy link
Collaborator

merged and published as 1.5.1 🎉

@mixmix
Copy link

mixmix commented Nov 24, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants