Skip to main content
Security is critical when running containerized sandboxes in production. This guide covers authentication, container hardening, network isolation, and operational security practices.

Authentication and Access Control

API Key Authentication

Always enable API key authentication in production:
Best Practices:
  • Use a strong, randomly generated API key (minimum 32 characters)
  • Store keys in a secrets manager (Vault, AWS Secrets Manager, etc.)
  • Never commit keys to version control
  • Rotate keys regularly
  • Use different keys for different environments
Disable Authentication Only For:
  • Local development
  • Trusted internal networks
  • Testing environments
Authentication is enforced when api_key is set. If empty or missing, all API endpoints (except /health, /docs, /redoc) are accessible without authentication.

Client Request Authentication

All authenticated requests must include the OPEN-SANDBOX-API-KEY header:
Protect API Keys:
  • Use HTTPS/TLS for all API communication
  • Avoid logging API keys in application logs
  • Monitor for unauthorized access attempts
  • Implement rate limiting at the reverse proxy level

Container Security Hardening

Drop Dangerous Capabilities

Linux capabilities control privileged operations. Drop unnecessary capabilities:
Why Drop These Capabilities:
  • SYS_ADMIN: Prevents container escape vulnerabilities
  • NET_ADMIN: Blocks network spoofing and routing attacks
  • SYS_MODULE: Prevents kernel module injection
  • SYS_PTRACE: Prevents process memory inspection
  • NET_RAW: Prevents packet crafting and sniffing

Block Privilege Escalation

Prevent processes from gaining new privileges:
This prevents:
  • Setuid/setgid binary exploitation
  • Privilege escalation via file capabilities
  • sudo/su within containers

Process Limits

Limit process creation to prevent fork bombs:
Recommended values:
  • Light workloads: 256-512 processes
  • Heavy workloads: 1024-2048 processes
  • Unlimited: null (not recommended)

Seccomp Profiles

Seccomp filters system calls to reduce the attack surface:
Options:
  • Empty string: Docker default seccomp profile (recommended)
  • Absolute path: Custom seccomp JSON profile
  • unconfined: Disable seccomp (not recommended)
Docker’s default profile blocks ~44 system calls including:
  • clone with dangerous flags
  • reboot
  • swapon/swapoff
  • mount/umount
  • Keyring manipulation

AppArmor Profiles

AppArmor provides mandatory access control:
Profile Options:
  • "": No AppArmor profile (default)
  • "docker-default": Docker’s default AppArmor profile
  • Custom profile name: Your organization’s profile
Check AppArmor Availability:

Network Security

Network Isolation

Use bridge mode for network isolation:
Bridge Mode Benefits:
  • Sandboxes cannot directly access each other
  • Host network is isolated from sandboxes
  • Port conflicts eliminated
  • Network policies enforceable
Host Mode Risks:
  • No network isolation
  • Port conflicts possible
  • Direct access to host network
  • Better performance but less secure

Network Policy Enforcement

Control outbound traffic with network policies:
Requirements:
  • Bridge network mode only
  • Egress sidecar image configured
  • Main container drops NET_ADMIN capability
  • Sidecar retains NET_ADMIN for iptables management
Example Request:
Network Policy Best Practices:
  • Default deny all egress traffic
  • Allowlist only required destinations
  • Block private IP ranges (RFC 1918)
  • Block cloud metadata endpoints (169.254.169.254)
  • Log denied connections for monitoring

TLS/HTTPS

Run OpenSandbox behind a reverse proxy with TLS:
Reverse Proxy Configuration (Nginx):

Resource Limits

Enforce resource quotas to prevent resource exhaustion:
Recommended Limits: Why Resource Limits Matter:
  • Prevent single sandbox from consuming all host resources
  • Enable fair resource sharing
  • Predictable performance
  • Protection against resource exhaustion attacks

Storage Security

Host Path Restrictions

Limit bind mount access to trusted paths:
Security Implications:
  • Empty list: All paths allowed (dangerous in production)
  • Non-empty list: Only prefixes in list are allowed
  • Prevents access to sensitive host directories
Dangerous Paths to Block:
  • /etc: System configuration
  • /root: Root user home
  • /var/run/docker.sock: Docker daemon socket
  • /proc, /sys: Kernel interfaces
  • User home directories

Read-Only Filesystems

Mount root filesystem as read-only when possible:
Benefits:
  • Prevents malware persistence
  • Protects against container modification
  • Forces use of volumes for state

Image Security

Use Trusted Images

Only allow vetted container images:
Manual Image Vetting:
  1. Use official images from trusted registries
  2. Pin specific image tags (avoid latest)
  3. Scan images for vulnerabilities
  4. Review Dockerfiles before use
  5. Use minimal base images (alpine, distroless)

Image Scanning

Scan images for vulnerabilities:

Private Registry Authentication

Configure Docker credential helpers:

Kubernetes Security

Pod Security Standards

Apply Pod Security Standards to the opensandbox namespace:

Network Policies

Restrict pod network access:

RBAC Configuration

Minimize service account permissions:

Monitoring and Auditing

Enable Logging

Collect logs for security monitoring:
Log Events to Monitor:
  • Authentication failures
  • Sandbox creation/deletion
  • Resource quota violations
  • Network policy denials
  • Container exits and crashes

Centralized Logging

Forward logs to a SIEM or log aggregator:

Audit Trail

Track all API operations:

Incident Response

Sandbox Compromise Detection

Monitor for indicators of compromise:
  • Unexpected network connections
  • High CPU/memory usage
  • Failed authentication attempts
  • Unusual process executions
  • Container escapes

Emergency Procedures

Immediate Actions:
  1. Delete compromised sandboxes:
  2. Rotate API keys:
  3. Review logs for attack patterns
  4. Update security policies
  5. Patch vulnerabilities

Production Security Checklist

1

Enable API Key Authentication

  • Set strong server.api_key
  • Store keys in secrets manager
  • Enable TLS/HTTPS with reverse proxy
2

Harden Container Security

  • Drop dangerous capabilities
  • Enable no_new_privileges
  • Set process limits (pids_limit)
  • Apply seccomp profile
  • Configure AppArmor (if available)
3

Configure Network Isolation

  • Use bridge network mode
  • Enable egress sidecar for network policies
  • Block private IP ranges
  • Configure ingress gateway
4

Restrict Storage Access

  • Set allowed_host_paths allowlist
  • Avoid binding sensitive host directories
  • Use read-only root filesystems
5

Implement Resource Controls

  • Set CPU/memory limits on all sandboxes
  • Configure appropriate quotas per workload
6

Secure Image Supply Chain

  • Use trusted registries only
  • Pin specific image tags
  • Scan images for vulnerabilities
  • Review Dockerfiles
7

Enable Monitoring

  • Configure centralized logging
  • Set up audit trails
  • Monitor for security events
  • Set up alerting
8

Kubernetes Security (if applicable)

  • Apply Pod Security Standards
  • Configure Network Policies
  • Minimize RBAC permissions
  • Use namespaces for isolation

Further Reading

Next Steps