Search code examples
linuxsecurityvirtualizationsandbox

Secure way to run other people code (sandbox) on my server?


I want to make a web service that runs other people's code locally. Naturally, I want to limit their code's access to a certain "sandbox" directory, so that they won't be able to connect to other parts of my server (DB, main webserver, etc.)

What's the best way to do this?

Run VMware/Virtualbox:

  • + I guess it's as secure as it gets. Even if someone manage to "hack", they only hack the guest machine

  • + Can limit the CPU & memory the processes use

  • + Easy to set up - just create the VM

  • - Harder to "connect" the sandbox directory from the host to the guest

  • - Wasting extra memory and CPU for managing the VM

Run underprivileged user:

  • + Doesn't waste extra resources

  • + Sandbox directory is just a plain directory

  • ? Can't limit CPU and memory?

  • ? I don't know if it's secure enough

Any other way?

Server running Fedora Core 8, the "other" codes written in Java & C++


Solution

    1. Running under unprivileged user still allows a local attacker to exploit vulnerabilities to elevate privileges.
    2. Allowing to execute code in a VM can be insecure as well; the attacker can gain access to host system, as recent VMWare vulnerability report has shown.

    In my opinion, allowing running native code on your system in the first place is not a good idea from security point of view. Maybe you should reconsider allowing them to run native code, this will certainly reduce the risk.