githubEdit

Kubernetes Pentesting


Common Ports

Port
Service
Description

6443/8443

kube-apiserver

Kubernetes API (HTTPS)

10250

kubelet

Kubelet API (HTTPS)

10255

kubelet

Kubelet read-only API (HTTP)

10256

kube-proxy

Health check

2379/2380

etcd

Key-value store

10249

kube-proxy

Metrics


Discovery

Identifying Kubernetes

# SSL cert inspection reveals K8s
curl -k https://TARGET:8443/
# Response contains: "User \"system:anonymous\" cannot get path"
# Headers: X-Kubernetes-Pf-Flowschema-Uid

# Check common endpoints
curl -k https://TARGET:8443/version
curl -k https://TARGET:8443/healthz
curl -k https://TARGET:8443/readyz
curl -k https://TARGET:8443/livez
curl -k https://TARGET:8443/api
curl -k https://TARGET:8443/api/v1

SSL Certificate Indicators


Kubelet API (Port 10250)

The Kubelet API is often exposed and may allow unauthenticated access.

Manual Enumeration

kubeletctl Tool


Service Account Token Extraction

Tokens are mounted inside pods at predictable paths:


kubectl with Stolen Token


Privilege Escalation via Malicious Pod

If you have pod creation privileges, mount the host filesystem:

Basic Host Mount Pod

Privileged Pod with Host Access

Deploy and Access


Container Breakout Techniques

Via Host Mount

Via Privileged Container


Useful API Endpoints


Quick Reference


References

  • https://cloud.hacktricks.wiki/en/pentesting-cloud/kubernetes-security/kubernetes-enumeration.html

  • https://github.com/cyberark/kubeletctl

Last updated