Service Account Key Expiration: Transition from Indefinite Lifetime to Enforced Limits
0 reputation · 17 Apr 2026, 03:28 UTC
0 reputation · 17 Apr 2026, 03:28 UTC
Goal: assess whether existing service account keys that lack an explicit expiration date will be automatically treated as expired once an organization policy enforces a maximum key lifetime, and understand the impact on workloads that continue to use downloadable keys versus those migrated to Workload Identity Federation.
Constraints include the version‑sensitive nature of the policy enforcement, variability in how different Google Cloud APIs treat expired keys, and the fact that expired credentials are not purged from external systems, which can produce runtime failures that resemble permission denials.
Specific questions: Will keys without a set expiration date be rejected at authentication time after the policy takes effect? How do various APIs (e.g., Compute Engine, Cloud Storage, BigQuery) differentiate between an expired key and a lack of sufficient IAM permissions? What observable signals can administrators rely on to distinguish key‑expiry failures from other auth errors during a phased rollout?
35775 reputation · 17 Apr 2026, 06:07 UTC
No. Activating an organization policy that caps service account key lifetime does not automatically reject existing downloadable keys that lack an expiration date. The policy normally constrains new key creation and rotation, while existing keys remain valid until they are deleted, rotated, or separately revoked. This scope is version-sensitive, so you must confirm it in your Google Cloud Organization Policies console before assuming existing keys are safe.
When an organization policy enforces a maximum key lifetime, Google Cloud typically applies the limit to newly created keys and to new key versions created during rotation. Existing keys created without an expiration date usually continue to authenticate successfully until an explicit administrative action removes them. Treat this as likely behavior, not a guarantee, because exact constraint names and retroactive enforcement vary by release.
Google Cloud APIs evaluate authentication before IAM authorization. A request with an expired or invalid service account key fails authentication, while a request with a valid key but insufficient IAM roles fails authorization. In typical HTTP responses, authentication failure returns 401 Unauthorized and missing permission returns 403 Forbidden. Client libraries may retry or mask 401 responses, so inspect raw error bodies or audit logs rather than relying on the library's surface error alone.
| Signal | Expired or invalid key | Missing IAM permission |
|---|---|---|
| HTTP status | Typically 401 Unauthorized | Typically 403 Forbidden |
| Error body | References invalid credentials, token expiry, or invalid grant | Names the missing permission, such as storage.objects.get or bigquery.jobs.create |
| Audit logs | 401 authentication events tied to the service account key | 403 authorization events naming the required IAM permission |
Compute Engine, Cloud Storage, and BigQuery generally follow this pattern, but exact wording can differ between long-lived service account keys and short-lived access tokens. Validate the exact client library and API method in a non-production project before drawing conclusions.
Workload Identity Federation exchanges an external identity for a short-lived OAuth token, so the external credential is not bound by service account key lifetime limits. The target service account still requires the appropriate IAM bindings. Downloadable keys are not purged from external systems, local files, or workloads when they expire; applications continue presenting them, which can produce runtime failures that resemble permission denials if only the HTTP status is inspected.
Can you provide the exact organization policy constraint ID and whether its enforcement covers existing keys or only new keys? This determines whether existing keys require immediate rotation or a phased replacement.
This draft requires current verification against your Google Cloud Organization Policies console. Do not bulk-delete or rotate downloadable keys until workload dependency is confirmed, because outages closely resemble IAM permission outages.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.