Pentesting Kubernetes from the outside
There different ways to find exposed Kubernetes Pods to the internet.
Finding exposed pods with OSINT
One way could be searching for Identity LIKE "k8s.%.com"
in crt.sh to find subdomains related to kubernetes. Another way might be to search "k8s.%.com"
in github and search for YAML files containing the string.
Finding Exposed pods via port scanning
The following ports might be open in a Kubernetes cluster:
cAdvisor
Insecure API server
Secure API Server
etcd API
Kubelet API
kubelet (Read only)
Remote Cluster Misconfigurations
By default, API endpoints are forbidden to anonymous access. But it’s always a good idea to check if there are any insecure endpoints that expose sensitive information:
Checking for ETCD Anonymous Access
The ETCD stores the cluster secrets, configuration files and more sensitive data. By default, the ETCD cannot be accessed anonymously, but it always good to check.
If the ETCD can be accessed anonymously, you may need to use the etcdctl tool. The following command will get all the keys stored:
Checking Kubelet (Read Only Port) Information Exposure
When the “kubelet” read-only port is exposed, the attacker can retrieve information from the API. This exposes cluster configuration elements, such as pods names, location of internal files and other configurations. This is not critical information, but it still should not be exposed to the internet.
For example, a remote attacker can abuse this by accessing the following URL: http://<external-IP>:10255/pods
References
Last updated