Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Prototype pollution fix - grpc node - update for the original fix requested by repo maintainer #4

Closed
wants to merge 1 commit into from

Conversation

d3v53c
Copy link

@d3v53c d3v53c commented Jan 12, 2021

📊 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/

This bounty was already rewarded. The issue is still persisted in a legacy branch of the source code. I was notified, when it was raised by one of the maintainers in this PR.

⚙️ 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 the fix, functionality is unaffected.

🔗 Relates to...

  1. Bounty fix PR merged to source.
  2. Bounty fix PR by user
  3. Bounty URL

@d3v53c d3v53c changed the title prototype pollution fix Prototype pollution fix - grpc node - update for the original fix requested by repo maintainer Jan 12, 2021
@JamieSlome
Copy link

@d3v53c - Are you able to create a disclosure for this? And then we can officially create a bounty for it?

Thanks! 🍰

@JamieSlome JamieSlome closed this Jan 21, 2021
@huntr-helper
Copy link

Sorry d3v53c, we enjoyed reviewing your fix but it has not been selected this time. If this bounty has not been closed, please feel free to try again with a new pull request!

We appreciate your effort and look forward to reviewing more of your fixes in the future! 🔨😎

Come join us on Discord

@d3v53c
Copy link
Author

d3v53c commented Jan 21, 2021

@d3v53c - Are you able to create a disclosure for this? And then we can officially create a bounty for it?

Thanks! 🍰

Yes, I will go ahead with that.
Thanks for the clarification.

Cheers!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants