Skip to content
SSRF Disclosed report Advanced CVE-2022-3172

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

When an aggregated API server such as metrics-server is hijacked and returns a 30X redirect, clients calling the metrics API follow the redirect, sending their bearer tokens to the attacker's endpoint. This could expose credentials and allow traffic to be redirected to internal or external endpoints.

weinongw Follow

Originally disclosed on HackerOne

Bounty$1,000 Medium View original
  • Fixed in 7 months
  • Paid in 7 months
  • Disclosed after 8 months

Report Submission Form

Summary:

This report uses metrics-server as example, but it should be applicable to any aggregated api server.

When metrics-server is hijacked, either by modifying the container image directly or by running another pods using the same label selector in kube-system namespace, and is returning 30X redirect, the clients calling the metrics api will follow the redirect.

It could be a serious issue in managed Kubernetes offerings such as Azure Kubernetes Service (AKS) where clients from managed components may be redirected to call the internal endpoints.

Note: my coworker, Nicolas Joly, found the issue and reported my team (AKS)

Kubernetes Version:

all k8s versions on AKS. I believe it's the same in other cloud providers.

Component Version:

n/a

Steps To Reproduce:

  • Attached main.go is a very simple redirection api server. I've built the docker image on weinong/go-redirect.
  • update and deploy go-redirect.yaml with your endpoint to capture the redirected traffic in kube-system namespace. It uses the same pod label selector as metrics-server does
  • you should be able to observe redirected traffic from the control plane components

Supporting Material/References:

Sample output being logged in the web server capturing redirected traffic:

2022/04/16 00:30:13 src IP: 20.51.80.40:4096
GET / HTTP/1.1
Host: 20.85.59.5
Accept: application/json, */*
Accept-Encoding: gzip
Authorization: Bearer <omitted>
User-Agent: azurepolicyaddon/v0.0.0 (linux/amd64) kubernetes/$Format

GET / HTTP/1.1
Host: 20.85.59.5
Accept: application/vnd.kubernetes.protobuf, */*
Authorization: Bearer <omitted>
User-Agent: kube-controller-manager/v1.17.13 (linux/amd64) kubernetes/f4a8e76/system:serviceaccount:kube-system:generic-garbage-collector

2022/04/16 00:34:37 src IP: 20.69.190.88:21504
GET / HTTP/1.1
Host: 20.85.59.5
Accept: application/json, */*
Accept-Encoding: gzip
Authorization: Bearer  <omitted>
User-Agent: cpmonitor/v0.0.0 (linux/amd64) kubernetes/$Format
  • [attachment / reference]

Impact

  • Bearer token may be logged in the logging system in those internal backend
  • Potentially, they may be logged by kube-controller-manager or kubernetes api-server at certain verbose level (not verified)
  • Redirected traffic may hit external/internal endpoints for spamming which would look originating from the cloud providers

The original report as published on HackerOne, by weinongw. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the Kubernetes API server and other control-plane clients follow HTTP redirects from aggregated API servers without restricting where they can redirect to, so a hijacked server can send credentials to an arbitrary destination.

Impact

Bearer tokens may be logged by the attacker's endpoint, and redirected traffic could be used to spam internal or external endpoints while appearing to originate from the cloud provider.

What the attacker needed

Ability to hijack an aggregated API server; hijacked server returns 30X redirect

How it was found

  1. Build a simple redirection API server.
  2. Deploy it in kube-system with the same pod label selector as metrics-server.
  3. Observe redirected traffic from control plane components arriving at the capture endpoint.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

An aggregated API server is an extra service that the main Kubernetes API server forwards certain requests to, like metrics-server for resource usage. If an attacker can replace that service with one that sends a redirect response, the clients that trust it will follow the redirect and include their login token, handing it to the attacker.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More from Kubernetes

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.