Skip to content

Commit 383b72d

Browse files
Security Fix for Prototype Pollution
Fix prototype pollution when path components are not strings
1 parent 010f017 commit 383b72d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

index.js

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const isUnsafeKey = key => {
1818
};
1919

2020
const validateKey = key => {
21+
if (typeof key !== 'string' && typeof key !== 'number') {
22+
key = String(key)
23+
}
2124
if (isUnsafeKey(key)) {
2225
throw new Error(`Cannot set unsafe key: "${key}"`);
2326
}

0 commit comments

Comments
 (0)