Skip to content

Commit 98a6b22

Browse files
committed
fix: remove overly aggressive disabling of native functions but disallow __proto__
1 parent 30194c7 commit 98a6b22

12 files changed

+26
-21
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGES for jsonpath-plus
22

3+
## 10.0.5
4+
5+
- fix: remove overly aggressive disabling of native functions but
6+
disallow `__proto__`
7+
38
## 10.0.4
49

510
- fix(security): further prevent binding of Function calls which may evade detection

badges/coverage-badge.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index-browser-esm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,16 +1325,16 @@ const SafeEval = {
13251325
if (func === Function) {
13261326
throw new Error('Function constructor is disabled');
13271327
}
1328-
if (func.toString() === 'function () { [native code] }') {
1329-
throw new Error('Native functions are disabled');
1330-
}
13311328
return func(...args);
13321329
},
13331330
evalAssignmentExpression(ast, subs) {
13341331
if (ast.left.type !== 'Identifier') {
13351332
throw SyntaxError('Invalid left-hand side in assignment');
13361333
}
13371334
const id = ast.left.name;
1335+
if (id === '__proto__') {
1336+
throw new Error('Assignment to __proto__ is disabled');
1337+
}
13381338
const value = SafeEval.evalAst(ast.right, subs);
13391339
subs[id] = value;
13401340
return subs[id];

dist/index-browser-esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-browser-esm.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-browser-umd.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,16 +1331,16 @@
13311331
if (func === Function) {
13321332
throw new Error('Function constructor is disabled');
13331333
}
1334-
if (func.toString() === 'function () { [native code] }') {
1335-
throw new Error('Native functions are disabled');
1336-
}
13371334
return func(...args);
13381335
},
13391336
evalAssignmentExpression(ast, subs) {
13401337
if (ast.left.type !== 'Identifier') {
13411338
throw SyntaxError('Invalid left-hand side in assignment');
13421339
}
13431340
const id = ast.left.name;
1341+
if (id === '__proto__') {
1342+
throw new Error('Assignment to __proto__ is disabled');
1343+
}
13441344
const value = SafeEval.evalAst(ast.right, subs);
13451345
subs[id] = value;
13461346
return subs[id];

dist/index-browser-umd.min.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/index-browser-umd.min.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-node-cjs.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,16 +1326,16 @@ const SafeEval = {
13261326
if (func === Function) {
13271327
throw new Error('Function constructor is disabled');
13281328
}
1329-
if (func.toString() === 'function () { [native code] }') {
1330-
throw new Error('Native functions are disabled');
1331-
}
13321329
return func(...args);
13331330
},
13341331
evalAssignmentExpression(ast, subs) {
13351332
if (ast.left.type !== 'Identifier') {
13361333
throw SyntaxError('Invalid left-hand side in assignment');
13371334
}
13381335
const id = ast.left.name;
1336+
if (id === '__proto__') {
1337+
throw new Error('Assignment to __proto__ is disabled');
1338+
}
13391339
const value = SafeEval.evalAst(ast.right, subs);
13401340
subs[id] = value;
13411341
return subs[id];

dist/index-node-esm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,16 +1324,16 @@ const SafeEval = {
13241324
if (func === Function) {
13251325
throw new Error('Function constructor is disabled');
13261326
}
1327-
if (func.toString() === 'function () { [native code] }') {
1328-
throw new Error('Native functions are disabled');
1329-
}
13301327
return func(...args);
13311328
},
13321329
evalAssignmentExpression(ast, subs) {
13331330
if (ast.left.type !== 'Identifier') {
13341331
throw SyntaxError('Invalid left-hand side in assignment');
13351332
}
13361333
const id = ast.left.name;
1334+
if (id === '__proto__') {
1335+
throw new Error('Assignment to __proto__ is disabled');
1336+
}
13371337
const value = SafeEval.evalAst(ast.right, subs);
13381338
subs[id] = value;
13391339
return subs[id];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Stefan Goessner",
33
"name": "jsonpath-plus",
4-
"version": "10.0.4",
4+
"version": "10.0.5",
55
"type": "module",
66
"bin": {
77
"jsonpath": "./bin/jsonpath-cli.js",

src/Safe-Script.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,16 @@ const SafeEval = {
140140
if (func === Function) {
141141
throw new Error('Function constructor is disabled');
142142
}
143-
if (func.toString() === 'function () { [native code] }') {
144-
throw new Error('Native functions are disabled');
145-
}
146143
return func(...args);
147144
},
148145
evalAssignmentExpression (ast, subs) {
149146
if (ast.left.type !== 'Identifier') {
150147
throw SyntaxError('Invalid left-hand side in assignment');
151148
}
152149
const id = ast.left.name;
150+
if (id === '__proto__') {
151+
throw new Error('Assignment to __proto__ is disabled');
152+
}
153153
const value = SafeEval.evalAst(ast.right, subs);
154154
subs[id] = value;
155155
return subs[id];

0 commit comments

Comments
 (0)