Skip to content

Commit

Permalink
Security Fix for Prototype Pollution
Browse files Browse the repository at this point in the history
Fix prototype pollution when path components are not strings
  • Loading branch information
ready-research authored Aug 30, 2021
1 parent 010f017 commit 383b72d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const isUnsafeKey = key => {
};

const validateKey = key => {
if (typeof key !== 'string' && typeof key !== 'number') {
key = String(key)
}
if (isUnsafeKey(key)) {
throw new Error(`Cannot set unsafe key: "${key}"`);
}
Expand Down

0 comments on commit 383b72d

Please sign in to comment.