# SSRF vulnerability can be exploited when a hijacked aggregated api server such as metrics-server returns 30X

Hijacked aggregated API server (metrics-server) returning 30X redirects causes control-plane clients to follow redirects, leaking bearer tokens to attacker-controlled endpoints.

- Payout: $1,000
- Severity: medium
- Program: Kubernetes
- Found by (vendor credit): Nicolas Joly, Weinong Wang
- Found by: weinongw
- Disclosed: 2022-12-10
- CVE: CVE-2022-3172
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1544133
- Library page: https://bugbountylibrary.com/r/h1%3A1544133
- Tags: area:cloud domain:cloud domain:infra impact:data-leak impact:internal-access kind:bounty platform:hackerone sev:medium tech:kubernetes technique:recon vuln:secrets-leak vuln:ssrf

**Target:** kube-aggregator / aggregated API server (metrics-server) in kube-system
**Root cause:** Clients calling aggregated APIs follow HTTP redirects returned by the aggregated apiserver, forwarding their Authorization bearer tokens to the redirect target without restriction.
**Steps:**
1. Deploy a pod in kube-system using the same label selector as metrics-server, running a server that returns 30X redirects to an attacker endpoint (`weinong/go-redirect`).
2. Apply `go-redirect.yaml` so the hijacked pod is selected by the metrics-server service.
3. Control-plane components (kube-controller-manager, azurepolicyaddon, cpmonitor) call the metrics API and follow the redirect.
4. Observe requests at attacker endpoint containing `Authorization: Bearer <token>` and User-Agent identifying the caller.
**How found:** Researcher (Nicolas Joly) hypothesized that aggregated API clients follow redirects; tested by deploying a redirecting server under metrics-server's label selector and observing control-plane traffic with tokens.
**Exploitation:** Attacker with ability to run a pod in kube-system matching metrics-server's label selector serves 30X redirects; control-plane clients follow redirect and send their bearer tokens to the attacker's capture server, enabling token theft and potential internal endpoint access.
**Escalation:** Redirected traffic can reach internal/external endpoints, enabling spamming that appears to originate from the cloud provider; tokens may be logged in backend logging systems.
**Insight:** Aggregated API clients trust the apiserver endpoint and follow redirects with credentials attached; test whether label-selector-based service routing lets you impersonate a system component to harvest tokens.

