Skip to content
DoS Disclosed report Intermediate

"Self" DOS with large deployment and scaling

A deployment with many environment variables can be scaled up and down repeatedly to cause excessive CPU and memory usage in the Kubernetes API server and etcd, potentially making the cluster unresponsive. The reporter's own cluster became unusable after running the scaling loop.

wiardvanrij Follow

Originally disclosed on HackerOne

  • Triaged in 12 days
  • Disclosed after 4 months

Report Submission Form

Summary:

Good day! I was just messing around with some functions and trying to see what the impact was on my cluster. I found out that it took quite some resources to process a larger deployment, especially when scaling it. When I check your security release process I noticed that it did include "Authenticated User" - DOS (https://github.com/kubernetes/security/blob/master/security-release-process.md#denial-of-service) so I figured I should just make a report of this.

The summary is:

When you define a deployment that contains loads of env variables, we can easily increase the size of what is being processed. When we start to scale & downscale this deployment, we get a massive increase in the API/ETCD memory & CPU usage.

In my case, I literally ruined my cluster that consists of 3 master nodes (4 vCPUs, 15 GB memory each)

Kubernetes Version:

1.15.10

Component Version:

Steps To Reproduce:

Short story:

  1. Create a deployment that is near to the max chars allowed with env vars.
  2. Scale it to N-number of nodes where N could be "whatever" - I've tested it with 99 nodes and 999, both seem to be increasing cluster usage
  3. Scale it back down to 1
  4. Repeat for a while.

Long story:

1 Create a deployment

Please check out my example deployment file here: https://gist.github.com/wiardvanrij/21e516993603282e174da399002d95a3 As it is really huge. It is good to note that I just used a random image and defined really low cpu/mem limits in order to allow many pods to get created without hitting some cluster/node limit

2 Save this as scale.json

{
    "kind": "Scale",
    "apiVersion": "autoscaling/v1",
    "metadata": {
      "name": "nginx",
      "namespace": "default"
    },
    "spec": {
      "replicas": 999
    }
}  

3 And save this as scaledown.json

{
    "kind": "Scale",
    "apiVersion": "autoscaling/v1",
    "metadata": {
      "name": "nginx",
      "namespace": "default"
    },
    "spec": {
      "replicas": 1
    }
}  

4 create a run.sh

curl -X PUT 127.0.0.1:8001/apis/apps/v1/namespaces/default/deployments/nginx/scale -H "Content-Type: application/json" -d @scale.json
curl -X PUT 127.0.0.1:8001/apis/apps/v1/namespaces/default/deployments/nginx/scale -H "Content-Type: application/json" -d @scaledown.json
curl -X PUT 127.0.0.1:8001/apis/apps/v1/namespaces/default/deployments/nginx/scale -H "Content-Type: application/json" -d @scale.json
curl -X PUT 127.0.0.1:8001/apis/apps/v1/namespaces/default/deployments/nginx/scale -H "Content-Type: application/json" -d @scaledown.json
curl -X PUT 127.0.0.1:8001/apis/apps/v1/namespaces/default/deployments/nginx/scale -H "Content-Type: application/json" -d @scale.json
curl -X PUT 127.0.0.1:8001/apis/apps/v1/namespaces/default/deployments/nginx/scale -H "Content-Type: application/json" -d @scaledown.json
... repeat above for a bunch of times (50x or so).

5 I've used kube proxy for easy access

run kubectl proxy to make a proxy to your cluster

6 run the run.sh file ./run.sh and optionally you could run this multiple times for some "concurrency"

7 What you could see

Massive usage in CPU power on the master nodes AND memory usage on for certain the API part of k8s, perhaps the nodes too, but I lost control of everything to see exactly what went down. Eventually, you should not able to contact your cluster anymore and the nodes remain unresponsive/heavy throttled.

Notes

This feels really "basic" as for a DOS, though I really wanted to point something out. I was actually learning deeper internals of k8s and I just made this "work" when I saw some spikes in my metrics. Therefore I wanted to make the note that:

  • I actually made my cluster completely useless with this, but I'm uncertain if the ENV vars and/or the scaling are the sole reason.
  • I've got no idea what is really happening, because even when I stopped my "script" - the entire cluster was still unresponsive.
  • I've first tested this locally with KIND, and used KOPS to set up a "production like" cluster, and even with 3 somewhat decent master nodes, it was gone in minutes.

Supporting Material/References:

Deployment file: https://gist.github.com/wiardvanrij/21e516993603282e174da399002d95a3

Impact

DOS on the entire k8s cluster.

The original report as published on HackerOne, by wiardvanrij. 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 control plane processes the large deployment object on every scale operation without sufficient rate limiting or resource bounds, so repeated scaling causes excessive load on the API server and etcd.

Impact

An authenticated user could cause a denial of service on the entire Kubernetes cluster, making it unresponsive.

What the attacker needed

Authenticated user with permission to create deployments; ability to scale deployments; access to the Kubernetes API

How it was found

  1. Create a deployment with environment variables near the maximum allowed size.
  2. Scale the deployment up to a large number of replicas (e.g., 99 or 999).
  3. Scale it back down to 1 replica.
  4. Repeat the scale up and down many times (e.g., 50 times).
  5. Observe high CPU and memory usage on the master nodes and API server, leading to cluster unresponsiveness.

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.

Kubernetes is a system for running containerised applications. A deployment describes how many copies of an application should run. The report says that if a deployment has a very large number of environment variables (settings passed to the container), then rapidly changing the number of copies forces the cluster's control plane to do a lot of work, which can overwhelm it and make the whole cluster stop responding.

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.

More from Kubernetes

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.