1. Resources
  2. Detection rules
  3. Service Account Impersonation in Google Cloud

Service Account Impersonation in Google Cloud detection rules

An identity with token-creator rights on a service account mints short-lived access or ID tokens, or signs JWTs or blobs as that account, and acts with its roles without ever holding a key.

Platform
Google Cloud
Severity
High
Log source
Google Cloud Audit Logs
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
The iam.serviceAccounts.getAccessToken permission on the target service account, usually through Service Account Token Creator on the account, its project or a folder.
Impact
The roles of the impersonated service account for as long as tokens are requested, which with Owner, Editor or IAM admin roles means control of the project or organization.
Response
Revoke the caller's Service Account Token Creator grant on the account and on any project or folder, and disable a privileged account until its issued tokens have expired.
Mitigation
Grant Service Account Token Creator on individual service accounts rather than on projects or folders, and keep admin roles off service accounts.
API methods
GenerateAccessTokenGenerateIdTokenSignBlobSignJwt
Threat groups
None listed in MITRE ATT&CK for this technique

How the attack works

The IAM Service Account Credentials API (iamcredentials.googleapis.com) lets a principal with iam.serviceAccounts.getAccessToken and related permissions on a service account create credentials for it: OAuth 2.0 access tokens (GenerateAccessToken), OpenID Connect ID tokens (GenerateIdToken), and signatures made with the account's Google-managed key (SignJwt, SignBlob). The Service Account Token Creator role grants these permissions; granted on a project or folder, it covers every service account below it.

Attackers use impersonation to borrow the roles of a more privileged service account. The tokens are short-lived and no key is created, so nothing lasting is left on the service account. Each credential request is a Data Access audit log entry, which is disabled by default and must be enabled for the IAM API (iam.googleapis.com) or for all services. Actions taken with the token are logged under the service account's email, with the original caller in authenticationInfo.serviceAccountDelegationInfo.

What an attacker needs

  • iam.serviceAccounts.getAccessToken (or signBlob, signJwt, getOpenIdToken) on the target service account, usually through Service Account Token Creator granted on the account, its project or a folder.

Impact

The roles of the impersonated service account for as long as the attacker keeps requesting tokens. Service accounts with Owner, Editor or IAM admin roles turn this into control of the project or organization.

Detection rules

Service Account Credentials Generated by a User Account in Google Cloud

Detects a user account (not a service account) generating an access token or ID token for a service account, or signing a JWT or blob as one, through the IAM Service Account Credentials API. These are Data Access audit log entries: enable Data Access logs for the IAM API (iam.googleapis.com) or for all services first. Federated callers without a principalEmail are not matched.

LevelMediumStatusExperimentalLog sourceGoogle Cloud Audit Logs
title: Service Account Credentials Generated by a User Account in Google Cloud
id: 63221e6e-0e9f-421a-be52-92d31d6fca06
status: experimental
description: >-
  Detects a user account (not a service account) generating an access token or
  ID token for a service account, or signing a JWT or blob as one, through the
  IAM Service Account Credentials API. These are Data Access audit log entries:
  enable Data Access logs for the IAM API (iam.googleapis.com) or for all
  services first. Federated callers without a principalEmail are not matched.
references:
  - https://docs.cloud.google.com/iam/docs/audit-logging/audit-logging-iamcreds
  - https://docs.cloud.google.com/iam/docs/audit-logging/examples-service-accounts
author: Forestall
date: 2026-11-10
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: gcp
  service: gcp.audit
detection:
  selection:
    protoPayload.serviceName: iamcredentials.googleapis.com
    protoPayload.methodName:
      - GenerateAccessToken
      - GenerateIdToken
      - SignBlob
      - SignJwt
    protoPayload.authenticationInfo.principalEmail|contains: '@'
  filter_service_accounts:
    protoPayload.authenticationInfo.principalEmail|endswith: .gserviceaccount.com
  condition: selection and not filter_service_accounts
falsepositives:
  - Administrators and developers who impersonate service accounts on purpose instead of using keys; allow-list them per service account (principalEmail together with protoPayload.request.name).
level: medium

False positives

  • Administrators and developers who impersonate service accounts on purpose instead of using keys; allow-list them per service account (principalEmail together with protoPayload.request.name).

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Privileged change made through an impersonated service account

Detection hypothesisJoins two logsNeeds your own lists

The token request is a Data Access entry and is missing wherever those logs are off. What is done with the token is not. Every Admin Activity entry made with an impersonated service account names the original caller in its delegation info, so a policy change or a new key made through impersonation can be found without the token request.

  1. An Admin Activity entry whose protoPayload.authenticationInfo.principalEmail is a service account and whose authenticationInfo.serviceAccountDelegationInfo list is present. Google's example shows the original caller in firstPartyPrincipal.principalEmail of the list element.
  2. Keep the entries whose protoPayload.methodName ends with SetIamPolicy, or is google.iam.admin.v1.CreateServiceAccountKey or google.iam.admin.v1.CreateServiceAccount.
  3. Compare the original caller with the identities that are expected to impersonate this service account, such as the deployment pipeline, and alert on anyone else.
  4. Where Data Access logs are on, join with the GenerateAccessToken entry of the same caller for the same account to get the time and the source of the token request.

EventsSetIamPolicygoogle.iam.admin.v1.CreateServiceAccountKeygoogle.iam.admin.v1.CreateServiceAccountGenerateAccessToken

LimitsGoogle notes that some services, including App Engine and Google Kubernetes Engine, do not log the identity that created the short-lived credentials. Teams that deploy by impersonation on purpose appear in every such entry, so the list of expected impersonators is what makes this usable. The delegation info is a list, and a list with more than one element means the token was obtained through a chain of service accounts.

Service account impersonated by another service account or through a chain not seen before

Detection hypothesisNeeds a baseline

The rule on this page leaves out callers that are service accounts. A stolen workload credential can mint tokens for a more privileged account, directly or through intermediate accounts, and Google's Event Threat Detection reports unusual impersonators and unusual multistep delegation. A caller or chain that is new for the target account is the pattern.

  1. Data Access: GenerateAccessToken, GenerateIdToken, SignJwt and SignBlob entries from iamcredentials.googleapis.com whose authenticationInfo.principalEmail is a service account. The pair is that caller and the target in resource.labels.email_id.
  2. Admin Activity: entries whose authenticationInfo.serviceAccountDelegationInfo list has two or more elements. Google documents the list as the delegation history, in the order of delegation. The chain is the firstPartyPrincipal.principalEmail of each element followed by authenticationInfo.principalEmail.
  3. Keep the pairs and chains seen for each target account over the past 30 days and raise a new one. Give priority to targets with roles on a project, folder or organization, and to entries that change allow policies or create keys or service accounts.

EventsGenerateAccessTokenGenerateIdTokenSignJwtSignBlob

LimitsPipelines that reach per-environment accounts through a deployer account build chains on purpose, and a new pipeline creates new pairs that are harmless. The first 30 days only build the baseline. Google notes that App Engine and Google Kubernetes Engine do not log the delegating identity, and token requests are logged only where Data Access logs are on for the IAM API.

Triage

  • Identify the caller (principalEmail) and the target service account (protoPayload.request.name or resource.labels.email_id).
  • Compare with the caller's normal behaviour; a person minting tokens for a production service account needs a reason.
  • Search Admin Activity logs for entries whose serviceAccountDelegationInfo names the caller to see what was done with the token.

Response

Once the attack is confirmed:

  1. Remove the caller's right to mint credentials for the service account. Revoke Service Account Token Creator, or the custom role that carries iam.serviceAccounts.getAccessToken, on the account and on any project or folder where it was granted.
  2. Block tokens that are already issued. Service account access tokens cannot be revoked and remain valid until they expire, by default up to 60 minutes. For a privileged account, disable the service account or apply a deny policy for it during that time. Disabling cuts off every workload that uses the account at once.
  3. Contain the caller's own account. Reset its credentials and end its sessions, since whoever requested the tokens controls that identity.
  4. Undo what was done with the tokens. Remove the bindings, service account keys and resources that were created under the service account's email during that period.
  5. Enable the service account again only after the issued tokens have expired and the token creator grants on it have been reviewed.

Mitigation

  • Grant Service Account Token Creator on individual service accounts rather than on projects or folders, and only to identities that need it.
  • Keep admin roles off service accounts so that impersonating one does not give broad control.
  • Enable Data Access audit logs for the IAM API so that credential requests are recorded.

Frequently asked questions

Which audit log has to be enabled before token requests become visible?

Data Access audit logs for the IAM API (`iam.googleapis.com`), or for all services. Each credential request to the Service Account Credentials API is a Data Access entry, and those logs are disabled by default. Without them `GenerateAccessToken`, `GenerateIdToken`, `SignJwt` and `SignBlob` leave no entry and the rule has nothing to match.

Does deleting the service account's keys stop impersonation?

No. Impersonation never uses a key. The caller asks the Service Account Credentials API for a short-lived credential, and the right to do so comes from a role binding, usually Service Account Token Creator. Removing that binding on the service account, its project or the folder where it was granted is what stops it.

Why does the rule not match tokens requested by service accounts?

The rule looks only at user accounts, where requesting credentials for a service account is uncommon. A compromised service account that impersonates another one is therefore not matched, and neither is a federated caller without a `principalEmail`. Chains between service accounts need a baseline of which account normally impersonates which.

How can I see what was done with a token after it was issued?

Actions taken with the token are logged under the service account's email, not under the caller's. The original caller is recorded in `authenticationInfo.serviceAccountDelegationInfo` of those entries. Searching the audit logs for entries whose delegation info names the caller shows what was done through impersonation.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.