Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Mongodb is a web based console to try out Mongodb.

I have created something similar to try out nodejs. In nodejs I am accepting user input and then I am performing eval on that command. Given the power of nodejs , someone from web console can create a file, delete files on the system or could execute rm -rf.

I was wondering if it would be okay to run nodejs as a user called node. This user node will not have any privilege to write anything, create anything or update anything. The only access this user will have is read access.

Will that work or that is too much of risk? What is a good strategy to handle such a situation?

share|improve this question
Given that you're talking about rm -rf I assume you're talking about *nix here, not Windows? – Mark Henderson Apr 8 '10 at 21:46
Yes. I am running ubuntu karmic on a slice from slicehost. – user35340 Apr 9 '10 at 11:31

Running as a less privileged user can help. For an extra level of paranoia you could run the service within a minimal chroot jail, optionally within a loopback mounted disk image to limit disk space usage - the user cannot run programs or fill disk space if they cannot be accessed. Put exactly and only the files and free space they will need on that file system. They will not be able to access anything else. As an extra benefit you can just use a single cp command to either back up or restore the state of the image. Also consider using nice and ulimit to control usage of other resources.

share|improve this answer

Hrm, the problem is that if he has access to files he owns, users could probably just as easily set permissions to something editable. Remember, if you're giving users access to shell commands, you've already opened yourself up to a whole suite of problems. That's generally a bad idea.

Even if the user doesn't own any files and just existed to run your application, you're opening yourself up to things such as full temporary directories and mail spools.

Is there any way to run the V8 engine in a restricted environment? Disallow all IO? I'd personally look for a method such as that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.