Sandbox is a node module, which according to README;
- Can be used to execute untrusted code.
- Timeout support (e.g. preventing infinite loops)
- Limited code (cannot access node.js methods)
The stopping problem , as @maerics wrote about , can be solved by setting a timeout for the code, although you cannot do this in the same process, because, for example, while(1) block it. The sandbox solves this problem using a child process.
Therefore, the variable problem must also be resolved because Sandbox is in the child process, and not in the main process.
As mentioned earlier, if possible, you should avoid users from running arbitrary code on your server, as it carries a huge security risk. Even through the module, these restrictions you must run at least child processes with the most unacceptable user.
source share