I was going through this commit in @n8n/vm2
which restricts the use of Proxy
inside the sandbox:
As expected, when I run the following code in a standalone script using @n8n/vm2
, it throws an error:
const { NodeVM } = require('@n8n/vm2');
const vm = new NodeVM({
sandbox: { },
require: false,
});
const script = `
const obj = new Proxy({}, {
get(target, prop) {
return 'hello';
}
});
module.exports = obj.test;
`;
console.log(vm.run(script));
Error
TypeError [Error]: Proxy is not a constructor
However, when I use the same logic in an n8n Code node, the workflow executes successfully:
const obj = new Proxy({}, {
get(target, prop) {
return 'hello';
}
});
return $input.all();
So I’m a bit puzzled—if Proxy
is supposed to be blocked as per that commit, how is it still allowed within the Code node?
Is there some custom configuration or pre-processing n8n does internally to expose or allow Proxy
inside the Code node context?
Information on your n8n setup
- n8n version: 1.88.0
- Database (default: SQLite): default
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): npm
- Operating system: Mac OS 14.5
- n8n/vm2 version: 3.9.25