Skip to content

Commit 2be3354

Browse files
committedOct 10, 2020
Fix prototype pollution in set()
1 parent 404223b commit 2be3354

File tree

2 files changed

+765
-719
lines changed

2 files changed

+765
-719
lines changed
 

‎index.js

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@
112112
}
113113
var currentPath = path[0];
114114
var currentValue = getShallowProperty(obj, currentPath);
115+
if (options.includeInheritedProps && (currentPath === '__proto__' ||
116+
(currentPath === 'constructor' && typeof currentValue === 'function'))) {
117+
throw new Error('For security reasons, object\'s magic properties cannot be set')
118+
}
115119
if (path.length === 1) {
116120
if (currentValue === void 0 || !doNotReplace) {
117121
obj[currentPath] = value;

‎test.js

+761-719
Large diffs are not rendered by default.

1 commit comments

Comments
 (1)

guptshruti2003 commented on Dec 29, 2020

@guptshruti2003

Hello how can I solve this in my folder ? it shows high vulnerability error

thanks

Please sign in to comment.