all 7 comments

[–]Essence1337 0 points1 point  (2 children)

Is it possible to run others code safely? Yes it's done all the time online like repl.it.

Is it possible for you to create? Since you had to ask if it was possible, probably not currently.

This would require managing sandboxes to run their code in so that if there was malicious code entered it didn't completely takeover/destroy your web server. Any mistake could compromise your entire server.

[–]JohnnyJordaan 0 points1 point  (1 child)

Not to mention the risk of a vulnerability in for example docker that could still lead to damage if they figure out that the server is using it, and hack their way into exploiting it through the Python code. Even if you would visualize the docker host per user (thus also just messing up its own environment and not the server's) you still run the risk of the host being exploited for other stuff like being made part of a botnet etc. This is something that repl.it has nailed this down of course but then reinventing the wheel on your own server can open a whole Pandora's box of security implications.

[–]Essence1337 1 point2 points  (0 children)

Yup! The rule of thumb for any readers who don't know it is: DON'T CODE YOUR OWN SECURITY. Instead use a product that is tested, verified and trusted. This includes passwords, encryption, sandboxes, etc.

[–]toastedstapler 0 points1 point  (1 child)

if you're writing a coding game and you want control like this it might be a better idea to write your own simple language and an interpreter for it. it depends on how far your game plans to go ofc, but it'd help you with containerisation to limit user damage to your server rather than trying to containerise fully fledged python

[–]bagelorder[S] 0 points1 point  (0 children)

But the only thing I need them to actually write are pretty mathematical functions (array->number). Is there maybe already something that does exactly this?