Agentic Security & Safety
How do you safely sandbox code execution tools for AI agents?
QUICK ANSWER
Sandbox code execution tools by running all interpreter processes inside isolated containers (like Docker or gVisor), restricting network access, setting CPU/memory resource limits, enforcing a read-only root filesystem where possible, and using short process timeout thresholds.
Sandbox Security Standards
Running code generated dynamically by LLMs requires securing host systems from damage or data leakage.
| Vector | Mitigation Action | Implementation Technique |
|---|---|---|
| Resource Exhaustion | Set resource limits | Limit runtime to 5s, memory to 256MB, CPU share to 0.5 |
| System Compromise | Containerization Isolation | Run inside a lightweight ephemeral Docker container or MicroVM (Firecracker) |
| Network Abuse | Network Restriction | Disable outbound traffic or restrict via firewall/iptables rules to trusted APIs |
| Persistent Mutex | Root Ephemerality | Mount the container root filesystem as read-only, allowing writes only to a temporary directory |
Verified against: Docker Sandbox Container Guidelines