Skip to content

Commit b70aa71

Browse files
committed
fix(security): prevent constructor access in safe vm
Also: - docs: add security policy file
1 parent 763ada0 commit b70aa71

14 files changed

+54
-6
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ labels: Bug - unconfirmed
66
---
77
<!--
88
**PLEASE NOTE: This project is not currently being very actively developed.**
9+
10+
**ALSO: If wishing to report a security bug, please read SECURITY.md**
911
-->
1012

1113
## Describe the bug

CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGES for jsonpath-plus
22

3+
## 10.0.7
4+
5+
- fix(security): prevent `constructor` access
6+
- docs: add security policy file
7+
38
## 10.0.6
49

510
- fix(security): prevent `call`/`apply` invocation of `Function`

SECURITY.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Security Policy
2+
3+
## Reporting a Vulnerability
4+
5+
**Please do not report security vulnerabilities through public GitHub issues.**
6+
7+
If you believe you’ve found a security vulnerability, please send it to us by emailing [[email protected]](mailto:[email protected]). Please include the following details with your report:
8+
9+
1. Description of the location and potential impact of the vulnerability
10+
11+
2. A detailed description of the steps required to reproduce the vulnerability (POC scripts, etc.).
12+
13+
3. How you would like to be credited.
14+
15+
We will evaluate the vulnerability and, if necessary, release a fix or unertake mitigating steps to address it. We will contact you to let you know the outcome, and will credit you in the report.
16+
17+
Please **do not disclose the vulnerability publicly** until we have sufficient time to release a fix.
18+
19+
Once we have either a) published a fix, b) declined to address the vulnerability for whatever reason, or c) taken more than 30 days to reply, we welcome you to publicly report the vulnerability on our tracker and disclose it publicly. If you intend to
20+
disclose sooner regardless of our requested policy, please at least indicate to us when you plan to disclose.

badges/coverage-badge.svg

+1-1
Loading

dist/index-browser-esm.js

+3
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,9 @@ const SafeEval = {
12911291
return ast.value;
12921292
},
12931293
evalMemberExpression(ast, subs) {
1294+
if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') {
1295+
throw new Error("'constructor' property is disabled");
1296+
}
12941297
const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]`
12951298
: ast.property.name; // `object.property` property is Identifier
12961299
const obj = SafeEval.evalAst(ast.object, subs);

dist/index-browser-esm.min.js

+1-1
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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-browser-umd.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,9 @@
12971297
return ast.value;
12981298
},
12991299
evalMemberExpression(ast, subs) {
1300+
if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') {
1301+
throw new Error("'constructor' property is disabled");
1302+
}
13001303
const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]`
13011304
: ast.property.name; // `object.property` property is Identifier
13021305
const obj = SafeEval.evalAst(ast.object, subs);

dist/index-browser-umd.min.cjs

+1-1
Large diffs are not rendered by default.

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

+1-1
Large diffs are not rendered by default.

dist/index-node-cjs.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,9 @@ const SafeEval = {
12921292
return ast.value;
12931293
},
12941294
evalMemberExpression(ast, subs) {
1295+
if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') {
1296+
throw new Error("'constructor' property is disabled");
1297+
}
12951298
const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]`
12961299
: ast.property.name; // `object.property` property is Identifier
12971300
const obj = SafeEval.evalAst(ast.object, subs);

dist/index-node-esm.js

+3
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,9 @@ const SafeEval = {
12901290
return ast.value;
12911291
},
12921292
evalMemberExpression(ast, subs) {
1293+
if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') {
1294+
throw new Error("'constructor' property is disabled");
1295+
}
12931296
const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]`
12941297
: ast.property.name; // `object.property` property is Identifier
12951298
const obj = SafeEval.evalAst(ast.object, subs);

package.json

+1-1
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.6",
4+
"version": "10.0.7",
55
"type": "module",
66
"bin": {
77
"jsonpath": "./bin/jsonpath-cli.js",

src/Safe-Script.js

+9
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ const SafeEval = {
105105
return ast.value;
106106
},
107107
evalMemberExpression (ast, subs) {
108+
if (
109+
(ast.property.type === 'Identifier' &&
110+
ast.property.name === 'constructor') ||
111+
(ast.object.type === 'Identifier' &&
112+
ast.object.name === 'constructor')
113+
) {
114+
throw new Error("'constructor' property is disabled");
115+
}
116+
108117
const prop = ast.computed
109118
? SafeEval.evalAst(ast.property) // `object[property]`
110119
: ast.property.name; // `object.property` property is Identifier

0 commit comments

Comments
 (0)