Kubelet resource exhaustion attack via metric label cardinality explosion from unauthenticated requests
The kubelet records a metrics label containing the request path for every HTTP request, even unauthenticated ones, and each unique path creates 16 new time series. An attacker sending many requests with random paths could grow kubelet memory until it is OOM killed or evicts workloads.
Originally disclosed on HackerOne
- Triaged in under an hour
- Fixed in 3 months
- Paid in 20 days
- Disclosed after 10 months
Report Submission Form
Summary:
Malicious clients can potentially DOS a kubelet by sending a high amount of specially crafted requests to the kubelet's HTTP server.
For each request the kubelet updates/sets 3 metrics:
- kubelet_http_requests_total (Counter)
- kubelet_http_requests_duration_seconds (Histogram with 7 buckets)
- kubelet_http_inflight_requests (Counter)
Each metric has the label path which will contain the path of each request.
It does not matter if the request is authenticated or not - The metrics will be set/updated regardless.
With each unique path, the kubelet creates 16 new time series.
By sending a high amount of requests with random path values, the kubelet's memory usage will grow and eventually the kubelet will get OOM killed.
It's also possible that the kubelet evicts all workloads before being OOM killed (Which might be worse than an OOM kill)
The corresponding kubelet server code: https://github.com/kubernetes/kubernetes/blob/v1.17.0/pkg/kubelet/server/server.go#L859-L865
Kubernetes Version:
- v1.17.0 kubeadm (tested)
- v1.16.4 kubeadm (tested)
- v1.15.7 kubeadm (tested)
Component Version:
Kubelet
Steps To Reproduce:
NODE_NAME="my-poor-node"
NODE_IP="192.168.1.100"
# Perform random requests from an unauthenticated client
curl --insecure https://${NODE_IP}:10250/foo
curl --insecure https://${NODE_IP}:10250/bar
curl --insecure https://${NODE_IP}:10250/baz
# Run in a dedicated shell to be able to get the metrics
kubectl proxy
# Load metrics from node
# For each path (foo, bar, baz) 16 time series got created
curl http://127.0.0.1:8001/api/v1/nodes/${NODE_NAME}/proxy/metrics 2>&1 | grep 'kubelet_http_requests_total\|kubelet_http_requests_duration_seconds\|kubelet_http_inflight_requests'
# Perform more random requests & see the output of the metrics endpoint to grow.
Supporting Material/References:
A gist with an additional go tool which spams the kubelet https://gist.github.com/mrIncompetent/c6cbe483298c36668374363baf52a35d
Impact
Kill the kubelet / Make the kubelet consume all resources so it starts to evict pods.
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 metrics label uses the raw, unbounded request path, so every distinct path creates new time series that are never cleaned up.
Impact
The kubelet could be OOM killed, or it may evict all workloads before that happens.
What the attacker needed
Network access to kubelet port 10250; no authentication needed
How it was found
- Send requests with different random paths to the kubelet's HTTPS port from an unauthenticated client.
- Use kubectl proxy to reach the node's metrics endpoint.
- Load the metrics and observe that each path created 16 time series.
- Send more random requests and watch the metrics output grow.
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.
The kubelet is the agent on each Kubernetes node. It keeps metrics about incoming web requests, labelled with the request's path. Anyone who can reach the port can send requests with made-up paths, and each new path adds 16 time series, so flooding it with random paths can exhaust memory and crash the node agent.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.