Sandbox Escape
Category: Privilege & Access Control
Severity: Critical
MITRE ATT&CK Mapping: T1055 (Process Injection)
Description
Breaking out of security sandboxes and containment mechanisms designed to isolate MCP tools and processes, enabling access to the broader system environment.
Technical Details
Attack Vector
- Sandbox implementation flaws
- Containment bypass techniques
- Security boundary violations
- Isolation mechanism failures
Common Techniques
- Container escape techniques
- Virtual machine breakout
- Process isolation bypass
- Security boundary violations
Impact
- System Access: Breaking out of containment to access host system
- Security Bypass: Circumventing security isolation mechanisms
- Lateral Movement: Accessing systems outside the sandbox
- Privilege Escalation: Gaining higher privileges outside containment
Detection Methods
Sandbox Monitoring
- Monitor sandbox integrity
- Detect escape attempts
- Track containment violations
- Analyze sandbox behavior
System Monitoring
- Monitor system activities
- Track process behavior
- Detect privilege escalation
- Analyze system integrity
Mitigation Strategies
Sandbox Security
- Harden sandbox implementations
- Implement strong isolation
- Deploy escape detection
- Regular security updates
Containment Controls
- Implement multi-layered containment
- Use secure isolation mechanisms
- Deploy monitoring systems
- Regular security audits
Real-World Examples
Example 1: Container Escape via Mount Points
# Vulnerable container configuration
import os
import subprocess
def execute_in_container(command):
# Weak container isolation
container_config = {
"mounts": [
{"source": "/", "target": "/host", "type": "bind"}
]
}
# Attacker escapes via host mount
# command = "chroot /host /bin/bash"
subprocess.run(["docker", "run", "--privileged", "-v", "/:/host", "image", command])
Example 2: Process Namespace Escape
# Vulnerable process isolation
import os
def create_sandbox():
# Weak process isolation
pid = os.fork()
if pid == 0:
# Child process in "sandbox"
# Insufficient namespace isolation
os.execv("/bin/sh", ["sh"])
else:
# Parent process
os.waitpid(pid, 0)
# Attacker breaks out of weak isolation
# Access to parent process namespace
Example 3: File System Escape
# Vulnerable file system containment
import os
class SandboxFileSystem:
def __init__(self):
self.jail_dir = "/tmp/sandbox"
def access_file(self, path):
# Insufficient path validation
full_path = os.path.join(self.jail_dir, path)
# Vulnerable to path traversal
if os.path.exists(full_path):
return open(full_path, 'r').read()
# Attacker escapes sandbox
# path = "../../../../etc/passwd"
References & Sources
- Academic Paper - “Model Context Protocol (MCP): Landscape, Security Threats, and Future Research Directions”
- Strobes Security - “MCP and Its Critical Vulnerabilities”
Related TTPs
Sandbox escape represents a critical security vulnerability that can completely compromise the isolation and containment of MCP systems.