Skip to content

Security Fix for Prototype Pollution - huntr.dev#5

Open
huntr-helper wants to merge 3 commits into
frenchroasted:masterfrom
418sec:1-npm-path-toolkit
Open

Security Fix for Prototype Pollution - huntr.dev#5
huntr-helper wants to merge 3 commits into
frenchroasted:masterfrom
418sec:1-npm-path-toolkit

Conversation

@huntr-helper

Copy link
Copy Markdown

https://huntr.dev/users/d3v53c 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#2
Vulnerability README | https://github.com/418sec/huntr/blob/master/bounties/npm/path-toolkit/1/README.md

User Comments:

📊 Metadata *

path-toolkit is vulnerable to Prototype Pollution.

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

⚙️ 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 *

Fixed by avoiding setting magical attributes. The bug is fixed by validating the input strArray to check for prototypes. It is implemented by a simple validation to check for prototype keywords (proto, constructor and prototype), where if it exists, the function returns the object without modifying it, thus fixing the Prototype Pollution Vulnerability.

🐛 Proof of Concept (PoC) *

Create the following PoC file:

// poc.js
var pathToolkit = require("path-toolkit")
var ptk = new pathToolkit();
var obj = {}
console.log("Before : " + {}.polluted);
ptk.set(obj,"__proto__.polluted","Yes! Its Polluted");
console.log("After : " + {}.polluted);

Execute the following commands in terminal:

npm i path-toolkit # Install affected module
node poc.js #  Run the PoC

Check the Output:

Before : undefined
After : Yes! Its Polluted

🔥 Proof of Fix (PoF) *

Before:
image

After:
image

👍 User Acceptance Testing (UAT)

image

image

image

image

After fix, the functionality is unaffected.

🔗 Relates to...

https://www.huntr.dev/bounties/1-npm-path-toolkit/

d3v53c and others added 3 commits December 21, 2020 13:06
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.

3 participants