Kubernetes Security for CTF: Cluster Auditing, RBAC Abuse, and Service Mesh Attacks
Kubernetes Architecture Quick‑Reference
A CTF Kubernetes cluster typically consists of Control Plane components (API Server, etcd, controller manager) and Worker Nodes running pods. Misconfigurations often expose the API Server on port 6443 or the Kubelet on 10250.
Common Misconfigurations in CTF Clusters
- Anonymous authentication enabled on the API Server.
- Overly permissive RBAC roles (e.g.,
cluster-adminbound tosystem:anonymous). - Default service account tokens mounted into pods.
- Etcd accessible without TLS.
Attacking RBAC & Service Accounts
- Enumerate roles with
kubectl get roles,rolebindings -A. - Use kubectl auth can-i --list --as=system:anonymous to spot dangerous permissions.
- If you can create a pod on any namespace, exploit it to mount the host’s filesystem:
spec: containers: - name: alpine image: alpine command: ['sh'] volumeMounts: - name: root mountPath: /host volumes: - name: root hostPath: path: / - Run
kubectl exec -it <pod> -- chroot /hostto obtain a root shell on the node and retrieve the flag.
Service Mesh (Istio) Exploitation
- Istio sidecar proxies can be abused to capture mTLS traffic if the
PeerAuthenticationpolicy is set toPERMISSIVE. - Use kubectl exec to access the sidecar and dump traffic with
tcpdump -i eth0 -w /tmp/capture.pcap. - Extract secrets from traffic and decode base64 to get the flag.
Detection with Falco & Audit Logs
- Deploy Falco as a DaemonSet to monitor abnormal API calls (e.g.,
kubectl execon a privileged pod). - Enable Audit Logs on the API Server (
--audit-policy-file=/etc/kubernetes/audit-policy.yaml) and forward them to an ELK stack for correlation.
Real‑World Pakistan Cloud Use Cases
Local companies host citizen services on private clouds that mimic K8s clusters. The PTA advises strict RBAC policies and regular security audits. Follow these guidelines when designing CTF challenges that emulate government portals.
Do / Don't
- Do use
kubectl --dry-run=clientto test manifests before applying them. - Don't leave
cluster-adminbound to any user other than the admin account.
