Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Fix for Prototype Pollution - huntr.dev #574

Merged
merged 3 commits into from Mar 19, 2021

Conversation

huntr-helper
Copy link
Contributor

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/js-data/1/README.md

User Comments:

馃搳 Metadata *

js-data is vulnerable to Prototype Pollution.

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

鈿欙笍 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
const js = require("js-data");
const payload = JSON.parse('{"__proto__":{"polluted":"Yes! Its Polluted"}}');
var obj = {}
console.log("Before : " + {}.polluted);
js.utils.deepMixIn(obj, payload);
console.log("After : " + {}.polluted);

Execute the following commands in terminal:

npm i js-data # 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

After applying the fix, functionality is unaffected.

馃敆 Relates to...

https://www.huntr.dev/bounties/1-npm-js-data/

d3v53c and others added 3 commits January 15, 2021 06:13
Prototype pollution fix - checking magic attributes - js-data
@KagamiChan
Copy link

KagamiChan commented Mar 18, 2021

Pinging @js-data

The associated CVE is ranked critical / high sev., and is alerting in our security reviews, could someone please help review it?

@KagamiChan
Copy link

KagamiChan commented Mar 18, 2021

Not sure if the org mention is working
pinging @crobinson42 @techniq instead

@crobinson42 crobinson42 merged commit 2d9eed5 into js-data:master Mar 19, 2021
@KagamiChan
Copy link

Thanks @crobinson42 for looking into it, could I expect there's a new release in recent days?

@crobinson42
Copy link
Member

@KagamiChan 3.0.10 released

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.

None yet

5 participants