A monitoring agent or a script gets 403 on nodes/proxy, and the obvious reaction is to grant it. Careful: exec and log also run through the kubelet proxy. Whoever has nodes/proxy is effectively root in every container of the cluster.
Symptom
AS="--as=system:serviceaccount:attacker:default" kubectl $AS get --raw "/api/v1/nodes/rke2-agent1/proxy/pods" Error from server (Forbidden): nodes "rke2-agent1" is forbidden: User "system:serviceaccount:attacker:default" cannot get resource "nodes/proxy" in API group ""
A service account queries the pod list through a node's kubelet proxy.
Diagnosis
Check who may use nodes/proxy – apart from the control plane, nobody should get yes.
kubectl auth can-i get nodes/proxy --as=system:serviceaccount:attacker:default
Causes
RBACnodes/proxy is not granted
The account has no get on nodes/proxy. In the course this is exactly the state after the fix: with the permission an attacker had read a database password from a foreign namespace.
kubeletDirect kubelet access is closed too
Anonymously, the kubelet answers 401 – the proxy through the API server was the real path.
kubectl -n attacker exec shell -- curl -s -k -o /dev/null -w "%{http_code}\n" \
--max-time 5 https://172.16.0.228:10250/podsFix
Don't: Do not hand nodes/proxy to workloads or teams through a broad cluster role – exec and log into every container run through it.
Attacking and securing Kubernetes, Day 7: the kubelet – anonymous access, nodes/proxy and why it is so powerful.
Go to day 7 →
FAQ
What does the course's checkpoint expect?
kubectl auth can-i get nodes/proxy for the attacker account returns no.
Is the kubelet on port 10250 reachable without a token?
Not in the course: anonymously it answers 401.