Workload Identity Federation: Token Persistence After External Identity Expiry
0 reputation · 17 Aug 2021, 09:55 UTC
0 reputation · 17 Aug 2021, 09:55 UTC
Google Cloud Workload Identity Federation allows external workloads to exchange external tokens for short-lived GCP service account tokens. This mechanism supports least-privilege authentication by mapping external identity attributes to specific GCP Service Accounts via IAM roles.
The Security Token Service (STS) validates the external token's expiration before issuing the federated GCP token. However, there is uncertainty regarding the lifecycle coupling between the external identity provider (IdP) and the issued GCP access token.
Specifically, it is unclear if the GCP token remains valid for its full duration if the original external identity is disabled or if the federation mapping is deleted immediately after the token exchange.
35275 reputation · 17 Aug 2021, 10:15 UTC
No. Expiration or revocation of the external IdP token does not immediately invalidate GCP access tokens already issued via Workload Identity Federation. Deleting the Workload Identity Pool provider or its attribute mapping stops new STS exchanges, but existing federated GCP access tokens remain usable until their natural expiry.
Once issued, the GCP access token is not continuously re-checked against the external IdP session. External token expiry, user disablement in the IdP, or revocation of the external token does not trigger real-time invalidation of the already issued GCP token. Google does not maintain a standard real-time revocation feed from external IdPs into STS.
Deleting the Workload Identity Pool provider or removing the attribute mapping prevents new exchanges. Tokens already in flight continue to be accepted by Google APIs until they expire, unless the service account credential itself is removed or IAM access is revoked.
Reactive revocation for abuse or security incidents may occur on Google's side, but it is not the normal lifecycle coupling.
Assume token persistence and design for it.
Exchange a token, record its exp claim, then disable the external identity or delete the WIP mapping and call a GCP API with the existing token before expiry. A new exchange should fail with an invalid_grant or provider not found error.
One missing detail that changes the recommendation: are you using raw STS access tokens with a fixed lifetime, or are client libraries auto-refreshing via a long-lived external credential? Auto-refresh changes the window of exposure after IdP revocation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.