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

Fix Prototype Pollution #1

Merged
merged 1 commit into from
Oct 19, 2020
Merged

Fix Prototype Pollution #1

merged 1 commit into from
Oct 19, 2020

Conversation

alromh87
Copy link

@alromh87 alromh87 commented Oct 17, 2020

📊 Metadata *

y18n 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-y18n

⚙️ 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.
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 avoid setting magical attributes.

Note that in this case path is not expanded so constructor.prototype would not cause prototype pollution so filtering this magical attributes is not needed

🐛 Proof of Concept (PoC) *

  1. Create the following PoC file:
// poc.js
const y18n = require('y18n')();
var obj = {}
console.log("Before : " + obj.polluted);
y18n.setLocale('__proto__');
y18n.updateLocale({polluted: 'Yes! Its Polluted'});
console.log("After : " + {}.polluted);
  1. Execute the following commands in another terminal:
npm i y18n # 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-18 13-05-46

🔥 Proof of Fix (PoF) *

After fix execution will block prototype pollution and throw an exception

y18nPOF

👍 User Acceptance Testing (UAT)

After fix functionality is unafected

@huntr-helper
Copy link

Congratulations alromh87 - 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