Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable NodeJs internal Modules?

I am in the process of evaluating the use of NodeJs for a shared programming platform.

Users should be able to submit code and run it on the server. To give them the best fundamentals, several NodeJs Modules should be provided.

For security reasons the processes should be chrooted to forbid access to system resources.

The best approach seems to be the use of child_processes, especially the fork() function.

For further security also some NodeJs Modules should be disabled, like launching additional child processes.

How can I disable these modules for a child? I can't even seem to find compile options to disable some by default,

like image 286
favo Avatar asked Jan 31 '26 11:01

favo


1 Answers

Basically, what you are looking for is running untrusted code within a trusted environment. The key here is sandboxing, I guess.

Please note that there are various solutions out there for creating and managing sandboxes in Node.js, among others:

  • gf3/sandbox, which is A nifty javascript sandbox for node.js
  • hflw/node-sandbox, which is an Advanced sandboxing library that allows communication between the sandbox and the parent process.

I do not have any practical experience with either of them, but I guess that's a step into the right direction for you. Maybe you would like to share your experiences with them here? I think this would be awesome :-)

Hope this helps.

like image 179
Golo Roden Avatar answered Feb 02 '26 15:02

Golo Roden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!