Privilege escalation in AWS Elastic Kubernetes Service
A low-privileged pod in an EKS cluster could reach the node's EC2 metadata service and obtain the node's IAM token, which EKS exchanges for a Kubernetes system:node token. That token could then be used to request service account tokens bound to other pods on the same node, allowing the attacker to impersonate more privileged workloads and potentially reach cluster-admin.
blog.calif.io
Published on blog.calif.io
An Trinh and Duc Nguyen
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely two design issues combine: pods can reach the node's instance metadata service, and the node's EC2 IAM token is accepted by EKS as a system:node identity that can mint tokens for pods on that node.
Impact
An attacker with only a low-privileged pod could impersonate more privileged pods and potentially take over the whole cluster, and the aws-auth backdoor still works even if the node's IAM role is stripped of permissions.
What the attacker needed
A compromised low-privileged pod; pod can reach node metadata service; a privileged pod on the same node
The fix
AWS should stop pods reaching node metadata (for example by setting the IMDSv2 hop limit to one) and stop exchanging EC2 IAM tokens for system:node tokens; operators should also isolate untrusted pods on separate nodes and restrict the API endpoint.
How it was found
- From the low-privileged pod, request the EC2 metadata IAM access token.
- Exchange that token for an EKS token using the AWS CLI get-token command.
- Use the resulting system:node token to request a service account token bound to a privileged pod on the same node.
- Pivot to the privileged service account and use its permissions on the cluster.
- Insert a new record into the aws-auth configmap mapped to system:masters to keep a backdoor.
- In the update, use the cert-manager service account to create a pod with a privileged service account attached, then patch cluster roles to gain cluster-admin.
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 write-up has not been written yet. The Original tab links to the source.
Kubernetes runs workloads in containers called pods, and each pod sits on a worker machine (a node). The node has an AWS identity that lets it talk to AWS services, and the report shows a pod can ask the node's metadata service for that identity. With it, the attacker can pretend to be other pods on the same machine and borrow their higher permissions.
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.