Skip to content

Commit 1c29f6a

Browse files
committed
fix: disallow usage of Object.constructor
1 parent 74e5bb8 commit 1c29f6a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ class SaferEval {
4040
if (typeof code !== 'string') {
4141
throw new TypeError('not a string')
4242
}
43+
let src = 'Object.constructor = function () {};\n'
44+
src += 'return ' + code + ';\n'
45+
4346
return vm.runInContext(
44-
'(function () {"use strict"; return ' + code + '})()',
47+
'(function () {"use strict"; ' + src + '})()',
4548
this._context,
4649
this._options
4750
)

0 commit comments

Comments
 (0)