Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Security Fix for Prototype Pollution - huntr.dev #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

huntr-helper
Copy link

https://huntr.dev/users/alromh87 has fixed the Prototype Pollution vulnerability 🔨. alromh87 has been awarded $25 for fixing the vulnerability through the huntr bug bounty program 💵. 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/deep-merge-object/1/README.md

User Comments:

📊 Metadata *

deep-merge-object 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-deep-merge-object

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

🐛 Proof of Concept (PoC) *

  1. Create the following PoC file:
// poc.js
var {objectMerge } = require("deep-merge-object")
const payload = JSON.parse('{"__proto__":{"polluted":"Yes! Its Polluted"}}');
var obj = {}
console.log("Before : " + {}.polluted);
objectMerge(obj, payload);
console.log("After : " + {}.polluted);
  1. Execute the following commands in another terminal:
npm i deep-merge-object # Install affected module
node poc.js #  Run the PoC
  1. Check the Output:
Before : undefined
After : Yes! Its Polluted

Captura de pantalla de 2020-10-29 18-08-48

🔥 Proof of Fix (PoF) *

After fix execution will block prototype pollution and polluted will be undefined for new objects

Captura de pantalla de 2020-10-29 18-10-23

👍 User Acceptance Testing (UAT)

After fix functionality is unafected

@JamieSlome
Copy link

@etc-tiago - let me know if you have any questions or thoughts, 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