-
Notifications
You must be signed in to change notification settings - Fork 2
Security fix for prototype pollution in js-ini #1
Conversation
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.
LGTM!
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.
The fix
is applied to the line 75
which is enclosed in a if
statement.
However, in line 89
there's another dangerous
line which could lead to prototype pollution
in case the first condition isn't respected but the 2' yep.
I would suggest adding a check before the various if clauses
in order to avoid this kind of problems 😄
If I missed something or you think I'm not correct please let me know it 👍
Cheers,
Mik
@Mik317 I assume you are refering to the if (currentSection !== '') {
(<IIniObjectSection>result[currentSection])[name] = val;
} else {
result[name] = val;
} The setting of property is done in the []
polluted = "Yes! Its Polluted" In that case, I have improved the fix by using function to make the code cleaner. |
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.
LGTM 😄 🍰
@arjunshibu thanks for the explanation 👍
I was thinking about the possibility to use just the polluted = 'string'
line to create an array as value and set the name of that property to __proto__
which theorically would have worked but actually can't do it since IDK the INI syntax lol (I worked on it for a hour then I just checked if it was possible array transformation
and it doesn't seem)
Cheers,
Mik
Congratulations arjunshibu - your fix has been selected! 🎉 Thanks for being part of the community & helping secure the world's open source code. |
📊 Metadata *
js-ini
is vulnerable toPrototype Pollution
.Bounty URL: https://www.huntr.dev/bounties/1-npm-js-ini
⚙️ 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
andprototype
. 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 *
Prototype pollution if fixed by not allowing to modify object prototype.
🐛 Proof of Concept (PoC)
🔥 Proof of Fix (PoF) *
Prototype pollution is fixed as seen below.
👍 User Acceptance Testing (UAT)