This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
⚙️ Fix:
The fix is implemented by defining the input
Object
withObject.create(null)
. An Object created through this API won’t have any prototype attributes which preventPrototype Pollution Attacks
.❓ How:
The main
assocInM()
function has 3 parametersobj
,keys
, andvalue
. Theobj
parameter is the object being mutated in this function.The payload is however passed as an array to the
keys
parameter and the value to set inside the object to thevalue
parameter as per the PoC:These values (with the payload) is mutated in this function which causes prototype pollution, I used the
Object.create()
to define the object to not contain any prototypes before the mutations start.This fix is implemented with the help of this paper on Prototype Pollution:
🗒️ Prototype pollution attack in NodeJS application
From Mitigation Methods -> Object.create(null) (from the paper):
🗒️ Proof of Concept:
Place the below PoC in the root folder of the project as
poc.js
🔥 Steps to Reproduce:
❤️ After Fix Screenshot:
✌️ Fixed!