InterviewHubPRO
Section Overview
Q30

Question 30 of 50

Part 3: Agentic Workflows, Function Calling & MCP

60%
AI Engineering & LLMs (50 Qs)•Part 3: Agentic Workflows, Function Calling & MCP

Code Execution Sandboxes for Coding Agents: gVisor, Firecracker & Docker Isolation

1. The Danger of Local Code Execution

Coding agents (Claude Engineer, SWE-bench agents, OpenCodeInterpreter) routinely generate and execute shell commands and Python code. Executing untrusted LLM-generated code directly on host servers or developer laptops is a critical security vulnerability:

  • Malicious prompt injections can execute rm -rf /, exfiltrate ~/.ssh/id_rsa keys, or install cryptominers.
  • Accidental bugs can launch local fork-bombs or saturate network ports.

2. Isolation Technologies Comparison

TechnologyStartup LatencyIsolation BoundaryResource OverheadProduction Example
Standard Docker Container~1 secondShared Linux Kernel (namespaces/cgroups)Very LowVulnerable to kernel privilege escalation CVEs
gVisor (Google)~100–200 msUser-space virtualized kernel intercepting syscallsLowGoogle Cloud Run, production agent code runners
Firecracker MicroVMs (AWS)~5–20 msHardware-level KVM virtualization per sandboxExtremely LowAWS Lambda, Modal, Fly.io
WebAssembly (WASM)< 1 msMemory-safe bytecode runtimeMinimalClient-side or edge compute (limited language support)

3. Production MicroVM Sandbox Architecture

vbnet
   Agent Host (Untrusted LLM Output)
             │
             ├── Sends code payload: "import os; os.system('cat /etc/passwd')"
             │
             ▼
   [ Firecracker MicroVM / gVisor Sandbox ]
   ┌────────────────────────────────────────────────────────┐
   │ • Ephemeral Guest Kernel (KVM / Isolated System Calls) │
   │ • Network: Egress blocked to internal 10.0.0.0/8 VPC   │
   │ • Filesystem: Copy-on-Write tmpfs (destroyed on exit)  │
   │ • CPU / RAM Quotas: Max 1 Core, 512 MB                 │
   │ • Wall-Clock Timeout: 5.0 seconds                      │
   └────────────────────────────────────────────────────────┘
             │
             ▼
      Returns stdout/stderr safely to Agent without host exposure