Secure way to run other people code (sandbox) on m

2019-01-08 19:01发布

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

Whats the best way to do it?

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 process uses

(+) easy to setup.. 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:

(+) doesnt waste extra resources

(+) sandbox directory is just a plain directory

(?) cant limit cpu and memory?

(?) dont know if it's secure enough...

Any other way?

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

9条回答
家丑人穷心不美
2楼-- · 2019-01-08 19:15

Not sure about how much effort you want to put into this thing but could you run Xen like the VPS web hosts out there?

http://www.xen.org/

This would allow full root access on their little piece of the server without compromising the other users or the base system.

查看更多
smile是对你的礼貌
3楼-- · 2019-01-08 19:20

try using lxc as a container for your apache server

查看更多
手持菜刀,她持情操
4楼-- · 2019-01-08 19:21

Use Ideone API - the simplest way.

查看更多
放我归山
5楼-- · 2019-01-08 19:23

Try learning a little about setting up policies for SELinux. If you're running a Red Hat box, you're good to go since they package it into the default distro.

This will be useful if you know the things to which the code should not have access. Or you can do the opposite, and only grant access to certain things.

However, those policies are complicated, and may require more investment in time than you may wish to put forth.

查看更多
姐就是有狂的资本
6楼-- · 2019-01-08 19:28

Check out ulimit and friends for ways of limiting the underprivileged user's ability to DOS the machine.

查看更多
戒情不戒烟
7楼-- · 2019-01-08 19:29
  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.

查看更多
登录 后发表回答