AI Agent Sandboxing Runtime — Your Runtime Isolation Isn't Secure Enough. Here's the Fix.
Your runtime isolation isn't secure enough — a compromised agent broke through process isolation and exhausted host resources. The result: €2.1M in damages, your DevOps team was fired, customers are upset. Here's how to isolate your AI agents with runtime sandboxing.
What is Runtime Sandboxing? Simply Explained
Runtime sandboxing is like a quarantine box for running processes. Imagine you have a system that does tasks — execute code, use tools, read/write files. Runtime sandboxing ensures these tasks run in an isolated environment — process isolation, resource limits, network isolation, filesystem isolation. Without runtime sandboxing, a compromised agent could access your entire system and exhaust resources. The fundamentals are: process isolation (containerisation), resource limits (CPU/memory/disk), network isolation (firewall/policies), filesystem isolation (read-only mounts).
↓ Jump straight to the technical deep dive below
4 Runtime Controls — What Works in Production
Isolate agent processes from each other and from the host system. Use containerisation or process isolation to prevent cross-agent contamination.
# Moltbot agent process isolation:
process_isolation:
enabled: true
# Containerisation:
containerisation:
# Use Docker containers for each agent
# Each agent runs in its own container
enabled: true
# Container isolation:
# - User namespace isolation
# - PID namespace isolation
# - Network namespace isolation
# - Mount namespace isolation
namespaces:
- user
- pid
- network
- mount
# Seccomp profiles:
# Restrict system calls available to agent
# Only allow necessary syscalls for agent operation
seccomp:
enabled: true
profile: "agent-profile.json"
# Process hardening:
hardening:
# Drop privileges
# Run agent as non-root user
drop_privileges: true
user: "agent-user"
group: "agent-group"
# Enable security features:
# - ASLR (Address Space Layout Randomisation)
# - PIE (Position Independent Executable)
# - Stack canaries
security_features:
aslr: true
pie: true
stack_canary: trueLimit agent resource consumption to prevent resource exhaustion attacks. Set CPU, memory, and disk limits.
# Moltbot agent resource limits:
resource_limits:
enabled: true
# CPU limits:
cpu:
# Limit CPU usage per agent
cpu_quota: "0.5" # 50% of one CPU core
cpu_period: 100000 # 100ms period
# Memory limits:
memory:
# Limit memory usage per agent
memory_limit: "512m" # 512MB
memory_swap: "512m" # No swap
oom_kill_disable: false # Kill on OOM
# Disk limits:
disk:
# Limit disk usage per agent
disk_quota: "100m" # 100MB
inode_quota: 10000 # 10000 inodes
# File descriptor limits:
file_descriptors:
# Limit number of open file descriptors
nofile: 1024
# Process limits:
processes:
# Limit number of processes per agent
nproc: 64Isolate agent network access. Control which agents can access which endpoints. Use network policies and firewall rules.
# Moltbot agent network isolation:
network_isolation:
enabled: true
# Network policies:
policies:
# Default deny all egress traffic
default_policy: "deny"
# Allow specific egress traffic:
allowed_egress:
- destination: "api.openai.com"
ports: [443]
protocol: "https"
- destination: "api.anthropic.com"
ports: [443]
protocol: "https"
- destination: "internal-api.internal"
ports: [443, 8080]
protocol: "https"
# Firewall rules:
firewall:
# Use iptables or nftables to enforce network policies
enabled: true
rules:
- action: "deny"
destination: "0.0.0.0/0"
except_allowed: true
# DNS isolation:
dns:
# Use custom DNS resolver for agents
# Block access to malicious domains
custom_resolver: "10.0.0.53"
block_malicious: trueIsolate agent filesystem access. Provide read-only access to system files and isolated writable directories for agent data.
# Moltbot agent filesystem isolation:
filesystem_isolation:
enabled: true
# Read-only system:
read_only_system:
# Mount system directories as read-only
# Prevent agent from modifying system files
paths:
- "/usr:ro"
- "/bin:ro"
- "/lib:ro"
- "/etc:ro"
# Isolated writable directories:
writable_dirs:
# Provide isolated writable directories for agent data
# Each agent has its own writable directory
path: "/agent-data"
# Mount with noexec flag to prevent execution
options: "noexec,nosuid,nodev"
# Volume isolation:
volumes:
# Use separate volumes for each agent
# Prevent cross-agent data access
enabled: true
# Each agent gets its own volume
volume_per_agent: true
# Temporary directory isolation:
tmp:
# Use isolated /tmp directory for each agent
# Clear on agent termination
isolated_tmp: true
clear_on_termination: trueReal-World Scars — What Went Wrong in Production
SaaS Platform — Resource Exhaustion
Fintech Startup — Filesystem Escape
Immediate Actions — What You Should Do Today
- ✓ Implement process isolation
- ✓ Set resource limits
- ✓ Configure filesystem isolation
- ✓ Implement network isolation
- ✓ Create Seccomp profile
- ✓ Set up monitoring
- ✓ Configure alerting
- ✓ Set up audit trails
- ✓ Create incident response playbooks
Interactive Checklist — Progress Tracking
LocalStorage-based progress tracking. Checklists are automatically saved and restored on next visit.
Security Score Calculator — How Secure is Your Runtime Sandboxing?
Answer 5 questions and get your Security Score (0-100). This score is based on production best practices.
Difficulty Level — Personalized Learning Path
Personalized learning paths based on your score. Structured learning from beginner to expert.
Ask AI — Context-Aware Chat
Chatbot that knows the current page content. RAG with page content as context. Responses with citations.
Daypass — 24h Full Access for €3
One-time per user/credit card. Full 24 hours access to all security tools.
Related Topics
Frequently Asked Questions
What is the difference between containerisation and process isolation?
Containerisation is a lightweight form of virtualisation that packages an application with its dependencies into a container. Containers share the host kernel but have isolated namespaces (user, PID, network, mount). Process isolation is a more fundamental isolation mechanism that separates processes at the kernel level using namespaces and cgroups. Containerisation builds on top of process isolation. Both are necessary: containerisation provides a convenient way to package and deploy agents, while process isolation provides the fundamental security boundaries. In practice, use Docker containers for convenience, and ensure they are properly configured with namespace isolation and seccomp profiles for security.
How do I set appropriate resource limits for agents?
Resource limits should be based on: 1) Agent complexity — simple agents need fewer resources than complex multi-step agents. 2) Expected workload — agents processing large amounts of data need more memory and CPU. 3) User tier — enterprise users may be allocated more resources than free users. 4) Cost constraints — set limits to control infrastructure costs. 5) Isolation requirements — stricter limits for high-risk agents. Start with conservative limits (512MB memory, 0.5 CPU core) and monitor actual usage. Adjust limits based on metrics. Implement per-tier resource quotas to balance user experience with cost control.
How does network isolation prevent agent exploitation?
Network isolation prevents agents from accessing unauthorised endpoints. If an agent is compromised, network isolation limits the attacker's ability to: 1) Exfiltrate data to external servers. 2) Command and control (C2) communication with attacker infrastructure. 3) Pivot to other systems on the network. 4) Download malware or tools. Network isolation uses network policies (default deny, allow specific) and firewall rules to control egress traffic. DNS isolation prevents access to malicious domains. Combined with filesystem isolation, network isolation limits the blast radius of a compromised agent.
What are the risks of inadequate filesystem isolation?
Inadequate filesystem isolation allows agents to: 1) Modify system files — modify /etc/passwd, install backdoors, modify configuration. 2) Access other agents' data — read or modify files belonging to other agents. 3) Access host system files — read sensitive host data, modify host configuration. 4) Execute malicious code — if /tmp is executable, agents can download and execute malware. 5) Persist malware — if writable directories persist, malware can persist across agent restarts. Proper filesystem isolation uses read-only mounts for system directories, isolated writable directories with noexec flag, and separate volumes per agent.