logo svg
logo

October 22, 2025

Kubernetes Penetration Testing: Methodology & Guide

Learn how to perform effective Kubernetes penetration testing. Step-by-step guide covering enumeration, common attacks and misconfigurations.

Hazem El-Sayed

Hazem El-Sayed

Featured Image

Kubernetes (K8s) has rapidly become the de facto platform for container orchestration, enabling microservices, scalability, resilience and portability. From a security testing (penetration testing) point of view, it introduces a new attack surface: clusters, nodes, pods, containers, APIs, role-based access, etc.

Why test Kubernetes?

Kubernetes shifts much of the application infrastructure into a highly dynamic environment: ephemeral containers, pods that scale up/down, complex networking, inter-pod communication, control‐plane APIs, etc. If misconfigured or poorly secured, an attacker can discover cluster metadata, expose etcd (the cluster’s key‐value store), exploit open APIs, or elevate privileges via mis-set role-based access control (RBAC).

Key Kubernetes Concepts for Pentesters

Before diving into tests, it helps to get familiar with the basic terminology

Getting these terms solid helps you follow the later attack surfaces.

Reconnaissance & Information Gathering

Passive discovery

Start with externally available information; this phase avoids touching the target network:

Public scans & search engines: use Shodan/Censys and CT logs to find domains, hostnames and certificates that indicate Kubernetes components

Below is a list of keywords to search with these tools:

Searching in Censys

Searching in Censys

Cluster management can be performed using tools like the Kubernetes dashboard, Weave Scope, and Lens. These applications add capabilities and offer graphical interfaces for the Kubernetes environment. Search engines like Shodan and Censys are useful for discovering improperly secured dashboards. Authentication is typically needed for these dashboard interfaces.

Here is an example to search in CT logs like crt.sh

Crtsh Search

Search in CT Logs using crt.sh

Public repos & config leaks: search GitHub/GitLab for yaml/yml manifests, Helm charts, or CI/CD configs containing cluster endpoints, tokens, or credentials.

Searching in GitHub for leaks

Searching in GitHub for leaks

What you’ll likely find: Secrets and leaked credentials, and publicly visible config files.

Active discovery

If passive discovery yields IPs/domains, move to live probes:

Here are the common exposed ports for Kubernetes clusters:

PortProcessDescription
443/TCPkube-apiserverKubernetes API port
2379/TCPetcdetcd,etcdAPI
6666/TCPetcdetcd
4194/TCPcAdvisorContainer metrics
6443/TCPkube-apiserverKubernetes API port
8443/TCPkube-apiserverMinikube API port
8080/TCPkube-apiserverInsecure API port
10250/TCPkubeletHTTPS API which allows full mode access
10255/TCPkubeletUnauthenticated read-only HTTP port: pods, running pods and node state
10256/TCPkube-proxyKube Proxy health check server
9099/TCPcalico-felixHealth check server for Calico
6782-4/TCPweaveMetrics and endpoints
30000-32767/TCPNodePortProxy to the services
44134/TCPTillerHelm service listening

Practical example (conceptual, follow legal rules before running any command):

Attack Surface Checklist

Below is a prioritized checklist with what to test, the risk each item represents, and common indicators of compromise or misconfiguration.

1. Kubernetes API Server

What to test

Why it matters

The API server is the cluster’s control plane unauthenticated access can allow reading resource definitions, secrets, or even creating resources.

Indicators

Remediation pointers

2. etcd

What to test

Why it matters

etcd stores cluster state and often secrets. Unprotected etcd = full cluster compromise.

Indicators

Remediation

3. Kubelet endpoints

What to test

Why?

Read-only kubelet can leak pod metadata, file locations, container images. If write operations or CVEs exist, kubelet could be abused to execute or escalate.

Indicators

Remediation

(Both sources discuss kubelet as a valuable reconnaissance target.)

4. Dashboard & Add-ons (cAdvisor, metrics UIs)

What to test

Why?

Dashboards often run with elevated permissions and can be used to view secrets or create workloads.

Indicators

Remediation

5. RBAC / Service Account Misconfigurations (internal escalation)

What to test

Why?

Service accounts often act as the identity of a pod. Overprivileged tokens are an easy path from pod to cluster admin.

Indicators

Remediation

6. Secrets and Configuration Leakage

What to test

Why?

Secrets in repo or etcd lead to credential theft and lateral movement.

Indicators

Remediation

Attack scenarios and escalation chains

Below are typical chains a pentester should attempt to demonstrate impact (based on the methodologies in the two resources).

Scenario A External API server + anonymous read

  1. Discover https://api.example.com:6443 responding to unauthenticated queries.
  2. Enumerate namespaces and secrets.
  3. Read a secret containing credentials for external services (DB, cloud provider).
  4. Use credentials to access other infrastructure or exfiltrate data.

Impact: full cluster visibility and external resource compromise.

Scenario B Exposed etcd

  1. Find etcd reachable at http://master.example.com:2379.
  2. Extract keys (including kube-system secret blobs, TLS certs).
  3. Reconstruct credentials to impersonate the cluster or decrypt data.

Impact: cluster takeover via direct control-plane data compromise.

Scenario C Kubelet information leakage → pivot

  1. Kubelet read-only port lists all pods and container images.
  2. Find a pod running with a mounted service account token and permissive RBAC.
  3. Retrieve token and use it against API server to escalate privileges.

Impact: lateral movement within cluster and possible cluster admin compromise.

Hands-on examples & commands

Below are conceptual examples of the kinds of commands shown or suggested in the referenced guides only run them against systems you are authorized to test.

Interpreting findings

When you find a positive result on a check, assess:

A small leak (e.g., read-only kubelet) may be low immediate severity but often enables lateral steps that escalate impact.

Remediation checklist

Following the two resources, apply these prioritized hardening steps:

  1. Lock down API server
    • Restrict access via firewall/network ACLs.
    • Require authentication (TLS client certs or OIDC) and disable anonymous access.
  2. Secure etcd
    • Require TLS for client/server communication.
    • Restrict network access to control plane only; enable access control.
  3. Harden kubelet
    • Disable read-only endpoints publicly; require auth for kubelet API.
    • Block 10255/10250 on external interfaces.
  4. Limit dashboard & add-on exposure
    • Don’t expose admin dashboards to the internet; bind them to localhost or use bastion/proxy.
    • Run dashboard with the least privilege necessary.
  5. RBAC & tokens
    • Audit RBAC ClusterRoleBindings; remove overly broad bindings.
    • Disable automounting of service account tokens where not needed.
    • Rotate service account tokens and secrets regularly.
  6. Secrets management
    • Don’t store secrets in plaintext in repo or in etcd without encryption at rest.
    • Use a secrets manager and ensure etcd encryption.
  7. Logging & monitoring
    • Log API access and watch for anomalous calls (e.g., unexpected list/delete operations).
    • Scan for exposed endpoints (regular Shodan/Censys checks) and alert on new public endpoints.

Reporting how to present findings to stakeholders

When you deliver a pentest report, include:

Limitations & safe testing notes

Appendix: Practical checklist

Use this checklist during a test. Mark results and follow with evidence.

  1. Passive discovery: public cert logs, Shodan/Censys, GitHub searches.
  2. API server reachable? /<api>/api/v1 responds without auth?
  3. etcd reachable (2379/2380) and returns keys?
  4. Kubelet read-only (10255) lists pods?
  5. Dashboard or metrics UI publicly reachable?
  6. Any secrets found in public repos?
  7. Service accounts with broad RBAC bindings?
  8. Can a mounted token be used to access API?

Common Tools you will need

Frequently Asked Questions FAQ —

background
Let's hack you before real hackers do

Stay secure with DeepStrike penetration testing services. Reach out for a quote or customized technical proposal today

Contact Us