P
performing-container-escape-detection
About performing-container-escape-detection
A container security auditing skill for security assessors and incident responders. It checks Kubernetes pods for configurations that may enable container escapes.
Key features
- 01Check privileged containers
- 02Check dangerous capabilities
- 03Check host namespace sharing
- 04Check writable hostPath mounts
- 05Check Docker socket mounts
Use cases
- 01Audit Kubernetes pod configurations
- 02Investigate container security incidents
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill performing-container-escape-detectionAfter installing, type/performing-container-escape-detectionin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
LICENSEreferences/api-reference.mdscripts/agent.pyDetails
From the project READMEPerforming Container Escape Detection
When to Use
- When conducting security assessments that involve performing container escape detection
- When following incident response procedures for related security events
- When performing scheduled security testing or auditing activities
- When validating security controls through hands-on testing
Prerequisites
- Familiarity with container security concepts and tools
- Access to a test or lab environment for safe execution
- Python 3.8+ with required dependencies installed
- Appropriate authorization for any testing activities
Instructions
Audit Kubernetes pods for container escape vectors including privileged mode, dangerous capabilities, host namespace sharing, and writable hostPath mounts.
from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()
pods = v1.list_pod_for_all_namespaces()
for pod in pods.items:
for container in pod.spec.containers:
sc = container.security_context
if sc and sc.privileged:
print(f"PRIVILEGED: {pod.metadata.namespace}/{pod.metadata.name}")
Key escape vectors:
- Privileged containers (full host access)
- CAP_SYS_ADMIN capability
- Host PID/Network/IPC namespace sharing
- Writable hostPath mounts to / or /etc
- Docker socket mount (/var/run/docker.sock)
Examples
# Check for docker socket mounts
for vol in pod.spec.volumes or []:
if vol.host_path and "docker.sock" in (vol.host_path.path or ""):
print(f"Docker socket exposed: {pod.metadata.name}")
Comments
Markdown supported