Skip to content

LearnCloud

Kubernetes workload identity review

Brief

EKS, GKE and AKS let a Kubernetes service account act as a cloud identity, so anyone who can run a pod as that account, or mint a token for it, holds the cloud role too. The review lists each account's cloud identity, the workloads that run as it, and the cluster permissions that let someone else borrow it.

Track
Cloud
Stage
Escalation
Reviewed
On this page
  1. Check first
  2. Who am I on the cluster?
  3. Which service accounts carry a cloud identity?
  4. Which workloads run as each account?
  5. Who in the cluster can borrow an identity?
  6. Does a pod creator get the identity?
  7. What does the cloud side trust?
  8. The defender sees
  9. Done when
  10. Not covered
  11. Tools
  12. Related research
  13. Reviewed

All commands

Situation
A review identity on the cluster that can read service accounts, workloads and role bindings, a kubeconfig for one identity that can create pods, such as the CI deployer, granted for one dry run, and read access to the cloud accounts' IAM for the last step. Every pod test is a server-side dry run, no token is minted, and no cloud call is made with a borrowed identity.
Goal
A table of service accounts with their cloud identity, the workloads that run as each, and every subject that can borrow each one.
Outputs
Captured on 6 Nov 2026 in the Atarus Bench review lab, edition review-lab-0.2: a one-node kind cluster (Kubernetes v1.37.0) with its API server on 127.0.0.1, kubectl 1.37.1 on the capture host, and three service accounts annotated the way EKS, GKE and AKS read them. No cloud trusts this cluster, the workloads are scaled to zero, and the cloud-side commands show no output: they wait on the lab accounts.

Check first

  • The review identity's kubeconfig, and that it can read service accounts, deployments, cron jobs and role bindings across namespaces.
  • A kubeconfig for one identity that can create pods, such as the CI deployer, for the single dry run.
  • Which cloud each cluster runs on and which workload identity system it uses: EKS IAM roles for service accounts (IRSA) or EKS Pod Identity, GKE Workload Identity Federation, or Microsoft Entra Workload ID on AKS.
  • Read access to the matching cloud IAM: role trust policies, service account IAM policies, or federated identity credentials.
  • The client's agreement that pod tests are server-side dry runs and no token for another account is minted.

Steps

Who am I on the cluster?

export KUBECONFIG=reviewer.kubeconfig
kubectl auth whoami -o jsonpath='{.status.userInfo.username}{"\n"}'

Expected output

system:serviceaccount:team-a:identity-review   # <- the read-only review identity

The review runs as the identity the client made for it, which can read workloads and bindings and change nothing. The rest of the page reads the cluster as that identity, except one dry run as the deployer from the pod escalation page.

Negative result. The name is not the review identity the client issued: stop and ask before going on.

Which service accounts carry a cloud identity?

kubectl get serviceaccounts -A -o json | jq -r '.items[] | .metadata as $m | ($m.annotations // {}) | to_entries[]
  | select(.key | test("eks.amazonaws.com/role-arn|iam.gke.io/gcp-service-account|azure.workload.identity/client-id"))
  | "\($m.namespace)/\($m.name) \(.key)=\(.value)"'

Expected output

payments/ledger-export iam.gke.io/gcp-service-account=ledger-export@atarus-lab.iam.gserviceaccount.com   # <- GKE
payments/payments-api eks.amazonaws.com/role-arn=arn:aws:iam::111122223333:role/payments-api-s3   # <- EKS
team-a/reports azure.workload.identity/client-id=11111111-2222-3333-4444-555555555555   # <- AKS

Each cloud reads one annotation on the service account: EKS takes an IAM role ARN, GKE a Google service account, and AKS the client id of a managed identity or app registration. On AKS the webhook acts only on pods labelled azure.workload.identity/use: "true". A pod running as that service account receives a token the cloud accepts for that identity. The lab carries one of each; a real cluster runs one cloud and often dozens of accounts. Two newer systems leave no annotation: EKS Pod Identity keeps its associations in the EKS API (aws eks list-pod-identity-associations), and GKE can grant IAM roles straight to a Kubernetes service account principal. On those clusters, the list comes from the cloud side.

Negative result. No service account carries an annotation, and the cloud API shows no Pod Identity association or principal grant: the cluster's pods hold no cloud identity beyond the node's own.

Fix. Give each workload its own service account and its own cloud identity, never one shared account per namespace.

Which workloads run as each account?

kubectl get deployments,cronjobs -A -o json | jq -r '.items[]
  | select(.metadata.namespace | test("^(kube-|local-path)") | not)
  | (.spec.template.spec // .spec.jobTemplate.spec.template.spec) as $s
  | "\(.kind) \(.metadata.namespace)/\(.metadata.name) sa=\($s.serviceAccountName // "default") automount=\(if $s | has("automountServiceAccountToken") then $s.automountServiceAccountToken else "unset" end)"'

Expected output

Deployment payments/ledger-export sa=ledger-export automount=false   # <- no API token, but the cloud identity stays
Deployment payments/payments-api sa=payments-api automount=unset
CronJob team-a/reports-nightly sa=reports automount=unset

Each workload names the service account its pods run as, so each cloud identity has an owner and a purpose: the payments API, the ledger export, and a nightly report job. The ledger export turns off automountServiceAccountToken, which removes the Kubernetes API token from its pods, not its cloud identity: GKE serves that from the node's metadata server, and the EKS and AKS webhooks mount their own token. An account with a cloud identity and no workload is a finding of its own: nobody needs it, and anyone who can run a pod can use it. Add statefulsets, daemonsets and jobs to the list on a real cluster.

Negative result. Every account with a cloud identity has exactly one workload that uses it.

Fix. Remove cloud identities from accounts no workload uses, and remove the annotation or association when a workload is retired.

Who in the cluster can borrow an identity?

for ns in payments team-a; do
  kubectl get rolebindings -n $ns -o json \
    | jq -r --arg ns $ns '.items[] | "\($ns) \(.roleRef.name) <- \([.subjects[] | "\(.kind):\(.name)"] | join(", "))"'
done
kubectl get clusterrole edit -o json | jq -r '.rules[] | .verbs as $v | .resources[]?
  | select(test("^(pods|pods/exec|pods/attach|pods/ephemeralcontainers|serviceaccounts|serviceaccounts/token)$"))
  | "edit: \(.) \($v | join(","))"' | sort -u

Expected output

payments lab-pod-deployer <- ServiceAccount:ci-deployer   # <- can create pods where payments-api lives
payments edit <- Group:payments-devs
team-a lab-pod-deployer <- ServiceAccount:ci-deployer
edit: pods create,delete,deletecollection,patch,update
edit: pods get,list,watch
edit: pods/attach create,delete,deletecollection,patch,update
edit: pods/attach get,list,watch
edit: pods/exec create,delete,deletecollection,patch,update   # <- exec into a running pod reads its token
edit: pods/exec get,list,watch
edit: serviceaccounts create,delete,deletecollection,patch,update
edit: serviceaccounts get,list,watch
edit: serviceaccounts impersonate
edit: serviceaccounts/token create   # <- mints a token for any account in the namespace

Creating pods and minting tokens hand over the cloud identities in a namespace, and so does exec or attach into a running pod that already holds one. Creating pods lets a subject run a pod as any service account there. serviceaccounts/token create mints a token for any account, with the audience the caller chooses, and that token works away from the cluster wherever the cloud trusts it. impersonate on service accounts acts as the account in the Kubernetes API, which hands over its cloud identity only where that account can itself create pods or tokens. On this v1.37 cluster the built-in edit role holds all of these, though not pods/ephemeralcontainers, which the select also asks for, so the whole payments-devs group holds the payments API's AWS role and the ledger export's Google service account. The deployer can create pods in both namespaces. Cluster role bindings count too: the pod escalation page lists them.

Negative result. Only the deployment pipeline's own identity can create or patch pods and workloads in a namespace that holds a cloud identity, and nobody holds pods/exec, pods/attach, pods/ephemeralcontainers, serviceaccounts/token create or impersonate there.

Fix. Keep workloads with powerful cloud identities in namespaces only the pipeline deploys to, give people a role without pods, tokens or impersonation there, and review edit and admin bindings first.

Does a pod creator get the identity?

The test pod names payments-api as its service account and nothing else:

# Workload identity page: a pod that runs as payments-api, sent only as a
# server-side dry run, so nothing is stored and nothing runs.
apiVersion: v1
kind: Pod
metadata:
  name: atarus-identity-test
spec:
  serviceAccountName: payments-api
  containers:
    - name: test
      image: registry.example.com/payments/api:4.2.0
KUBECONFIG=deployer.kubeconfig kubectl apply --dry-run=server -n payments -f run-as-payments-api.yaml \
  -o jsonpath='{.metadata.name} accepted, runs as {.spec.serviceAccountName}{"\n"}'

Expected output

atarus-identity-test accepted, runs as payments-api   # <- admission accepts it; on EKS the webhook would add the role's token

The deployer sends a pod that names payments-api as its service account, as a server-side dry run: the API server runs authorization and admission and stores nothing. It is accepted, so the deployer can run code as payments-api, and on EKS that pod would receive a token for the payments-api-s3 role. Asked for by name afterwards, the pod is not there:

KUBECONFIG=deployer.kubeconfig kubectl get pod atarus-identity-test -n payments

Expected output

Error from server (NotFound): pods "atarus-identity-test" not found   # <- the dry run stored nothing

Negative result. The dry run is refused: by authorization, by a policy that ties each service account to its own workload, or by admission.

Fix. Use an admission policy (a ValidatingAdmissionPolicy, Kyverno or Gatekeeper rule) that lets only named workloads run as each service account with a cloud identity.

What does the cloud side trust?

aws iam get-role --role-name payments-api-s3 --query 'Role.AssumeRolePolicyDocument.Statement[].[Principal.Federated, Condition]'
gcloud iam service-accounts get-iam-policy ledger-export@atarus-lab.iam.gserviceaccount.com --format=json
az identity federated-credential list --identity-name reports-identity --resource-group rg-reports -o table

Each cloud must trust the cluster for exactly one service account. On AWS, the role's trust policy should require StringEquals on the issuer's :sub with system:serviceaccount:payments:payments-api and on :aud with sts.amazonaws.com; a StringLike with system:serviceaccount:payments:*, or no :sub condition at all, lets every account in the namespace, or the cluster, take the role. On Google Cloud, the roles/iam.workloadIdentityUser member should be serviceAccount:PROJECT.svc.id.goog[payments/ledger-export], not a namespace-wide principal set; every cluster in the project shares that pool, so the same namespace and name in another of its clusters matches too. On Azure, the federated credential's subject should be system:serviceaccount:team-a:reports with the cluster's own issuer. The output waits on the lab accounts, so this page shows the commands only.

Negative result. Each trust names one issuer, one namespace and one service account, exactly.

Fix. Tighten every wildcard to the exact subject, and add the audience condition where it is missing.

The defender sees

On the cluster, the review is a series of list and get calls from the review identity, and the dry run is one create with dryRun=All. The Kubernetes audit log records all of them when it is on, which on managed clusters means turning on control plane audit logging (EKS) or reading it from Cloud Logging (GKE) or diagnostic settings (AKS). The borrowed identity's use is the alert that matters: an AssumeRoleWithWebIdentity in CloudTrail, a token exchange in Google Cloud audit logs, or a federated sign-in in Entra sign-in logs, from a pod or an address the workload does not use. If the audit log is off, that goes in the report beside the finding.

Done when

Every service account with a cloud identity is listed with its workloads and the subjects that can create pods, exec or attach into them, mint tokens or impersonate in its namespace, and each cloud trust is checked for an exact subject.

Not covered

EKS Pod Identity associations and GKE principal grants made without an annotation (named below, read from the cloud API), node and instance roles, the cloud role's own permissions (see AWS IAM escalation), and using a borrowed identity.