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:
- 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.
- Kubernetes identity & control plane — projected service-account tokens on disk, the API server, kubelet, etcd.
- 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
| Service | Port | Notes |
|---|---|---|
| kubelet API | 10250 | exec/run, pod listing; often trusts node-network callers |
| kubelet read-only | 10255 | legacy, unauthenticated |
| kube-apiserver | 6443/443 | with a stolen SA token |
| etcd | 2379 | raw cluster secrets if reachable |
| Docker API / docker.sock | 2375 | host takeover |
| Consul | 8500 | config/service data |
| Envoy admin | 15000 / 9901 | topology, config dump, sometimes secrets — GET-only reachable |
| Prometheus/Grafana/Kibana/Jenkins/Elasticsearch | various | internal 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
restoreTenantGraphQL 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-dbmicroservice +svc.cluster.localservice 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.
Related
- Server-Side Request Forgery
- Cloud Metadata Service Exploitation
- IMDSv2
- SSRF Prevention
- Blind SSRF
- Webhook SSRF
- SSRF in AI Agents and LLM Tools
- Out-of-Band Detection
Sources
- SSRF Cloud Metadata Attacks: URL Fetcher to IAM Credentials · original
- Cloud SSRF - HackTricks · original
- SSRF in the Kubernetes (K8S) world — Kubernetes Goat · original
- Fun with SSRF - Turning the Kubernetes API Server into a port scanner · original
- raesene/k8s_ssrf_portscanner · original
- CVE-2025-27152: Auditing and Mitigating Axios SSRF in Kubernetes · original
- The $8,000 Kubernetes SSRF Bug Bounty · original
- Inside the Neocloud (Part 1): When the Container Is the Only Wall · original
- CVE-2020-8561: SSRF in Kubernetes API server · original
- CVE-2026-15378: Blind SSRF in Red Hat OpenShift AI · original
- $6000 bounty: SSRF exposing internal files, K8s tokens, Lambda runtime API · original
- Dgraph Critical SSRF and Auth Bypass (CVE-2026-34976) · original