diff --git a/test/saferEval.js b/test/saferEval.spec.js similarity index 97% rename from test/saferEval.js rename to test/saferEval.spec.js index 1c6f45e..1dae58c 100644 --- a/test/saferEval.js +++ b/test/saferEval.spec.js @@ -270,6 +270,14 @@ describe('#saferEval', function () { } assert.strictEqual(res, undefined) }) + it('should prevent a breakout using Object.constructor', function () { + let res + try { + res = saferEval(`{}.constructor.constructor("return this.constructor.constructor('return this')()")().process.mainModule.require('child_process').execSync('pwd').toString()`) + } catch (e) { + } + assert.strictEqual(res, undefined) + }) }) describeBrowser('in browser', function () {