AI Sandbox Architecture
A five-layer architecture that runs untrusted code inside a hardened Linux sandbox — isolated, resource-capped and fully observable.
Four walls, one job each
- Namespacewhat it can see8 namespace types; PID, Network, Mount and UTS do the work here.
ps → host - Seccomp-BPFwhat it can ask the kernelA BPF filter checks every syscall before it runs.
ptrace() - Cgrouphow much it can useHard caps on CPU, memory, I/O and process count.
fork() ×∞ - Timeouthow long it can runA wall-clock limit kills runaway jobs.
while (true)
- Core components
- 5
- Isolation layers
- 4
- Namespace types (kernel 6.1)
- 8
- Lifecycle steps
- 6
- ALLOW read(3, buf, 4096)
- ALLOW write(1, "42\n", 3)
- DENY ptrace(PTRACE_ATTACH) → EPERM
- DENY mount("/") → EPERM
- LIMIT clone() → EAGAIN pids.max
- KILL memory.max → OOM
- KILL wall-clock → SIGKILL
Five layers, top to bottom
Only the fourth layer runs untrusted code. Select a layer to read what it does.
- L1Frontend UIUpload, launch, view results
- File upload
- Sandbox launch
- Result display
- L2DatabaseTemporary & result store
- Job (ID / Status)
- Results
- Logs
- L3Job ManagerDispatch · monitor · return
- Dispatch to nodes
- Monitor status
- Return results
- Store to Sandbox
- L4Sandbox ExecutorRuns untrusted code under four kernel-level controls
- Linux Namespace
- Seccomp-BPF
- Cgroups
- Timeout
- L5Monitoring & LogsObserve everything, touch nothing
- Live resource metrics
- Anomaly alerts
- Log query
Treat every workload as hostile, then make 'hostile' boring.
Learn it
Learning Paths by RoleWant to help build a system like this? Here's what each role learns — and to what depth.
- System Architect
- Backend / Platform Engineer
- Security Engineer
- DevOps / SRE
- Frontend Engineer