I am designing a online programming website similar to https://repl.it. Users can execute shell and python scripts on the browsers.

If users execute malicious commands including but not limited to "reboot" etc, then our system are damaged.

I understand the easiest way is to leverage Linux user control system. But I do not think this is the most secure way. What are more secure options for building such sites?

Suppose I have 10,000 users and they will perform computing-intensive tasks. I am using AWS.

  • 3
    Well this seems like a too broad question because there are numerous ways of doing this. The first thing that comes to mind is to create a virtual machine where users can perform these actions. The advantage is that if the VM is attacked, the users are attacking themselves, thus preventing the main website from being tampered with. The down side is that you need quite the machines in order to host a lot of virtual environments but depends on the amount of simultaneous users.
    – Jeroen
    Aug 20, 2019 at 9:08
  • 1
    Or containers, or chroot jails, or serverless heads. There are simply too many options.
    – schroeder
    Aug 20, 2019 at 9:22
  • I believe you are going to have to write your own interpreter or runtime for the languages you support.
    – user163495
    Aug 20, 2019 at 9:23
  • PyPy had a "proper" sandbox. AFAIK it's not been maintained in the last 5-6 years or so. You could start maintaining it and use PyPy's sandbox inside docker containers inside VMs to add a few layers of security... (so basically you spawn a VM to run, say, N scripts inside docker containers so you avoid having too many VMs. Sure if a user can break outside the PyPy sandbox and docker they might be an issue with the other few people running on the same VM but this is a trade off between costs and security like always). Aug 20, 2019 at 12:22
  • @Jeroen-ITNerdbox these days I'd probably try to run it in the generic "Functions" capabilities provided by AWS and other large hosting providers. They are kings of isolation. However, you still have to very much worry about SSRF, which can be dangerous in that kind of environment... but anyway... agree this is too broad. Aug 20, 2019 at 13:43


You must log in to answer this question.

Browse other questions tagged .