Skip to main content
RunBook Academy

KubernetesLVI · Kubernetes Security FoundationsSecurity foundations

Attack surface mapping — what is exposed to whom

Advanced⏱ ~15 minkubectl

What you'll learn

  • Enumerate every endpoint that accepts external connections in a Kubernetes cluster
  • Map credentials (kubeconfigs, tokens, cloud creds) to their exposure surface
  • Identify the misconfigurations that expand the attack surface
  • Prioritise surface reduction based on exposure and impact

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

The attack surface of a Kubernetes cluster is the sum of every endpoint that accepts a connection, every credential that can be stolen, and every misconfiguration that allows a non-adversarial event to escalate. Mapping the surface turns “we have a cluster” into a concrete list of exposures, each with an owner and a remediation. This lesson enumerates the surface for a typical production cluster and the controls that shrink it.

Network endpoints

A cluster has more network endpoints than most operators realise. Each one is a place where an attacker can pivot.

flowchart LR
    A[Internet] --> B[Cloud LB]
    B --> C[API server 6443]
    B --> D[Ingress controller 80, 443]
    E[Operator kubectl] -->|6443| C
    F[CI/CD] -->|6443| C
    C -->|2379| G[(etcd)]
    C -->|10250| H[Kubelet]
    H -->|containerd socket| I[Container runtime]
    D --> J[Workload pods]
    K[Webhook service] -->|443| C
EndpointDefault portAuthenticationRisk if compromised
API server6443TLS + RBACCluster admin
etcd2379mTLSAll cluster state
Kubelet API10250Anonymous (often)Node-level exec
Kubelet read-only10255None (deprecated)Pod enumeration
containerd / CRI-O socketunix socketNone on hostFull node compromise
Ingress controller80/443TLS to backendWorkload compromise
Webhook services443TLSBypass admission

Credentials

Three classes of credentials drive Kubernetes security posture:

  • Kubeconfigs~/.kube/config for humans, mounted files for CI/CD. Long-lived if they embed client certs, short-lived if they use OIDC.
  • ServiceAccount tokens — projected into Pods at /var/run/secrets/kubernetes.io/serviceaccount/token. Short-lived (1 hour by default in 1.34), but still extractable from a compromised container.
  • Cloud credentials — IAM roles, instance metadata service access, service account keys. The credential every workload uses to talk to the cloud.

Misconfigurations

The third axis of the attack surface is misconfiguration. The CIS Kubernetes Benchmark enumerates ~150 of them; the ones that most commonly expand the surface:

MisconfigurationSurface expanded
--anonymous-auth=true on kubeletAnyone with node network reach can call kubelet
AlwaysAllow authorization mode on kubeletAnonymous = full access
hostNetwork: true on a PodWorkload shares the node network namespace
hostPID: true on a PodWorkload can see and signal all node processes
privileged: true on a containerAll capabilities granted, kernel paths visible
automountServiceAccountToken: true (default)Every Pod receives a token even if it does not need one
Default ServiceAccount with no RBAC bindingToken exists but is useless; not a security control
Default ServiceAccount bound to edit or higherToken in every Pod is a privilege escalation primitive
Ingress controller exposed to internet without authWorkload compromise via request smuggling
Webhook without failurePolicy: Ignore auditA failed webhook is silently bypassed
--read-only-port=0 not set on kubeletUnauthenticated read endpoint at 10255
hostPath volumes in workloadsContainer escape to host filesystem

Mapping the surface in practice

A surface map is a table with one row per exposure. Each row has: the asset, the endpoint or credential, the attacker reach, the impact if compromised, the existing control, and the residual risk. The map drives the remediation backlog.

flowchart TB
    A[Asset: API server] --> B[Endpoint: 6443]
    B --> C[Reach: Internet if public]
    C --> D[Impact: Cluster admin]
    D --> E[Control: Private endpoint + RBAC]
    E --> F[Residual: Low if private; high if public]

    G[Asset: Kubelet] --> H[Endpoint: 10250]
    H --> I[Reach: Pods on node, host network]
    I --> J[Impact: Node exec, container escape]
    J --> K[Control: anonymous-auth=false, Webhook authz]
    K --> L[Residual: Medium depends on chart]

The map is a living artifact. Every new Helm chart, every new ingress, every new webhook service changes the map. A quarterly surface review — kubectl get on every CRD, audit of every Service of type LoadBalancer, scan of every Secret — is the discipline.

Production failure modes

Three ways surface mapping fails in real shops:

  1. The map is built once. A cluster that was mapped on day 1 has a different surface on day 365: new ingress controllers, new CRDs, new add-on operators. The map must be re-built.
  2. The map stops at the cluster. The threat model names the cluster; the surface map names every adjacent system (image registry, OIDC provider, secret manager, cloud IAM). Stopping at the cluster misses half the surface.
  3. The map is not tied to ownership. A surface reduction without an owner is a wish. Every row needs a team and a date.

Cross-course references

  • The Linux course covers the kernel attack surface that the kubelet and runtime expose to Pods.
  • The OPNsense course covers the network perimeter that the cloud LB and firewall expose.
  • The Observability course covers the audit log that detects scanning and reconnaissance on the surface.

Quiz

Knowledge check · 4 questions

  1. Q1. Which Kubernetes network endpoint is most commonly under-hardened in production and is reachable from every Pod on the node via the host network?

  2. Q2. The cloud instance metadata service v1 (IMDSv1) is authenticated and prevents exfiltration of cloud credentials by compromised Pods.

  3. Q3. Your cluster was mapped six months ago. Since then, the platform team added three new Helm installs: an ArgoCD operator with its own CRDs, an Istio ingress, and a Kyverno admission policy engine. The surface map still lists only the original components. What is the failure mode?

    ArgoCD has `cluster-admin` ClusterRoleBinding to manage its apps. The Istio ingress exposes the workload mesh to the public internet via a NodePort. Kyverno's webhook service is reachable on the cluster network. The map document is six months old and has not been updated.

  4. Q4. Name four Kubernetes misconfigurations that expand the attack surface, and what each one enables.

Passing score: 75%. Answers are checked in this browser.

Production discipline

A credible surface map is rebuilt every quarter, after every Helm install, and after every CRD introduction. It names every endpoint, every credential, every misconfiguration. Each row has an owner and a date. The map drives the remediation backlog, and the backlog is the proof that security is an operational discipline, not a one-time deliverable. A cluster with a six-month-old map has an undiscovered surface; a cluster with a live map is defensible.