An isolated, secure code execution runtime and REST API designed to safely run untrusted, LLM-generated code. It enforces multi-layered host isolation using Linux cgroups v2, network air-gapping, read-only root filesystems, and watchdog deadline terminations.
| Attack Vector | Security Mechanism | Enforcement Layer |
|---|---|---|
| Out-of-Memory DOS | cgroups v2 Memory Ceiling | Enforces mem_limit with swap disabled (memswap_limit = mem_limit). Kernel terminates breach via SIGKILL (exit code 137). |
| CPU Starvation | CFS Bandwidth Quota | Bounds CPU compute via nano_cpus scheduling quotas. |
| Fork Bombs | Kernel PID Limits | Constrains active process tree to pids_limit=32. |
| Data Exfiltration | Network Air-Gapping | Dedicated Network Namespace with network_mode="none". |
| Filesystem Tampering | Read-Only Root & Scratch tmpfs | Mounts container root as read_only=True with an unprivileged /workspace tmpfs (noexec,nosuid). |
| Privilege Escalation | Capability Dropping & Non-Root UID | Strips all Linux capabilities (cap_drop=["ALL"]) and drops process privileges to UID 1000. |
| Process Hangs | Watchdog Deadline Reaper | Supervisor enforces wall-clock timeouts, killing stalled processes. |
Client / Autonomous Agent (FastAPI / HTTP)
│
(ExecutionRequest)
▼
[ Sandbox Supervisor ]
│
┌───────────────┴───────────────┐
▼ ▼
[ Resource Constraints (cgroups) ] [ Namespace Isolation ]
• memory.max (e.g., 64MB) • CLONE_NEWNET (network: none)
• cpu.max (e.g., 0.5 CPU) • Read-Only RootFS
• pids.max (32 processes) • cap_drop: ALL (UID 1000)
│
▼
[ Isolated Alpine Runner Container ]
docker build -t sandbox-runner:latest -f Dockerfile.runner .pip install -r requirements.txtpytest -v tests/uvicorn executor.server:app --host 0.0.0.0 --port 8000 --reloadExecutes arbitrary Python code inside an isolated container with hard resource constraints.
{
"code": "import platform; print(platform.python_version())",
"timeout_seconds": 3,
"memory_limit_mb": 64,
"cpu_limit": 0.5,
"allow_network": false
}{
"status": "success",
"stdout": "3.11.16\n",
"stderr": "",
"exit_code": 0,
"execution_time_ms": 384.21,
"memory_used_mb": null
}success: Script finished cleanly with exit code0.timeout: Process exceededtimeout_secondsand was killed (exit_code: 124).memory_exceeded: Script exceeded memory ceiling and was killed by Linux OOM killer (exit_code: 137).error: Script encountered runtime exceptions or non-zero exit codes.
To run the built-in LLM tool-calling simulation:
python -m examples.agent_tool_example