I have a snippet of python that does an exec
on user-provided python:
import sys
import traceback
def foo():
print("jailbreak!")
c_globals = {}
c_locals = {}
try:
exec(compile(open("core.py", "rb").read(), "core.py", 'exec'), c_globals, c_locals)
c_locals["update"]()
except Exception:
print(traceback.format_exc(2))
Is it possible for the user-provided python to trivially "jailbreak" or crash the calling code? I'm aware that the user code can call exit
, but other than that, what are some ways the user could misbehave?
I perused this question but the answers seem somewhat old.
To be clear: I'm not looking for a bulletproof sandbox. I'm looking for ways users might shoot themselves in the foot so I can prevent them from doing so. This is for a "run at your own risk" computer game I'm making.
See: https://repl.it/repls/MistyConventionalControlflowgraph