I would like to execute user-submitted JS files safely in my own Node.js application. The user can submit multiple files which can be required and executed by their index.js file which is triggered from my node process.
I have looked into some sandboxing solutions but they either limit the required capabilities or end up breaking the sandbox once a file is "required".
I have looked into vm, vm2, eval etc.
I'd like to restrict access to global variables like process and also restrict access to certain node libraries.
vmdocs says "Thenode:vmmodule is not a security mechanism. Do not use it to run untrusted code." which you should abide.