Skip to content

Commit 9619863

Browse files
huntr-helperarjunshibuJamieSlome
authored
Security fix for Prototype Pollution (#5)
Co-authored-by: arjunshibu <arjunshibu1999@gmail.com> Co-authored-by: Jamie Slome <jamie@418sec.com>
1 parent d028a1b commit 9619863

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function set (obj, path, value) {
2727
obj[path[i]] = value
2828
else if(null == obj[path[i]])
2929
obj = (obj[path[i]] = isNonNegativeInteger(path[i+1]) ? [] : {})
30-
else
30+
else if (!(isPrototypePolluted(path[i])))
3131
obj = obj[path[i]]
3232
return value
3333
}
@@ -91,6 +91,10 @@ function clone (obj) {
9191
return _obj
9292
}
9393

94+
function isPrototypePolluted(key) {
95+
return ['__proto__', 'constructor', 'prototype'].includes(key)
96+
}
97+
9498
exports.get = get
9599
exports.set = set
96100
exports.each = each

0 commit comments

Comments
 (0)