Containerization / Orchestration
Kubernetes
kubectl
Get kubectl:
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --clientBasic authenticated enumeration (the service account token from /run/secrets/kubernetes.io/serviceaccount/token can be parsed at jwt.io):
$ kubectl auth can-i --list
$ kubectl get namespaces
$ kubectl auth can-i --list -n <NAMESPACE>
$ kubectl get pods -n <NAMESPACE>
$ kubectl describe pods <POD> -n <NAMESPACE>
$ kubectl get secrets -n <NAMESPACE>
$ kubectl describe secrets -n <NAMESPACE>
$ kubectl --token=$(cat token) auth can-i create podsTo use kubectl from a remote host:
Bad Pods
Deploy a custom pod:
Kubernetes API Server Paths
Check these kube-apiserver paths for anonymous access (stolen from HackTricks):
Pod Escape
CVE-2022-0492 (cgroups)
Node Post-Exploitation
clusterrole-aggregation-controller
A study case in taking over the cluster after escaping from a pod to a worker node.
Extract tokens from all the running containers:
Check privileges of each token:
List kube-system secrets with a discovered privileged token:
Add exec privilege with clusterrole-aggregation-controller token to itself:
Look for a privileged pod to exec into it:
Do it:
Tools
kube-hunter
Training Labs
Red Hat OpenShift
Grant a low-priv user admin's privileges across the cluster via REST API:
Last updated