1
Create one sandbox per task
Pick the smallest template that has what the code needs:
python for scripts, node for JavaScript. Set a short timeout so a forgotten sandbox is killed for you.2
Run, read, and clean up
run_untrusted.py
with block kills the sandbox on exit.3
Decide what it may reach
Sandboxes can reach the internet by default, minus private ranges and cloud metadata, which are always blocked. Turn egress off or allow only the hosts you name: Networking. Give API tokens through the credential vault so the code never sees them.