Skip to content

Commit

Permalink
Security fix for Prototype Pollution (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: arjunshibu <[email protected]>
Co-authored-by: Jamie Slome <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2021
1 parent d028a1b commit 9619863
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function set (obj, path, value) {
obj[path[i]] = value
else if(null == obj[path[i]])
obj = (obj[path[i]] = isNonNegativeInteger(path[i+1]) ? [] : {})
else
else if (!(isPrototypePolluted(path[i])))
obj = obj[path[i]]
return value
}
Expand Down Expand Up @@ -91,6 +91,10 @@ function clone (obj) {
return _obj
}

function isPrototypePolluted(key) {
return ['__proto__', 'constructor', 'prototype'].includes(key)
}

exports.get = get
exports.set = set
exports.each = each
Expand Down

0 comments on commit 9619863

Please sign in to comment.