WBX Sandbox

Untrusted code

Run untrusted AI-generated code safely

Send the code to a WBX sandbox instead of running it on your server: each sandbox and each job gets its own Firecracker microVM with its own kernel, separate from other customers and from our network. Turn the network off, set short time limits, and every background job leaves an execution receipt.

The fences around the code

A separate machine

A fresh microVM for every sandbox and job, in its own network namespace and cgroup. Nothing is shared between two runs. WebAssembly jobs run in a restricted process instead – the receipt says which.

Network off or allowlisted

internet=False gives the code no network at all; an allowlist lets it reach only the hosts you name. Private networks, our infrastructure and outgoing e-mail are always blocked.

Limits

A timeout per command, a lifetime per sandbox, a small template (mini: 1 vCPU, 256 MB) and a price limit per job – an endless loop ends and cannot run up your bill.

A receipt for every job

What ran, the template build, checksums of inputs and outputs, measured resources and cost – signed by WBX on request. An audit trail, not a proof that nothing could be altered.

Three steps

  1. Install the SDKpip install wbxsandbox (or npm install wbxsandbox) and set WBXSANDBOX_API_KEY.
  2. Create a sandbox without networkA fresh sandbox per piece of code, with a lifetime of minutes. It is deleted when you are done.
  3. Run the code with a timeoutRead the exit code, output and whether it was stopped. For more safety, run it as an unprivileged user – see the guide.

Python – code that tries to reach the internet

from wbxsandbox import Sandbox

code = """import urllib.request
print(urllib.request.urlopen("https://example.com", timeout=5).status)"""

# fresh sandbox: no network, 2 minutes of lifetime, deleted when the block ends
with Sandbox.create(template="mini", timeout=120, internet=False) as sb:
    sb.files.write("/tmp/main.py", code)
    r = sb.run("python3 /tmp/main.py", timeout=10)   # killed after 10 seconds
    print(r.exit_code, r.timed_out)
    print(r.stderr.strip().splitlines()[-1])

Prints 1 False and a Python name-resolution error – the sandbox has no route to the internet.

Questions

How is one run separated from another?

Every sandbox and every job gets its own Firecracker microVM with its own kernel, in its own network namespace and cgroup. A new run starts from a clean template; nothing is shared with earlier runs.

Can the code reach the internet or my network?

Only if you let it. With internet=False it has no network; with an allowlist only the hosts you name. Private networks, our infrastructure, cloud metadata services and outgoing e-mail are always blocked.

What stops an endless loop?

The command timeout kills it and the result says timed_out. The sandbox lifetime and, for jobs, the price limit set an upper bound too.

Is the code root inside the sandbox?

Yes, commands run as root inside their own VM by default. Drop to an unprivileged user so the code cannot change your grading files or tools – the guide shows how.