Skip to content

Commit

Permalink
Fix prototype pollution
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshino-s committed Mar 26, 2021
1 parent a556e27 commit 6c475a1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export default function evaluate(tokens, expr, values) {
nstack.push(f(resolveExpression(n1, values), resolveExpression(n2, values), resolveExpression(n3, values)));
}
} else if (type === IVAR) {
if (/^__proto__|prototype|constructor$/.test(item.value)) {
throw new Error('prototype access detected');
}
if (item.value in expr.functions) {
nstack.push(expr.functions[item.value]);
} else if (item.value in expr.unaryOps && expr.parser.isOperatorEnabled(item.value)) {
Expand Down

0 comments on commit 6c475a1

Please sign in to comment.