- Version: >= 8.3
- Platform: MacOS
- Subsystem: vm
Hi,
With node version 8.3.0 and above the vm container does not prevent usage of built-in modules as "console". It is easy to reproduce with the following code:
const vm = require('vm');
const sandbox = vm.createContext({});
vm.runInContext('console.log("Hi")', sandbox);
When executed with node version < 8.3 we get the following error (which is correct):
evalmachine.<anonymous>:1
console.log("Hi")
^
ReferenceError: console is not defined
at evalmachine.<anonymous>:1:1
at ContextifyScript.Script.runInContext (vm.js:53:29)
at Object.runInContext (vm.js:108:6)
at Object.<anonymous> (/Users/development/workspace/vmbug.js:4:4)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
When using node version >= 8.3.0 the code executes without error.
It seems to be related to the introduction of the V8 version 6.
Best regards,
Hristo Dobtchev
Hi,
With node version 8.3.0 and above the vm container does not prevent usage of built-in modules as "console". It is easy to reproduce with the following code:
When executed with node version < 8.3 we get the following error (which is correct):
When using node version >= 8.3.0 the code executes without error.
It seems to be related to the introduction of the V8 version 6.
Best regards,
Hristo Dobtchev