Skip to content

Sandbox review (Code node, T30 as deployed by T53)

The transform node runs the user's Python in Pyodide on Deno (src/extractit/nodes/code). This review runs an escape battery against it and records what held.

What was run

tests/sandbox/test_sandbox_escape_battery.py (marker security_sandbox, make security-sandbox), profile deno on macOS with the pinned Deno and Pyodide bundle. Every case starts from user code that already got the real __import__ back through object.__subclasses__() (the import hook is defense in depth, not the boundary, T30) and then tries one thing:

Group Cases Result
Network (fetch, listen, connect, WebSocket, DNS, remote import(), Python sockets and urllib) 11 refused (NotCapable / PermissionDenied, or no such API); a listening server of the host saw 0 connections
Host files (read, list, write, create, mkdir, remove, chmod, symlink, realpath, stat, file:// import, /proc/self/environ) 12 refused; a sentinel file of the host is invisible through Python's virtual filesystem
Environment, subprocesses, FFI 6 refused; the host environment is not visible to Python (sentinel)
System information (hostname, OS release, interfaces, memory, load) 5 refused
Permission escalation (Deno.permissions.request, query, Function constructor, Deno.kill) 5 requests answered denied; nothing granted
Dedicated cases (cwd, os.system, Worker) 3 see the findings

39 cases refused as expected, 3 dedicated cases (42 attempts) and 3 side-channel checks (host server, host file, host environment), with no Deno process left behind after any of them (an autouse fixture checks it on every test).

Findings

Id Severity What State
SEC-010 info Deno.cwd() answers. It names only the throw-away directory of the run (dx-sbx-…), never the project; the test asserts it. accepted, owner T30
SEC-011 info os.system(...) does not raise inside Pyodide: it crashes the runner and the run ends SANDBOX_UNAVAILABLE (fail closed; the command did not run). Creating a Worker hangs until the wall limit kills the run (SANDBOX_TIMEOUT). A worker inherits no permission. open (robustness: a clear error instead of a crash), owner T30

One case first looked like a miss and was a test artefact: fetch to port 9 is refused by the fetch specification (bad port), before Deno's permissions are asked; the battery uses a normal port.

Not covered

  • The deno+gvisor profile (container with runsc, --network none, read-only root) needs Linux and runsc. It was not run in T55. Its checks live in tests/nodes/code/test_sandbox_deno.py (DX_SANDBOX=deno+gvisor) and must be run on the production host.
  • Side channels (timing, shared CPU) and kernel-level escapes of the host Deno process.
  • Resource exhaustion beyond T30's own tests (memory, CPU, output, time).
  • Pentest by a person: see Pentest checklist.

Conclusion for H8

On the deno profile Pyodide on Deno held against every attempt of the battery: the boundary is Deno's permission model (no network, no host files, no environment, no subprocess, no FFI), not Python. See ADR-015.