Skip to content

Commit 75c8009

Browse files
committed
fix(security): harden sandbox against code execution bypass (GHSA-9p4w-fq8m-2hp7)
1 parent 4dc0f1f commit 75c8009

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nyariv/sandboxjs",
3-
"version": "0.8.26",
3+
"version": "0.8.27",
44
"description": "Javascript sandboxing library.",
55
"main": "dist/node/Sandbox.js",
66
"module": "./build/Sandbox.js",

src/executor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ addOps(LispType.Prop, (exec, done, ticks, a, b: string, obj, context, scope) =>
377377
throw new SandboxError(`Static method or property access not permitted: ${a.name}.${b}`);
378378
}
379379
}
380-
} else if (b !== 'constructor') {
380+
}
381+
382+
if (b !== 'constructor') {
381383
let prot = a;
382384
while ((prot = Object.getPrototypeOf(prot))) {
383385
if (prot.hasOwnProperty(b)) {

test/tests.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@
230230
"evalExpect": "error",
231231
"safeExpect": "/Method or property access not permitted/"
232232
},
233+
{
234+
"code": "(() => {}).__defineGetter__('a', () => 1 ) || 'ok'",
235+
"evalExpect": "error",
236+
"safeExpect": "/Method or property access not permitted/"
237+
},
238+
{
239+
"code": "({}).toString.__defineGetter__('a', () => 1 ) || 'ok'",
240+
"evalExpect": "error",
241+
"safeExpect": "/Method or property access not permitted/"
242+
},
233243
{
234244
"code": "!test2",
235245
"evalExpect": false,

0 commit comments

Comments
 (0)