Service account impersonation

Minting credentials for a target service account: getAccessToken, signJwt and signBlob, Token Creator grants, implicit delegation, and long-lived key creation.

1 ನಿಮಿಷದ ಓದುಅಕ್ಟೋ 7,2026 ರಂದು ನವೀಕರಿಸಲಾಗಿದೆflorianamette1 ಕೊಡುಗೆದಾರ
ನಿಮ್ಮ ಸಹಾಯಕವನ್ನು ಕೇಳಿ (MCP)GitHub ನಲ್ಲಿ ಸಂಪಾದಿಸಿ

Impersonation is the most direct GCP escalation: a permission on a target service account lets you act as it without deploying anything. The roles/iam.serviceAccountTokenCreator role (and the individual permissions below) is the hinge, and it is frequently granted too broadly.

The primitives#

  • getAccessToken: mint a short-lived OAuth token for the target directly.
  • signJwt and signBlob: forge a signed JWT or blob as the target, then exchange it for a token.
  • Token Creator grant: grant yourself Token Creator on the target with serviceAccounts.setIamPolicy, then impersonate.
  • Implicit delegation: chain through an intermediate account to reach one you cannot call directly.
  • Key creation: create a long-lived JSON key for durable access and persistence.

Using an impersonated identity#

Most gcloud commands accept the impersonation flag once you hold the permission:

bash
gcloud <command> --impersonate-service-account=<target-sa>@<project>.iam.gserviceaccount.com
gcloud auth print-access-token --impersonate-service-account=<target-sa>@...

References#