Skip to content

Instantly share code, notes, and snippets.

View mavdol's full-sized avatar

Mohamed Diallo mavdol

View GitHub Profile
@mavdol
mavdol / sandboxing_untrusted_python.md
Created January 2, 2026 11:22
Notes on sandboxing untrusted code - why Python can't be sandboxed, comparing Firecracker/gVisor/WASM approaches

Sandboxing Untrusted Python

Python doesn't have a built-in way to run untrusted code safely. Multiple attempts have been made, but none really succeeded.

Why? Because Python is a highly introspective object-oriented language with a mutable runtime. Core elements of the interpreter can be accessed through the object graph, frames and tracebacks, making runtime isolation difficult. This means that even aggressive restrictions can be bypassed:

# Attempt: Remove dangerous built-ins
del __builtins__.eval