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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Fix for Prototype Pollution - huntr.dev #1654

Merged
merged 7 commits into from Jan 7, 2021

Conversation

huntr-helper
Copy link

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#3
Vulnerability README | https://github.com/418sec/huntr/blob/master/bounties/npm/grpc/1/README.md

User Comments:

📊 Metadata *

grpc is vulnerable to Prototype Pollution. This package allowing for modification of prototype behavior, which may result in Information Disclosure/DoS/RCE.

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

⚙️ 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 grpc =require('grpc')
grpc.loadPackageDefinition({'constructor.prototype.polluted': { service: "Yes! Its Polluted" }});
console.log({}.polluted)

Execute the following commands in another terminal:

npm i grpc # Install affected module
node poc.js # Run the PoC

Check the Output:

[Function: ServiceClient] { service: 'Yes! Its Polluted' }`

🔥 Proof of Fix (PoF) *

Before:
image

After:
image

👍 User Acceptance Testing (UAT)

After fix functionality is unaffected.

grpc-proto-test-1

grpc-proto-test-2
grpc-proto-test-3
grpc-proto-test-4
grpc-proto-test-5
grpc-proto-test-6
grpc-proto-test-7

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 16, 2020

CLA Signed

The committers are authorized under a signed CLA.

@JamieSlome
Copy link
Contributor

JamieSlome commented Dec 16, 2020

@murgatroid99 @nicolasnoble - let me know if you have any questions or thoughts, here to help! 🍰

@murgatroid99 murgatroid99 changed the base branch from master to @grpc/grpc-js@1.2.x January 5, 2021 18:52
@murgatroid99
Copy link
Member

I want to note that the vulnerability report links above talk about the grpc package, and this fix is being made to the @grpc/grpc-js package, which is a different thing. I am still happy to accept this fix; I just want to make sure that's clear. The grpc package can be found here, note that it's in the grpc@1.24.x branch.

@JamieSlome
Copy link
Contributor

@murgatroid99 - thanks for the clarification, happy to merge and will ensure the discloser is aware as well.

Thanks! 🍰

@JamieSlome
Copy link
Contributor

@ready-research @d3v53c - just attaching you to make you aware of the above comment...

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

6 participants