Safely sandbox and execute user submitted JavaScript?

后端 未结 5 1601
别跟我提以往
别跟我提以往 2020-11-30 00:52

I would like to have the ability to let users submit arbitrary JavaScript code, which is then sent to a Node.JS server and safely executed before the output is sent back to

5条回答
  •  再見小時候
    2020-11-30 01:03

    Under Node.js you may create a sandboxed child process, but you also need to append the code with "use strict";, otherwise it is possible to break the sandbox with arguments.callee.caller.

    Not sure why you need to send it to the server, because the code may also be executed in a sandboxed web-worker.

    Also take a look at my Jailed library which simplifies everything just mentioned for both Node.js and web-browser, and additionally provides an opportunity to export a set of functions into the sandbox.

提交回复
热议问题