CG
SkillsDetecting Container Escape Attempts
Start Free
Back to Skills Library
Container & Cloud-Native Security🔴 Advanced

Detecting Container Escape Attempts

Leverage Container escape — critical attack technique where an adversary breaks out of container isolation to access the host system or other containers. Detection involves monitoring for escape indicators.

5 min read7 code examples4 MITRE techniques

Prerequisites

  • Linux host with kernel 5.10+ (eBPF support)
  • Falco 0.37+ installed (kernel module or eBPF probe)
  • Docker Engine or containerd runtime
  • auditd configured
  • Root access for eBPF/kernel module loading

MITRE ATT&CK Coverage

T1611T1610T1068T1548

Detecting Container Escape Attempts

Overview

Container escape is a critical attack technique where an adversary breaks out of container isolation to access the host system or other containers. Detection involves monitoring for escape indicators such as namespace manipulation, capability abuse, kernel exploits, mounted sensitive paths, and anomalous syscall patterns using runtime security tools like Falco, Sysdig, and custom seccomp/audit rules.

Prerequisites

  • Linux host with kernel 5.10+ (eBPF support)
  • Falco 0.37+ installed (kernel module or eBPF probe)
  • Docker Engine or containerd runtime
  • auditd configured
  • Root access for eBPF/kernel module loading

Core Concepts

Common Container Escape Vectors

VectorTechniqueMITRE ID
Privileged containersMount host filesystem, load kernel modulesT1611
Docker socket mountCreate privileged container from withinT1610
Kernel exploitsCVE-2022-0185 (fsconfig), Dirty Pipe, runc CVEsT1068
Capability abuseCAP_SYS_ADMIN, CAP_SYS_PTRACE, CAP_NET_ADMINT1548
Sensitive mounts/proc/sysrq-trigger, /proc/kcore, cgroup release_agentT1611
Namespace escapensenter, unshare to host namespacesT1611
Symlink/bind mountEscape through /proc/self/rootT1611

Detection Layers

  1. Syscall monitoring - eBPF/kernel module captures syscalls in real-time
  2. File integrity - Detect modification of escape-enabling paths
  3. Process monitoring - Track process creation, namespace changes
  4. Network monitoring - Detect container-to-host connections
  5. Audit logging - Linux auditd for capability and mount operations

Implementation Steps

Step 1: Deploy Falco for Runtime Detection

# falco-values.yaml for Helm deployment
falco:
  driver:
    kind: ebpf   # or modern_ebpf for kernel 5.8+
  rules_files:
    - /etc/falco/falco_rules.yaml
    - /etc/falco/falco_rules.local.yaml
    - /etc/falco/rules.d
  json_output: true
  json_include_output_property: true
  http_output:
    enabled: true
    url: "http://falcosidekick:2801"
  grpc:
    enabled: true
  priority: warning
# Install Falco via Helm
helm repo add falcosecurity https://falcosecurity.github.io/charts
helm install falco falcosecurity/falco \
  --namespace falco-system --create-namespace \
  -f falco-values.yaml

Step 2: Custom Falco Rules for Escape Detection

# /etc/falco/rules.d/container_escape.yaml

# Detect container escape via privileged container
- rule: Container Escape via Privileged Mode
  desc: Detect attempts to escape container using privileged capabilities
  condition: >
    spawned_process and container and
    (proc.name in (nsenter, unshare, mount, umount, modprobe, insmod) or
     (proc.name = chroot and proc.args contains "/host"))
  output: >
    Container escape attempt via privileged operation
    (user=%user.name container=%container.name image=%container.image.repository
     command=%proc.cmdline pid=%proc.pid %container.info)
  priority: CRITICAL
  tags: [container, escape, T1611]

# Detect Docker socket access from container
- rule: Container Access to Docker Socket
  desc: Detect container reading/writing to Docker socket
  condition: >
    (open_read or open_write) and container and
    fd.name = /var/run/docker.sock
  output: >
    Docker socket accessed from container
    (user=%user.name container=%container.name image=%container.image.repository
     fd=%fd.name command=%proc.cmdline %container.info)
  priority: CRITICAL
  tags: [container, escape, docker_socket]

# Detect sensitive proc filesystem access
- rule: Container Access to Sensitive Proc Paths
  desc: Detect container accessing host-sensitive proc paths
  condition: >
    open_read and container and
    (fd.name startswith /proc/sysrq-trigger or
     fd.name startswith /proc/kcore or
     fd.name startswith /proc/kmsg or
     fd.name startswith /proc/kallsyms or
     fd.name startswith /sys/kernel)
  output: >
    Sensitive proc/sys access from container
    (user=%user.name container=%container.name path=%fd.name
     command=%proc.cmdline %container.info)
  priority: CRITICAL
  tags: [container, escape, proc_access]

# Detect cgroup escape technique
- rule: Container Cgroup Escape Attempt
  desc: Detect writing to cgroup release_agent (escape technique)
  condition: >
    open_write and container and
    (fd.name contains release_agent or
     fd.name contains notify_on_release)
  output: >
    Cgroup escape attempt detected
    (user=%user.name container=%container.name path=%fd.name
     command=%proc.cmdline %container.info)
  priority: CRITICAL
  tags: [container, escape, cgroup]

# Detect kernel module loading from container
- rule: Container Loading Kernel Module
  desc: Detect container attempting to load kernel modules
  condition: >
    spawned_process and container and
    (proc.name in (modprobe, insmod, rmmod) or
     (evt.type = init_module or evt.type = finit_module))
  output: >
    Kernel module load attempt from container
    (user=%user.name container=%container.name command=%proc.cmdline
     %container.info)
  priority: CRITICAL
  tags: [container, escape, kernel_module]

# Detect namespace manipulation
- rule: Container Namespace Manipulation
  desc: Detect setns/unshare syscalls from container
  condition: >
    container and (evt.type = setns or evt.type = unshare) and
    not proc.name in (containerd-shim, runc)
  output: >
    Namespace manipulation from container
    (user=%user.name container=%container.name syscall=%evt.type
     command=%proc.cmdline %container.info)
  priority: CRITICAL
  tags: [container, escape, namespace]

# Detect mount operations from container
- rule: Container Mount Sensitive Filesystem
  desc: Detect container mounting host filesystems
  condition: >
    spawned_process and container and proc.name = mount and
    (proc.args contains "/dev/" or proc.args contains "proc" or
     proc.args contains "sysfs")
  output: >
    Sensitive mount operation from container
    (user=%user.name container=%container.name command=%proc.cmdline
     %container.info)
  priority: HIGH
  tags: [container, escape, mount]

Step 3: Configure Seccomp Profile for Escape Prevention

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "archMap": [
    { "architecture": "SCMP_ARCH_X86_64", "subArchitectures": ["SCMP_ARCH_X86", "SCMP_ARCH_X32"] }
  ],
  "syscalls": [
    {
      "names": [
        "read", "write", "open", "close", "stat", "fstat", "lstat",
        "poll", "lseek", "mmap", "mprotect", "munmap", "brk",
        "rt_sigaction", "rt_sigprocmask", "ioctl", "access",
        "pipe", "select", "sched_yield", "dup", "dup2",
        "nanosleep", "getpid", "socket", "connect", "accept",
        "sendto", "recvfrom", "bind", "listen", "getsockname",
        "getpeername", "socketpair", "setsockopt", "getsockopt",
        "clone", "fork", "vfork", "execve", "exit", "wait4",
        "kill", "getuid", "getgid", "geteuid", "getegid",
        "epoll_create", "epoll_wait", "epoll_ctl", "epoll_create1",
        "futex", "set_tid_address", "set_robust_list",
        "openat", "newfstatat", "readlinkat", "fchownat",
        "clock_gettime", "clock_getres", "clock_nanosleep",
        "getrandom", "memfd_create", "statx", "rseq"
      ],
      "action": "SCMP_ACT_ALLOW"
    },
    {
      "names": ["unshare", "setns", "mount", "umount2", "pivot_root",
                "init_module", "finit_module", "delete_module",
                "kexec_load", "kexec_file_load", "ptrace",
                "reboot", "swapon", "swapoff", "sethostname",
                "setdomainname", "keyctl", "bpf"],
      "action": "SCMP_ACT_LOG",
      "comment": "Log escape-relevant syscalls for detection"
    }
  ]
}

Step 4: Audit Rules for Container Escape

# /etc/audit/rules.d/container-escape.rules

# Monitor namespace operations
-a always,exit -F arch=b64 -S setns -S unshare -k container_escape
-a always,exit -F arch=b64 -S mount -S umount2 -k container_mount
-a always,exit -F arch=b64 -S init_module -S finit_module -S delete_module -k kernel_module
-a always,exit -F arch=b64 -S ptrace -k process_trace

# Monitor sensitive paths
-w /var/run/docker.sock -p rwxa -k docker_socket
-w /proc/sysrq-trigger -p w -k sysrq
-w /proc/kcore -p r -k kcore_read

# Monitor container runtime
-w /usr/bin/runc -p x -k container_runtime
-w /usr/bin/containerd -p x -k container_runtime
-w /usr/bin/docker -p x -k container_runtime

Step 5: Real-Time Alert Pipeline

# Falcosidekick configuration for alert routing
config:
  slack:
    webhookurl: "https://hooks.slack.com/services/xxx"
    minimumpriority: "critical"
    messageformat: |
      *Container Escape Alert*
      Rule: {{ .Rule }}
      Priority: {{ .Priority }}
      Output: {{ .Output }}

  elasticsearch:
    hostport: "https://elasticsearch:9200"
    index: "falco-alerts"
    minimumpriority: "warning"

  pagerduty:
    routingkey: "xxxx"
    minimumpriority: "critical"

Validation Commands

# Test Falco rules with event generator
kubectl run falco-event-generator \
  --image=falcosecurity/event-generator \
  --restart=Never \
  -- run syscall --action PtraceAttachContainer

# Check Falco alerts
kubectl logs -n falco-system -l app.kubernetes.io/name=falco --tail=50

# Verify seccomp profile is loaded
docker inspect --format '{{.HostConfig.SecurityOpt}}' <container-id>

# Check audit logs for escape-related events
ausearch -k container_escape --interpret

Compliance Framework Mapping

This skill supports compliance evidence collection across multiple frameworks:

  • SOC 2: CC6.1 (Logical Access), CC7.1 (Monitoring), CC8.1 (Change Management)
  • ISO 27001: A.14.2 (Secure Development), A.12.6 (Technical Vulnerability Mgmt)
  • NIST 800-53: CM-7 (Least Functionality), SI-2 (Flaw Remediation), SC-28 (Protection at Rest)
  • NIST CSF: PR.IP (Information Protection), PR.DS (Data Security)

Claw GRC Tip: When this skill is executed by a registered agent, compliance evidence is automatically captured and mapped to the relevant controls in your active frameworks.

Deploying This Skill with Claw GRC

Agent Execution

Register this skill with your Claw GRC agent for automated execution:

# Install via CLI
npx claw-grc skills add detecting-container-escape-attempts

# Or load dynamically via MCP
grc.load_skill("detecting-container-escape-attempts")

Audit Trail Integration

When executed through Claw GRC, every step of this skill generates tamper-evident audit records:

  • SHA-256 chain hashing ensures no step can be modified after execution
  • Evidence artifacts (configs, scan results, logs) are automatically attached to relevant controls
  • Trust score impact — successful execution increases your agent's trust score

Continuous Compliance

Schedule this skill for recurring execution to maintain continuous compliance posture. Claw GRC monitors for drift and alerts when re-execution is needed.

References

  • Falco Runtime Security
  • Container Escape Techniques - HackTricks
  • MITRE ATT&CK T1611 - Escape to Host
  • Sysdig Container Security

Use with Claw GRC Agents

This skill is fully compatible with Claw GRC's autonomous agent system. Deploy it to any registered agent via MCP, and every execution will be logged in the tamper-evident audit trail.

// Load this skill in your agent
npx claw-grc skills add detecting-container-escape-attempts
// Or via MCP
grc.load_skill("detecting-container-escape-attempts")

Tags

containerskubernetesdockersecurityruntime-securityescape-detection

Related Skills

Container & Cloud-Native Security

Securing Container Registry with Harbor

3m·intermediate
Container & Cloud-Native Security

Hardening Docker Containers for Production

3m·advanced
Container & Cloud-Native Security

Performing Kubernetes Penetration Testing

4m·advanced
Container & Cloud-Native Security

Auditing Kubernetes RBAC Permissions

3m·intermediate
Container & Cloud-Native Security

Implementing Kubernetes Pod Security Standards

3m·intermediate
Container & Cloud-Native Security

Implementing Network Policies for Kubernetes

3m·intermediate

Skill Details

Domain
Container & Cloud-Native Security
Difficulty
advanced
Read Time
5 min
Code Examples
7
MITRE IDs
4

On This Page

OverviewPrerequisitesCore ConceptsImplementation StepsValidation CommandsReferencesCompliance Framework MappingDeploying This Skill with Claw GRC

Deploy This Skill

Add this skill to your Claw GRC agent and start automating.

Get Started Free →