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 #119

Closed
wants to merge 5 commits into 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#2
Vulnerability README | https://github.com/418sec/huntr/blob/master/bounties/npm/json8-patch/1/README.md

User Comments:

📊 Metadata *

json8-patch 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-json8-patch

⚙️ 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 json8Patch = require("json8-patch")
var obj = {}
const patch = [{op: "add", path: "/__proto__/polluted", value: "Yes! Its Polluted"}];
console.log("Before : " + obj.polluted);
json8Patch.apply(obj, patch);
console.log("After : " + {}.polluted);
  1. Execute the following commands in another terminal:
npm i json8-patch # 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 12-22-05

🔥 Proof of Fix (PoF) *

After fix execution will block prototype pollution and throw an exception according to herror handling in lib, see https://github.com/sonnyp/JSON8/blob/master/packages/patch/lib/walk.js#L23-L25

Captura de pantalla de 2020-10-29 12-39-14

👍 User Acceptance Testing (UAT)

After fix functionality is unafected

@JamieSlome
Copy link

@sonnyp - same as the other, let me know if you have any questions! 🍰

@sonnyp
Copy link
Owner

sonnyp commented Nov 8, 2020

I'm confused.

Are you @luci-m-666 ?

If so why did you submit (twice) the same code changes as #117 ? Why are those commits made by @alromh87 ?

If not why claiming credit?

@sonnyp
Copy link
Owner

sonnyp commented Nov 8, 2020

duplicate of duplicate of #117

@sonnyp sonnyp closed this Nov 8, 2020
@alromh87
Copy link

alromh87 commented Nov 8, 2020

Maybe because @luci-m-666 loved much my work 😋

He also pushed this changes two days after me:

flitbit/json-ptr#26

Maybe he didn't copied just got exactly the same thinking as I do, character by character 🙃

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.

4 participants