AWS Chain Attack- Thousands of Vulnerable EKS Clusters
The report describes a chain attack in AWS EKS where an attacker with limited access to a container can use the instance metadata service to obtain the node's EC2 role, then use that role to generate a kubeconfig and access the cluster API, ultimately deploying a privileged pod to escape to the node and access other containers' data. The author claims this works by default in EKS environments without third-party security products.
Published on medium.com
The attack vector I have identified allows attackers with limited access (i.e., non-root) to a secured pod to move laterally and gain access to privileged KubeAPI in Kubernetes environments without third-party security products.
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.
Context
This research looks at Amazon Elastic Kubernetes Service (EKS) and the attack methodology the author developed against it. The claim is that AWS Kubernetes environments without third-party security products are vulnerable by default, and that two zero-day vulnerabilities found during the research break the pod isolation mechanism. The chain exploits the Kubernetes orchestration of AWS cloud, specifically EKS.
The attack vector allows an attacker with limited access (non-root) to a secured pod to move laterally and gain access to a privileged KubeAPI in Kubernetes environments without third-party security products. The author describes the impact as reading and modifying data stored and accessible from other containers and services, and takeover of the cluster, which enables access to data from all containers, including secrets and storage.
The attack is built on two vulnerabilities:
- The EC2 VM Role (the role of the node) is accessible from the containers.
- In the Kubernetes environment, the role has privileges to generate a new kubeconfig. In addition, it has permissions to the whole cluster with a bypass.
Setup
The attack chain has several stages that need attention: AWS Cloud, EKS architecture, node, container, and app users.

The proof of concept uses two namespaces, backend and frontend. The starting position is access to the frontend container as a non-root user with limited permissions, without access to the cloud or to k8s.

Attack Flow
Finding it
Instance metadata is data about an instance that can be used to configure or manage the running instance. The IMDS is divided into categories such as host name, events and security groups, and the author considers it a powerful attack vector.
While assessing AWS Elastic Kubernetes Services cluster mechanisms, the author found several cloud services of the node instance accessible from the container, and that using API token creation can lead to lateral movement. From the container, the instance metadata endpoint gives detailed information about the running context: the ARN, labels, networking and details about the instance.
Exploitation
Step 1: request a token from the frontend container
From the frontend container, the first action is to request a token from the metadata server.

Figure 1: Request to the metadata server to get a temporary token from the frontend
Step 2: use the token to read node information
The token is then used to access information about the cloud environment and the node.

Figure 2: Using the token to get information about the node
The author developed a script that uses metadata queries to obtain network information about node instances in a cluster without performing a network scan. The script first retrieves the MAC addresses of the node instances, then generates a request for information based on the MAC address. This retrieves information on the relevant subnets and security groups, node names, cluster names, cluster host names and other relevant details.

Figure 3: Executing the script, which shows information about the cluster and other namespaces using the security groups (it utilises the MAC address and metadata)
Step 3: retrieve the EC2 instance role
The EC2 Instance Role grants an instance access to a specific set of IAM credentials and, depending on the policies associated with the role, may also allow access to various AWS services.
To retrieve the EC2 role of a node, a request is sent to the metadata service. Adding the token to the request yields the privileged role of the instance. Without the token, the usual result is an unprivileged role.

Figure 4: The EC2 host role cloud profile info

Figure 5: Generating a request to retrieve the EC2 role (node) using the temporary token
Step 4: use the role and work around listing restrictions
With the role in hand, the author used an open source tool called Pacu to access the AWS UI with the credentials. Access was very limited, so the research continued for another vector.

Figure 6: AWS Cloud UI account access using the role
In the default configuration most listing permissions are restricted, so users do not have access to detailed information about instances or databases unless explicitly granted. The author's attempts to obtain details about instances and databases failed because the necessary permissions were missing, confirming the default restrictions were in place.
Despite those restrictions, the Describe-tags functionality was usable. It allowed listing the tags of all resources in the cloud environment, including the cluster name, namespaces (via security groups default tags), cloud components and more. This bypass gave information about almost all components in the environment despite the default role permissions and restrictions, and that information is needed later.

Figure 7: Listing tags from all environments, showing resource ID, type and even names of every cloud component in the cluster
Step 5: generate a new kubeconfig
Although the default role permissions did not include write or list permissions for components or access to cloud components, the role did have permissions to generate a new kubeconfig file. The file can be generated using the cluster name identified earlier.
Kubernetes uses a YAML file known as kube-config to store cluster authentication information for kubectl. It can be used to authenticate with the cluster kubeAPI either by sending a custom POST request or by using the kubectl binary. The author used the update-kubeconfig command to generate a kube-config file by specifying the role and cluster name.

Figure 8: Generating a new kube-config to the target cluster

Figure 9: Although the user lacks permission to list namespaces directly, get services can be used to identify them
Typically most namespaces in real-world environments have at least one service configured, but that was not the case here. Since the API did not have sufficient RBAC permissions to list namespaces, the author needed a workaround. To obtain the names of each namespace, the list services command was used with the --all-namespaces flag together with the security group tags.

Figure 10: All services on the cluster and open ports (without an active scan), with the namespace names on the left
With the namespaces listed, the next step was retrieving information about the pods and config files of those namespaces.

Figure 11: Listing pods of the backend containers
Step 6: read the Kubernetes manifest
The author obtained all information about the pods, including the container internal specification of commands and environment variables, using the Kubernetes manifest.

Figure 12: Listing the information and configurations of relevant components in the Kubernetes orchestration
Access to the Kubernetes manifest of all pods allows access to the environment variables that usually contain secrets and information about services and sensitive systems.
Step 7: access pods and other namespaces
Connecting into pods was a challenge because the author did not have permission to exec into them, but a bypass was found. Connection to the pods was achieved with the YAML below, since the role has permissions to create pods.

In most environments the role has exec privileges for monitoring and log collection services such as Prisma, which results in takeover of every namespace in the pod. In the case of a hardened RBAC on the role, only creation of mirror pods is available: special pods created by Kubernetes itself for internal purposes. A potential bypass in that case is to create a new pod and set the mirror field in the pod's annotations to true, which allows access to the target node and ultimately the pods.
Step 8: create a vulnerable container and break out to the node
The author built an image with a Docker file with SSH configured. The Docker file copies a public key from the host for SSH login. The local vulnerable image sits in a local registry on the attacker's endpoint computer, started with:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
A deployment named vulnv3.yaml was created. The new privileged pod has port 22 open and the deployment downloads the author's image. The node of the deployment is the node of the target namespace. The vulnerable pod:
apiVersion: v1kind: Podmetadata: name: vulnerable-mirror-pod namespace: ui-systemsspec: nodeName: 7931b048-dfa4-40f7-80f1-e4761226a673 nodeSelector: kubernetes.io/hostname: ip-192-168-28-94.[redacted] containers: - name: vulnerable-mirror-pod image: localhost:5000/vulnpod:v2 volumeMounts: - name: docker-sock mountPath: /var/run/docker.sock securityContext: privileged: true ports: - containerPort: 22 env: - name: MY_ENV_VAR value: "my_value" volumes: - name: docker-sock hostPath: path: /var/run/docker.sock
After the SSH step, the breakout to the node is done with the following commands:
df -hCopy /dev/<host device>chroot /hostsys /bin/bash
The author summarises this stage as: deploying a container to the target node, adding the SYS_Admin capability, which makes the container vulnerable to a breakout, then connecting to the pod, exploiting the container breakout vulnerability and gaining access to the node. From there, access to pods of every namespace on the node was achieved, and pods can be entered using regular docker commands. At that point all container information is available: stored data, secrets and database authentication (if a secret manager is not in use, and if it is in use it can usually be connected with the pod access).
Root cause
The chain rests on two vulnerabilities in the EKS implementation. First, the EC2 VM role of the node is reachable from the containers through the instance metadata service, and a token obtained from the metadata server is enough to retrieve the privileged role. Second, the role, even at its minimal permission set, can generate a new kubeconfig for the cluster, and it holds cluster permissions that can be reached through bypasses: Describe-tags for enumeration when listing is denied, list services --all-namespaces when namespace listing is denied, and pod creation when exec is denied.
The author states that these risks do not exist in official Kubernetes or major cloud Kubernetes services because the vectors were the result of non-standard, insecure implementations. The default restrictions on listing permissions did not stop the chain because the bypasses above only need calls that remain available on the minimal role.
Impact
An attacker with limited, non-root access to a single secured pod can move laterally, reach the privileged KubeAPI, and take over the cluster. That gives access to data from all containers, including secrets and storage, and to environment variables in the Kubernetes manifests that usually contain secrets and information about services and sensitive systems. The author notes the exposure can include personally identifiable information, financial information and other sensitive data, with consequences such as financial loss, legal penalties and reputational damage, and non-compliance with regulations governing the handling of such data.
The exec risk depends on the environment: where the role has exec privileges for monitoring and log collection services such as Prisma, every namespace in the pod can be taken over; with a hardened RBAC only mirror pod creation remains, and the mirror annotation bypass applies. Takeover via vulnerable pod deployment depends on the RBAC.
Fix
The author states that it is not possible to remove some permissions of the EC2 role, but access to retrieve it can be limited using IP rules from the containers. The recommended practices are:
- Implement IP rules from the containers and block insecure metadata services from the containers.
- Change the EC2 instance IAM role permissions; the minimal permissions are vulnerable.
- Consider a third-party protection service to secure the environment.
Variants to test
- Metadata reachability from a pod: request a token from the metadata server from a non-root container and then query node information with it. A positive result is a token being issued and node details such as ARN, labels and networking coming back.
- Role retrieval with and without the token: request the EC2 role from the metadata service both ways. A positive result is the privileged role being returned when the token is added, against an unprivileged role without it.
- Tag enumeration under restricted listing: call
Describe-tagswith the role when instance and database listing is denied. A positive result is cluster names, namespaces and cloud component names appearing in the tags. - Kubeconfig generation on a minimal role: run
update-kubeconfigwith the role and cluster name. A positive result is a working config that authenticates to the kubeAPI. - Namespace discovery without list permission: run
list serviceswith--all-namespacesand correlate with security group tags. A positive result is namespace names and services with open ports appearing without an active scan. - Pod creation when exec is denied: create a pod, and where RBAC is hardened set the
mirrorannotation totrue. A positive result is a pod scheduled on the target node, reachable over SSH, from which the host can be reached through the breakout commands.
What happened, in plain words
Imagine a large office building. Each company in the building rents a small locked room (a container), and all the rooms sit inside one shared floor (a node, which is a computer). The building manager (Amazon Web Services, or AWS) runs the floor. A separate system (Kubernetes) decides which room each company gets and what each room is allowed to do.
A researcher looked at how AWS runs this kind of building, specifically a service called Amazon Elastic Kubernetes Service, or EKS. He found that someone locked inside one small room, with no special rights, could quietly walk out into the corridor, find the building manager's master keys, and then open every other room on the floor. He called this a chain attack, because it is a series of small steps, each one making the next possible, like a chain of dominoes.
He says he found two zero-day vulnerabilities. A zero-day is a security flaw that the maker does not know about yet, so there is no fix available at the time it is found. Both flaws break pod isolation. A pod is Kubernetes' word for the smallest unit it runs, usually one container plus a little setup around it. Isolation means one pod should not be able to reach into another.
The researcher's claim is that AWS Kubernetes environments are vulnerable by default if you do not add a third-party security product. A third-party security product is extra protection software from a company other than AWS, bolted on top.
The attack lets someone with limited access (not an administrator, just an ordinary user inside one pod) move sideways to other systems. Lateral movement is exactly that: going from one place you are allowed to be into places you are not. The end result is access to the KubeAPI, the control panel of the Kubernetes cluster, with high privileges. From there the attacker can read and change data in other containers and services, and take over the whole cluster. That includes secrets (passwords, keys and tokens stored for applications to use) and storage.
In his view the problems came from non-standard, insecure implementations specific to this setup, and without those flaws the Kubernetes features involved would not be dangerous.
The whole thing rests on two flaws:
- The EC2 VM Role (the identity and permissions given to the node, the shared floor computer) can be reached from inside the containers.
- In this Kubernetes environment, that role is allowed to generate a new kubeconfig (a login file for the cluster). On top of that, the role has permissions across the whole cluster that can be reached by going around the normal restrictions.
The pieces of the puzzle
The author says the attack chain has several stages you need to understand: the AWS Cloud, the EKS architecture, the node, the container, and the app users.

A quick word on each, from zero:
- AWS Cloud: Amazon's collection of rented computers and services, accessed over the internet.
- EKS architecture: the way AWS arranges Kubernetes for you. Kubernetes is software that runs and organises many containers across many machines.
- Node: one physical or virtual computer in the cluster. Containers run on nodes.
- Container: a packaged, isolated running application. Think of a shipping container: standard, sealed, and holding one thing.
- App users: the people using the application, at the far end of the chain.
For the demonstration (a proof of concept, or PoC: a small experiment that proves the problem is real), the author set up two namespaces, called backend and frontend. A namespace is a labelled area inside a cluster used to group related things, like folders on a computer. His starting position was access to the frontend container as a non-root user with limited permissions, with no access to the cloud and no access to Kubernetes.

Attack Flow
That starting position matters. He is not an administrator. He is like a temporary worker who has been given a login to one application and nothing else.
Finding it
Every rented computer in the cloud has a small built-in information desk called the instance metadata service, or IMDS. Instance metadata is data about the machine itself: its name, its network settings, its security groups (firewall rules), and so on. You can use it to configure or manage the running machine. The IMDS is organised into categories such as host name, events and security groups, and the author treats it as a powerful attack vector. An attack vector is simply the route an attacker uses to get in.
While assessing how EKS clusters work, he found that several cloud services belonging to the node were reachable from inside the container. He also found that creating an API token there could lead to lateral movement.
Two terms to unpack:
- API: an Application Programming Interface is the set of doors a program offers so other programs can ask it to do things. A restaurant menu is a fair comparison: it lists what you can order and how to order it, without you entering the kitchen.
- Token: a short-lived string of characters that proves who you are, a bit like a cloakroom ticket. You show it, and you get your coat. It expires, so it is safer than a permanent password.
From inside the container, the metadata endpoint gave detailed information about the running context: the ARN (Amazon Resource Name, a unique ID string for a resource), labels, networking details and information about the instance.
Exploitation
Step 1: request a token from the frontend container
From the frontend container, the first action is to ask the metadata server for a token.

Figure 1: Request to the metadata server to get a temporary token from the frontend
Why start here? Because the metadata service is reachable from inside the container, and a token is the key that unlocks the more sensitive parts of that service. Without a token, the service gives much less away.
Step 2: use the token to read node information
The token is then used to read information about the cloud environment and the node.

Figure 2: Using the token to get information about the node
The author wrote a script that uses metadata queries to gather network information about node instances without performing a network scan. A network scan is when you probe many addresses to see what answers, which is noisy and easy to notice. His approach is quieter: ask the machine about itself.
The script first retrieves the MAC addresses of the node instances. A MAC address is the hardware address of a network card, a fixed identifier like a serial number. Then it builds a request for information based on that MAC address. This returns the relevant subnets (ranges of network addresses, like a street of house numbers) and security groups (firewall rule sets), node names, cluster names, cluster host names and other details.

Figure 3: Executing the script, which shows information about the cluster and other namespaces using the security groups (it utilises the MAC address and metadata)
Why does this matter? Because knowing the layout of the network and the names of things is the groundwork for every later step. You cannot ask for a cluster's login file if you do not know the cluster's name.
Step 3: retrieve the EC2 instance role
An EC2 Instance Role is an identity attached to a machine. EC2 is Amazon's service for renting virtual computers. A role is a bundle of permissions, like a staff badge that opens certain doors. The role grants the instance access to a specific set of IAM credentials. IAM stands for Identity and Access Management, AWS's system for who can do what. Depending on the policies attached to the role (the written rules), it may also allow access to various AWS services.
To retrieve the EC2 role of a node, a request is sent to the metadata service. Adding the token to the request yields the privileged role of the instance. Without the token, the usual result is an unprivileged role.

Figure 4: The EC2 host role cloud profile info

Figure 5: Generating a request to retrieve the EC2 role (node) using the temporary token
This is the heart of the first vulnerability. The machine's own powerful identity is handed out to anyone who can reach the metadata service from inside a container. It is like a hotel room phone that, if you dial a certain number, reads out the master key code.
Step 4: use the role and work around listing restrictions
With the role in hand, the author used an open source tool called Pacu to access the AWS UI with the credentials. Pacu is a tool built for testing AWS environments. Access was very limited, so the research continued for another route in.

Figure 6: AWS Cloud UI account access using the role
In the default configuration most listing permissions are restricted. That means users cannot see detailed information about instances or databases unless someone explicitly granted that permission. His attempts to get details about instances and databases failed because the necessary permissions were missing, which confirmed the default restrictions were in place.
But one function still worked: Describe-tags. A tag is a label attached to a cloud resource, like a sticky note saying what it is and who owns it. Describe-tags lists those labels for all resources in the cloud environment, including the cluster name, namespaces (through the default tags on security groups), cloud components and more.

Figure 7: Listing tags from all environments, showing resource ID, type and even names of every cloud component in the cluster
This is a bypass: a way around a restriction without breaking it. The front door was locked, but the labels on the boxes were readable through the window. It gave him information about almost all components in the environment despite the default role permissions, and that information is needed later.
Step 5: generate a new kubeconfig
The default role permissions did not include write or list permissions for components, nor access to cloud components. But the role did have permission to generate a new kubeconfig file, and that file can be generated using the cluster name identified earlier.
Kubernetes uses a YAML file known as kube-config to store cluster authentication information for kubectl. YAML is a plain-text format for configuration, written as indented lists and key-value pairs. kubectl is the command-line tool for talking to a Kubernetes cluster. The config file can be used to authenticate with the cluster kubeAPI either by sending a custom POST request or by using the kubectl binary. A POST request is an HTTP request that sends data to a server, as opposed to a GET request that just asks for something.
The author used the update-kubeconfig command to generate a kube-config file by specifying the role and cluster name.

Figure 8: Generating a new kube-config to the target cluster

Figure 9: Although the user lacks permission to list namespaces directly, get services can be used to identify them
Normally, most namespaces in real environments have at least one service configured. A service in Kubernetes is a stable network address in front of a set of pods, so other things can reach them without knowing exactly where they run. But that was not the case here.
Since the API did not have sufficient RBAC permissions to list namespaces, he needed a workaround. RBAC stands for Role-Based Access Control: permissions granted according to a role. To obtain the names of each namespace, he used the list services command with the --all-namespaces flag together with the security group tags.

Figure 10: All services on the cluster and open ports (without an active scan), with the namespace names on the left
With the namespaces listed, the next step was retrieving information about the pods and config files of those namespaces.

Figure 11: Listing pods of the backend containers
Again, the pattern repeats: a permission was missing, and a neighbouring permission that was still available revealed the same information indirectly.
Step 6: read the Kubernetes manifest
The author obtained all information about the pods, including the container's internal specification of commands and environment variables, using the Kubernetes manifest. A manifest is the written definition of what a pod should look like and how it should run. Environment variables are named values passed into a program when it starts, and they are a very common place to keep configuration and secrets.

Figure 12: Listing the information and configurations of relevant components in the Kubernetes orchestration
Access to the Kubernetes manifest of all pods allows access to the environment variables that usually contain secrets and information about services and sensitive systems. In everyday terms: the manifest is the recipe card for each container, and people often write the safe combination on the recipe card.
Step 7: access pods and other namespaces
Connecting into pods was a challenge because the author did not have permission to exec into them. To exec means to run a command inside a running container, like opening a terminal on someone else's computer. But a bypass was found. Connection to the pods was achieved with the YAML below, since the role has permissions to create pods.

In most environments the role has exec privileges for monitoring and log collection services such as Prisma. That results in takeover of every namespace in the pod. In the case of a hardened RBAC on the role, only creation of mirror pods is available. Mirror pods are special pods created by Kubernetes itself for internal purposes. A potential bypass in that case is to create a new pod and set the mirror field in the pod's annotations to true, which allows access to the target node and ultimately the pods.
An annotation is a small piece of extra information attached to an object, like a note stuck to a folder. Setting it to true makes Kubernetes treat the pod as one of its own internal ones, which is the trick.
Step 8: create a vulnerable container and break out to the node
The author built an image with a Docker file with SSH configured. An image is a template for a container, and a Docker file is the recipe used to build that image. SSH is the standard way to log in to another computer over the network with a secure, encrypted connection. The Docker file copies a public key from the host for SSH login. Public key login is a pair of keys: one public, one private. The public one is placed on the machine you want to reach, and the private one stays with you, so you can log in without typing a password.
The local vulnerable image sits in a local registry on the attacker's endpoint computer, started with:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
Line by line:
docker runstarts a container from an image.-dmeans detached: run it in the background.-p 5000:5000maps port 5000 on your computer to port 5000 inside the container. A port is a numbered doorway on a computer that a service listens on.--restart=alwaysrestarts the container automatically if it stops.--name registrygives the container the nameregistry.registry:2is the image to run: the official Docker registry software, version 2.
A registry is a storage service for container images, like an app store for containers.
A deployment named vulnv3.yaml was created. A deployment is a Kubernetes instruction that says which pods to run and keeps them running. The new privileged pod has port 22 open (the standard SSH port) and the deployment downloads the author's image. The node of the deployment is the node of the target namespace. The vulnerable pod:
apiVersion: v1kind: Podmetadata: name: vulnerable-mirror-pod namespace: ui-systemsspec: nodeName: 7931b048-dfa4-40f7-80f1-e4761226a673 nodeSelector: kubernetes.io/hostname: ip-192-168-28-94.[redacted] containers: - name: vulnerable-mirror-pod image: localhost:5000/vulnpod:v2 volumeMounts: - name: docker-sock mountPath: /var/run/docker.sock securityContext: privileged: true ports: - containerPort: 22 env: - name: MY_ENV_VAR value: "my_value" volumes: - name: docker-sock hostPath: path: /var/run/docker.sock
Line by line, in plain words:
apiVersion: v1says which version of the Kubernetes object format this file uses.kind: Podsays the object being defined is a pod.metadata:starts the descriptive section.name: vulnerable-mirror-podis the pod's name.namespace: ui-systemsis the area it is placed in.spec:starts the section describing what the pod should actually do.nodeName: 7931b048-dfa4-40f7-80f1-e4761226a673pins the pod to one specific node by its identifier.nodeSelector:adds a label-based rule for choosing the node.kubernetes.io/hostname: ip-192-168-28-94.[redacted]is the hostname label the node must have.containers:begins the list of containers in the pod.- name: vulnerable-mirror-podnames the container.image: localhost:5000/vulnpod:v2says to pull the image from the local registry on port 5000, tagv2.volumeMounts:lists storage to attach inside the container.- name: docker-sockrefers to a volume nameddocker-sock.mountPath: /var/run/docker.sockplaces it at that path inside the container. This is the Docker control socket, the channel used to talk to the Docker daemon, the program that manages containers.securityContext:sets security settings for the container.privileged: truegives the container almost all the powers of the host machine. This is the dangerous part.ports:lists the ports the container exposes.- containerPort: 22opens port 22, the SSH port.env:lists environment variables.- name: MY_ENV_VARandvalue: "my_value"are a placeholder variable and value.volumes:defines the storage used by the pod.- name: docker-socknames the volume.hostPath:says the volume comes from the host machine's filesystem.path: /var/run/docker.sockis the host path being mounted, the Docker socket again.
After the SSH step, the breakout to the node is done with the following commands:
df -hCopy /dev/<host device>chroot /hostsys /bin/bash
Line by line:
df -hshows disk usage in human-readable sizes. It is a way to look around the host's filesystem.Copy /dev/<host device>refers to copying a host device. The angle brackets are a placeholder for the device name.chroot /hostsys /bin/bashchanges the apparent root directory to/hostsysand starts a shell there.chrootmeans change root: it makes a directory look like the top of the filesystem. Starting/bin/bashinside it gives a shell that sees the host's files as its own. That is the escape.
The author summarises this stage as: deploying a container to the target node, adding the SYS_Admin capability, which makes the container vulnerable to a breakout, then connecting to the pod, exploiting the container breakout vulnerability and gaining access to the node. A capability is a specific slice of the root user's powers, handed out individually. From there, access to pods of every namespace on the node was achieved, and pods can be entered using regular docker commands. At that point all container information is available: stored data, secrets and database authentication. If a secret manager (a dedicated service for storing secrets) is not in use, the secrets are simply there; if it is in use, it can usually be connected with the pod access.
Root cause
The chain rests on two vulnerabilities in the EKS implementation. First, the EC2 VM role of the node is reachable from the containers through the instance metadata service, and a token obtained from the metadata server is enough to retrieve the privileged role. Second, the role, even at its minimal permission set, can generate a new kubeconfig for the cluster, and it holds cluster permissions that can be reached through bypasses: Describe-tags for enumeration when listing is denied, list services --all-namespaces when namespace listing is denied, and pod creation when exec is denied. Enumeration means listing out what exists, one by one.
The author states that these risks do not exist in official Kubernetes or major cloud Kubernetes services because the vectors were the result of non-standard, insecure implementations. The default restrictions on listing permissions did not stop the chain because the bypasses above only need calls that remain available on the minimal role.
Impact
An attacker with limited, non-root access to a single secured pod can move laterally, reach the privileged KubeAPI, and take over the cluster. That gives access to data from all containers, including secrets and storage, and to environment variables in the Kubernetes manifests that usually contain secrets and information about services and sensitive systems. The author notes the exposure can include personally identifiable information (PII, data that identifies a real person), financial information and other sensitive data, with consequences such as financial loss, legal penalties and reputational damage, and non-compliance with regulations governing the handling of such data.
The exec risk depends on the environment: where the role has exec privileges for monitoring and log collection services such as Prisma, every namespace in the pod can be taken over; with a hardened RBAC only mirror pod creation remains, and the mirror annotation bypass applies. Takeover via vulnerable pod deployment depends on the RBAC.
Fix
The author states that it is not possible to remove some permissions of the EC2 role, but access to retrieve it can be limited using IP rules from the containers. IP rules are firewall rules based on network addresses: allow or deny by where the traffic comes from. The recommended practices are:
- Implement IP rules from the containers and block insecure metadata services from the containers.
- Change the EC2 instance IAM role permissions; the minimal permissions are vulnerable.
- Consider a third-party protection service to secure the environment.
Variants to test
If you want to check your own environment, these are the checks the author's work suggests. Each one is a small experiment with a clear positive result.
- Metadata reachability from a pod: request a token from the metadata server from a non-root container and then query node information with it. A positive result is a token being issued and node details such as ARN, labels and networking coming back.
- Role retrieval with and without the token: request the EC2 role from the metadata service both ways. A positive result is the privileged role being returned when the token is added, against an unprivileged role without it.
- Tag enumeration under restricted listing: call
Describe-tagswith the role when instance and database listing is denied. A positive result is cluster names, namespaces and cloud component names appearing in the tags. - Kubeconfig generation on a minimal role: run
update-kubeconfigwith the role and cluster name. A positive result is a working config that authenticates to the kubeAPI. - Namespace discovery without list permission: run
list serviceswith--all-namespacesand correlate with security group tags. A positive result is namespace names and services with open ports appearing without an active scan. - Pod creation when exec is denied: create a pod, and where RBAC is hardened set the
mirrorannotation totrue. A positive result is a pod scheduled on the target node, reachable over SSH, from which the host can be reached through the breakout commands.
Glossary
- API: the set of doors a program offers so other programs can ask it to do things.
- Annotation: a small piece of extra information attached to a Kubernetes object, like a note on a folder.
- ARN: Amazon Resource Name, a unique ID string for an AWS resource.
- Attack vector: the route an attacker uses to get in.
- AWS: Amazon Web Services, Amazon's collection of rented computers and services.
- Bypass: a way around a restriction without breaking it.
- Capability: a specific slice of the root user's powers, handed out individually.
- Chain attack: a series of small steps where each one makes the next possible.
- Container escape / breakout: getting out of a container onto the machine that runs it.
- Deployment: a Kubernetes instruction that says which pods to run and keeps them running.
- Docker: software for building and running containers.
- Docker file: the recipe used to build a container image.
- EC2: Amazon's service for renting virtual computers.
- EKS: Amazon Elastic Kubernetes Service, AWS's managed Kubernetes.
- Environment variable: a named value passed into a program when it starts.
- Enumeration: listing out what exists, one by one.
- Exec: running a command inside a running container.
- IAM: Identity and Access Management, AWS's system for who can do what.
- Image: a template for a container.
- IMDS: instance metadata service, the built-in information desk of a cloud machine.
- Instance metadata: data about a machine itself, such as its name and network settings.
- IP rules: firewall rules based on network addresses.
- KubeAPI: the control panel of a Kubernetes cluster.
- kubeconfig: a YAML file storing cluster authentication information for kubectl.
- kubectl: the command-line tool for talking to a Kubernetes cluster.
- Kubernetes: software that runs and organises many containers across many machines.
- Lateral movement: going from one place you are allowed to be into places you are not.
- MAC address: the fixed hardware address of a network card.
- Manifest: the written definition of what a pod should look like and how it should run.
- Mirror pod: a special pod created by Kubernetes itself for internal purposes.
- Namespace: a labelled area inside a cluster used to group related things.
- Network scan: probing many addresses to see what answers.
- Node: one physical or virtual computer in a cluster.
- PII: personally identifiable information, data that identifies a real person.
- Pod: the smallest unit Kubernetes runs, usually one container plus setup around it.
- Port: a numbered doorway on a computer that a service listens on.
- POST request: an HTTP request that sends data to a server.
- Privileged: given almost all the powers of the host machine.
- Proof of concept (PoC): a small experiment that proves a problem is real.
- Public key: one half of a key pair used for passwordless login.
- RBAC: Role-Based Access Control, permissions granted according to a role.
- Registry: a storage service for container images.
- Role: a bundle of permissions, like a staff badge that opens certain doors.
- Secret: a password, key or token stored for an application to use.
- Secret manager: a dedicated service for storing secrets.
- Security group: a set of firewall rules.
- Service: a stable network address in front of a set of pods.
- SSH: the standard way to log in to another computer over the network securely.
- Subnet: a range of network addresses.
- Tag: a label attached to a cloud resource.
- Third-party security product: extra protection software from a company other than the cloud provider.
- Token: a short-lived string of characters that proves who you are.
- YAML: a plain-text format for configuration, written as indented lists and key-value pairs.
- Zero-day: a security flaw the maker does not know about yet, so no fix exists.