SSRF in Kubernetes and Containers

Using an in-cluster fetch primitive to reach the node metadata service, service-account tokens, the kubelet/API-server/etcd control planes and unauthenticated internal services that trust any caller on the pod network.

How it works

A pod that can be steered to fetch arbitrary URLs sits inside the cluster’s flat, mutually-trusting network. Three escalation layers:

  1. Node/cloud metadata — same endpoints as Cloud Metadata Service Exploitation; from a container you may reach node IMDS (169.254.169.254, hop limit permitting), ECS task creds (169.254.170.2) or EKS Pod Identity (169.254.170.23). Blast radius = the node or pod IAM role.
  2. Kubernetes identity & control plane — projected service-account tokens on disk, the API server, kubelet, etcd.
  3. Internal microservices — cluster DNS (service.namespace.svc.cluster.local) resolves app-internal services that are usually unauthenticated.

Kubernetes’ own design also turns privileged API objects (webhooks, URL fields) into SSRF: the API server itself makes the outbound request.

Techniques / payloads

Service-account tokens & internal service discovery

cat /var/run/secrets/kubernetes.io/serviceaccount/token      # projected SA JWT (IRSA/WI tokens too)
http://169.254.169.254/latest/meta-data/                      # node cloud metadata
http://<svc>.<namespace>.svc.cluster.local[:port]/            # internal services via cluster DNS
http://metadata-db/latest/secrets/<name>                      # app "metadata" microservices (Kubernetes Goat)

Enumerate loopback ports inside the pod (http://127.0.0.1:5000, admin sidecars) and cluster DNS names. A projected SA token used against the API server grants whatever RBAC that SA holds.

Control-plane / internal ports to probe

ServicePortNotes
kubelet API10250exec/run, pod listing; often trusts node-network callers
kubelet read-only10255legacy, unauthenticated
kube-apiserver6443/443with a stolen SA token
etcd2379raw cluster secrets if reachable
Docker API / docker.sock2375host takeover
Consul8500config/service data
Envoy admin15000 / 9901topology, config dump, sometimes secrets — GET-only reachable
Prometheus/Grafana/Kibana/Jenkins/Elasticsearchvariousinternal data, labels-as-secrets

Even a GET-only blind primitive supports internal port scanning and reaching Envoy admin / Prometheus; a gopher-capable client can issue state-changing commands to unauthenticated Redis/etcd.

API server as a port scanner (standard functionality, no CVE)

ValidatingWebhookConfiguration (and other objects with a url/service field) make the API server issue outbound HTTPS. raesene’s k8s_ssrf_portscanner: create a namespaced validating webhook pointing at target:port, then attempt a pod create in that namespace; the verbose API-server error distinguishes no response / closed / open / open-but-not-HTTP. Requests show User-Agent: kube-apiserver-admission. Needs high API privileges (so usually not privesc) but on managed EKS/AKS/GKE lets you scan the CSP network.

Leaky response headers

An ordinary-looking SSRF that returns nothing from cloud metadata can still leak internal Kubernetes topology (workload names, internal IPs, service-naming conventions) via a single reflected HTTP response header — the pivot that turned one finding into an $8k bounty exposing the internal infra map.

Notable cases / CVEs

  • CVE-2020-8561 — SSRF in the kube-apiserver via ValidatingWebhookConfiguration / profiling endpoints exposing full responses; requires cluster-admin to weaponize.
  • CVE-2025-27152 (axios) — axios < 1.8.2 forwards Authorization headers across a 3xx redirect; a 302 to an attacker host leaks internal bearer tokens from any pod making external HTTP calls. Mitigate by upgrade or egress NetworkPolicy.
  • CVE-2026-15378 — blind SSRF in Red Hat OpenShift AI guardrails-detectors, exposing cloud credentials and Kubernetes secrets.
  • CVE-2026-34976 (Dgraph ≤25.3.0) — unauthenticated restoreTenant GraphQL admin missing authz: overwrite DBs, steal password hashes and Kubernetes tokens, SSRF internal networks.
  • $6k bounty — SSRF exposing internal files, Kubernetes access tokens, and the Lambda runtime API.
  • Shopify Exchange (HackerOne #341876) — SSRF → root on all instances, the canonical cloud-native cluster SSRF.
  • Kubernetes Goat — training scenario: SSRF → 169.254.169.254 + metadata-db microservice + svc.cluster.local service discovery to reach the flag.

Defenses

Egress NetworkPolicies (default-deny outbound, allow only DNS + required internal services); least-privilege RBAC on service accounts; disable the kubelet read-only port and authenticate 10250; block node metadata from pods (IMDSv2 required + hop limit 1, or HttpEndpoint=disabled); upgrade HTTP clients that forward headers on redirect. See SSRF Prevention.

Sources