Skip to content

Commit

Permalink
fix: disallow usage of Object.constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
commenthol committed Mar 9, 2019
1 parent 74e5bb8 commit 1c29f6a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ class SaferEval {
if (typeof code !== 'string') {
throw new TypeError('not a string')
}
let src = 'Object.constructor = function () {};\n'
src += 'return ' + code + ';\n'

return vm.runInContext(
'(function () {"use strict"; return ' + code + '})()',
'(function () {"use strict"; ' + src + '})()',
this._context,
this._options
)
Expand Down

0 comments on commit 1c29f6a

Please sign in to comment.