-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
@jquense - one of our users has proposed this fix. We could either throw an exception here or we could skip the iteration, what are your thoughts? Cheers! 🍰 |
@d3v53c - an alternative fix could be to Thoughts? 🍰 |
Yeah, I agree. |
@d3v53c - also, I think we would only need to skip the proto key as this affects the global scope which in this instance could have the significant impact, perhaps we only run the if statement on |
@d3v53c - also, can we implement a unit test in Then we are good to merge! Cheers! 🍰 |
Keeping the check for '__ proto __' and 'proto' as per @JamieSlome . Added a unit test for the poc provided. Please let me know if I'm missing anything and have a look on the unit test case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you review the requested changes?
Cheers! 🍰
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commited the changes.
Note that the actual test suite is broken on this project, so your test won't run if you do |
See #2 for an alternative fix that also fixes the entire test suite. |
Sorry d3v53c, 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! 🔨😎 |
📊 Metadata *
Please enter the direct URL for this bounty on huntr.dev. This is compulsory and will help us process your bounty submission quicker.
Bounty URL: https://www.huntr.dev/bounties/1-npm-yup
⚙️ 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) *
// poc.js
let yup = require('yup');
const payload = JSON.parse('{"proto":{"polluted":"Yes! Its Polluted"}}');
yup.setLocale(payload);
console.log({}.polluted)
🔥 Proof of Fix (PoF) *
Before:
After:
👍 User Acceptance Testing (UAT)
After fix functionality is unaffected