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

[Fix] fix prototype pollution vuln#1

Merged
JamieSlome merged 2 commits into
418sec:masterfrom
ljharb:stable
Jan 12, 2021
Merged

[Fix] fix prototype pollution vuln#1
JamieSlome merged 2 commits into
418sec:masterfrom
ljharb:stable

Conversation

@ljharb
Copy link
Copy Markdown

@ljharb ljharb commented Jan 11, 2021

📊 Metadata *

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

⚙️ Description *

Note that the link describes pollution via .prototype and .constructor, neither of which are actually "prototype pollution". Mutating a shared object is supposed to be visible across the environment. However, __proto__ is the one that can be unintentional and cause these kind of issues.

Note: in node 0.10, obj['__proto__'] incorrectly does obj.__proto__, which is different according to the spec, so Object.getOwnPropertyDescriptor is needed.

When the key is __proto__ and is not an own property, use Object.defineProperty to create it, avoiding accidental pollution of the [[Prototype]].

💻 Technical Description *

See above.

🐛 Proof of Concept (PoC) *

See the test case.

🔥 Proof of Fix (PoF) *

npm test

👍 User Acceptance Testing (UAT)

npm test

🔗 Relates to...

418sec/huntr#747

See https://www.huntr.dev/bounties/1-npm-doc-path/

Note that the link describes pollution via `.prototype` and
`.constructor`, neither of which are actually "prototype pollution".
Mutating a shared object is *supposed* to be visible across the
environment. However, `__proto__` is the one that can be unintentional
and cause these kind of issues.

Note: in node 0.10, `obj['__proto__']` incorrectly does `obj.__proto__`,
which is different according to the spec, so
Object.getOwnPropertyDescriptor is needed.
@huntr-helper
Copy link
Copy Markdown

Congratulations @ljharb - your fix has been selected! 🎉

Thanks for being part of the community & helping secure the world's open-source code.
If you have any questions, please respond in the comments section, or hit us up on Discord. Your bounty is on its way - keep hunting!

Come join us on Discord

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