Skip to content
Threat Feed
medium advisory

GCP Service Account Impersonation Role Grant Detection

Adversaries can gain unauthorized access to Google Cloud Platform environments by granting themselves service account impersonation roles, enabling long-term persistence and privilege escalation that survives credential rotation.

Adversaries with sufficient GCP administrative privileges can establish durable, key-less persistence by granting themselves or an attacker-controlled principal specific IAM roles on a target service account. The roles roles/iam.serviceAccountTokenCreator, roles/iam.serviceAccountUser, and roles/iam.serviceAccountOpenIdTokenCreator allow a principal to mint OAuth2 access tokens, generate OpenID Connect identity tokens, or attach (actAs) the target service account to new cloud resources. Because these roles leverage GCP's native IAM trust relationship rather than long-lived static service account keys, the resulting access is unaffected by traditional credential rotation or password reset procedures. This technique is commonly used to pivot from a compromised low-privileged identity to a higher-privileged service account with broader project or organization-level permissions. Defenders should monitor for unexpected SetIamPolicy operations, particularly when the principal performing the grant has not historically performed such actions.

Impact

Successful exploitation allows an adversary to maintain long-term access to a GCP environment regardless of security team efforts to rotate credentials. It facilitates significant privilege escalation if the target service account possesses broad IAM permissions. In enterprise environments, this can lead to unauthorized data access, infrastructure manipulation, and cross-project movement within the GCP organization.

Recommendation

  • Deploy detection rules to monitor SetIamPolicy operations that add impersonation roles to service accounts.
  • Baseline administrative and CI/CD service accounts (such as Terraform or Jenkins) that legitimately perform IAM modifications to reduce false positives.
  • Restrict the ability to set IAM policies on service accounts and implement a peer-review or justification-based approval process for IAM changes.
  • Review existing IAM bindings for unauthorized principals or external accounts that have been granted impersonation rights.

Immediate actions

Deploy detection rule to identify service account impersonation grants.

Detection Engineering 48h

Threat Hunt

Identify all service accounts with roles/iam.serviceAccountUser or similar impersonation roles currently bound.

T1098.003 high high confidence hunt now

Data: GCP IAM Policy exports

Mitigations

Review and audit all current service account IAM policies for unauthorized impersonation bindings.

immediate Cloud Security Team

Persistent access via cloud roles

Detection coverage 1

Detect GCP IAM Service Account Impersonation Role Granted

medium

Detects when a service account impersonation role (e.g., serviceAccountTokenCreator) is added to a service account via SetIamPolicy.

sigma tactics: persistence, privilege-escalation techniques: T1098.003 sources: process_creation, google_cloud

Detection queries are available on the platform. Get full rules →