# 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 | 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 `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]]. ## 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 - [[raw/agentoffense.com/ssrf-cloud-metadata-attacks-url-fetcher-to-iam-credentials-15332|SSRF Cloud Metadata Attacks: URL Fetcher to IAM Credentials]] - [[raw/book.hacktricks.xyz/cloud-ssrf-58|Cloud SSRF - HackTricks]] - [[raw/madhuakula.com/ssrf-in-the-kubernetes-world-kubernetes-goat-3161|SSRF in the Kubernetes (K8S) world — Kubernetes Goat]] - [[raw/raesene.github.io/fun-with-ssrf-turning-the-kubernetes-api-server-into-a-port-scanner-219|Fun with SSRF - Turning the Kubernetes API Server into a port scanner]] - [[raw/github.com/raesene-k8s-ssrf-portscanner-27|raesene/k8s_ssrf_portscanner]] - [[raw/archy.net/auditing-and-mitigating-axios-ssrf-in-kubernetes-cve-2025-27152-3289|CVE-2025-27152: Auditing and Mitigating Axios SSRF in Kubernetes]] - [[raw/medium.com/the-8-000-kubernetes-ssrf-bug-bounty-how-one-hidden-http-header-reveal-14215|The $8,000 Kubernetes SSRF Bug Bounty]] - [[raw/lava.security/inside-the-neocloud-part-1-when-the-container-is-the-only-wall-15335|Inside the Neocloud (Part 1): When the Container Is the Only Wall]] - [[raw/x.com/cve-2020-8561-exploits-an-ssrf-flaw-in-kubernetes-api-servers-validati-2689|CVE-2020-8561: SSRF in Kubernetes API server]] - [[raw/x.com/daily-cybersecurity-cve-2026-15378-is-a-blind-ssrf-in-red-hat-openshif-10429|CVE-2026-15378: Blind SSRF in Red Hat OpenShift AI]] - [[raw/x.com/6000-bounty-for-a-juicy-ssrf-that-exposed-internal-files-k8s-access-to-2289|$6000 bounty: SSRF exposing internal files, K8s tokens, Lambda runtime API]] - [[raw/blog.rankiteo.com/dgraph-critical-ssrf-and-auth-bypass-cve-2026-34976-3316|Dgraph Critical SSRF and Auth Bypass (CVE-2026-34976)]]