How do you control, manage and run untrusted third-party code in a hosted service?

Let's say I run a hosted service that wants to allow plugins written by third-party clients.

Perhaps a gaming service provider that provides infrastructure, but allows customers to develop their own game referees. Or a coding competition site that allows coders to send code to run as a solution to any coding problem.

How would you solidify / block / isolate this user code from potential harm to the server that intends to run it?

How would you track and limit the use of resources (mainly CPU, memory)?

This is a good start for Python, but I wonder if anyone has more experience that they can use regardless of language (Python, Lua, Ruby, etc.).

+3
source share
5 answers

Lua has the best sandbox and watch I've seen so far. My host language is Python. So I decided to go with Lunatic Python .

0
source

RestrictedPython (shown in the link provided) looks promising. I can’t say that I really tried to do this.

, , Linux , . , , , . , VM, , ( ).

2 . Python.

+2

, 100% , chroot'ing - . , chroot'd . script ( - oops!), infiltrater script, .

python, Python.

+1

, :

  • , import .

  • _import_ reload.

  • API , , WSGI, . API- . , .

0

FWIW, Apache/mod_wsgi 3.0 chroot.

, , .

If you also want users to not interfere with other users' code, and there may be an arbitrary number of users that can dynamically change, this is more complicated, although Apache / mod_wsgi does not yet have a function for dynamic groups of daemon processes and instead relies on a static configuration.

0
source

Source: https://habr.com/ru/post/1707219/


All Articles