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

Fix Prototype Pollution withouth throwing #2

Closed
wants to merge 2 commits into from

Conversation

alromh87
Copy link

@alromh87 alromh87 commented Oct 22, 2020

📊 Metadata *

json-ptr 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-json-ptr/

⚙️ 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 {JsonPointer } = require("json-ptr")
var obj = {}
console.log("Before : " + obj.polluted);
JsonPointer.set(obj,'/__proto__/polluted','Yes! Its Polluted', true);
var obj1 ={}
console.log("After : " + obj1.polluted);
  1. Execute the following commands in another terminal:
npm i json-ptr # Install affected module
node poc.js #  Run the PoC
  1. Check the Output:
Before : undefined
After : Yes! Its Polluted

🔥 Proof of Fix (PoF) *

After fix execution will block prototype pollution and return undefined object
Captura de pantalla de 2020-10-22 10-15-10

👍 User Acceptance Testing (UAT)

After fix functionality is unafected

@alromh87 alromh87 mentioned this pull request Oct 22, 2020
@alromh87 alromh87 changed the title Fix Prototype Pollution Fix Prototype Pollution withouth throeing Oct 22, 2020
@alromh87 alromh87 changed the title Fix Prototype Pollution withouth throeing Fix Prototype Pollution withouth throwing Oct 22, 2020
@ghost
Copy link

ghost commented Oct 22, 2020

Thanks for the fix! Closing this one as it's been fixed upstream 👍

@ghost ghost closed this Oct 22, 2020
@huntr-helper
Copy link

Sorry alromh87, 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

This pull request was closed.
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.

2 participants