Reconnaissance and Enumeration
This section covers different ways of retrieving information from a K8S cluster from the outside and the inside.
Overview
Most of the time, you will not directly interact with critical Kubernetes components. Instead, you must first gain a foothold in a Kubernetes pod, which then allows access to internal Kubernetes APIs. Because these pods often host web services, obtaining an initial foothold typically relies more on traditional web application pentesting skills than on Kubernetes-specific techniques.

This table sums up all the important ports to recon inside a Kubernetes cluster:
443/TCP
kube-apiserver
Kubernetes API port
2379/TCP
etcd
etcd,etcdAPI
6666/TCP
etcd
etcd
4194/TCP
cAdvisor
Container metrics
6443/TCP
kube-apiserver
Kubernetes API port (HTTPS)
8443/TCP
kube-apiserver
Minikube API port
8080/TCP
kube-apiserver
Insecure API port (HTTP, deprecated)
10250/TCP
kubelet
HTTPS API which allows full mode access
10255/TCP
kubelet
Unauthenticated read-only HTTP port: pods, running pods and node state (deprecated)
10256/TCP
kube-proxy
Kube Proxy health check server
9099/TCP
calico-felix
Health check server for Calico
6782-4/TCP
weave
Metrics and endpoints
30000-32767/TCP
NodePort
Proxy to the services
44134/TCP
Tiller
Helm service listening
Kubernetes Control Plane Exposure
Even though it shouldn’t be exposed to untrusted networks, some Kubernetes control planes are publicly exposed. This clearly facilitates our work because we can directly interact with the control plane API to retrieve important information.
Network Reconnaissance
K8S API Access
If the Control Plane is accessible the authentication enforcement might be disabled. A common misconfiguration in Kubernetes exposes API endpoints. By navigating to the IP address in a browser, the server may respond with a list of the API paths https://<CONTROL_PLANE_IP>. Thus you can try interacting with the Master API to see if you can retrieve information anonymously.
Sample curl requests to kube-apiserver that might reveal useful information:
List of standard API endpoints:
Sample requests to access etcdAPI that might reveal useful information:
kubelet API Access
kubelet API AccessAccess to the read-only kubelet port 10255 can expose cluster configuration elements, such as pod names, location of internal files, and other configurations that might be used to identify sensitive information or craft other attacks.
etcd API Access
etcd API AccessThe etcd API stores the entire state of the Kubernetes cluster, including secrets, configuration data, and service account information. If the etcd service is accessible over the network without proper authentication or encryption, it represents a critical security risk. Detecting exposed etcd endpoints allows us to verify service availability, enumerate cluster members, and assess health status.
etcd Service Detection:
etcd Data Enumeration:
Cloud Provider Discovery
SSL Certificate Inspection
Internal Enumeration (From Compromised Pod)
Once a pod is compromised, internal enumeration becomes significantly more effective. Kubernetes automatically mounts a service account token inside most pods, which can be used to authenticate against the Kubernetes API and enumerate cluster resources based on the assigned RBAC permissions.
However, kubectl is not always available inside containers, either due to minimal images or security hardening. In such cases, direct interaction with the Kubernetes API using tools like curl becomes essential for performing enumeration and permission discovery.
Container Environment Discovery
Depending on the privileges associated with this service account token, the easiness of rooting the cluster can change.
Network Environment Analysis
Retrieving the following information will help you map the internal cluster network and facilitate the pivoting step.
Internal Service Enumeration
Network Scanning from Pod (requires network pivoting):
RBAC and Permission Enumeration
Service Account Analysis:
Advanced Permission Discovery:
ConfigMap Analysis
Cluster Discovery
Understanding the cluster’s layout is a critical step in Kubernetes pentesting. Cluster discovery and architecture mapping involve identifying the nodes, services, and overall topology of the environment.
By mapping the cluster, we can determine which nodes host critical workloads, how network traffic flows, and where sensitive resources are located. This information is essential for planning further enumeration and potential lateral movement.
Node Discovery
Network Policy Analysis
Pod Security Analysis
RBAC Configuration Review
Service Account Token Usage
Once a service account token is retrieved from a compromised pod, it can be used to authenticate directly against the Kubernetes API server. This token allows interaction with all previously described API endpoints, with access limited only by the RBAC permissions assigned to the service account.
Even in the absence of kubectl, we can leverage the token to perform enumeration, query cluster resources, and retrieve sensitive information by sending authenticated HTTP requests directly to the Kubernetes API.
Automated Enumeration Tools
Detection Evasion Techniques
During reconnaissance, simple traffic obfuscation techniques can be used to blend API requests with legitimate Kubernetes activity. One common approach is to modify the HTTP User-Agent header to mimic standard Kubernetes clients, such as kubectl.
While this does not bypass authentication or authorization controls, it can reduce suspicion in logs and make reconnaissance traffic less distinguishable from normal cluster operations.
Resources
Last updated
Was this helpful?