API keys should be rotated at least every 90 days
This check looks at the age of the API keys in your Google Cloud projects. The safe setting is that no key is older than 90 days, so each one is replaced on a regular schedule.
Why it matters
An API key is a long-lived string. It is often pasted into code, config files or mobile apps, and anyone who copies it can use it until it is deleted. Regular replacement limits how long a leaked key stays useful.
Google Cloud's API key documentation tells you to keep key strings secure and to restrict each key by API and by application. Rotation adds a time limit on top of those restrictions. The Google documentation describes rotation in the console. See the source below.
How to check it yourself
In the Google Cloud console open APIs & Services → Credentials and read the Creation date column in the API keys list. Any key older than 90 days fails the check.
With the gcloud CLI, this read-only command lists keys with their creation time (replace the project ID):
gcloud services api-keys list --project=my-project-id \
--format="table(uid, displayName, createTime)"Repeat for each project in scope.
How to fix it
Rotate in this order so nothing breaks: create a replacement key with the same restrictions, move every application to it, confirm that traffic uses the new key, then delete the old key. Google documents rotation as a console feature (APIs & Services → Credentials → the key → Rotate key), and the delete step is done there too.
To create the replacement key with gcloud, restrict it to the API it needs:
gcloud services api-keys create \
--project=my-project-id \
--display-name="my-app-key-rotated" \
--api-target=service=maps-backend.googleapis.comYou make these changes yourself. ConfigCobra uses a read-only service account and never creates, changes or deletes keys.
What changes when you fix it
The old key stops working once it is deleted, so any application, script or device still using it starts to fail with an authentication error. List who owns each key before you rotate, update the secret in each system, and watch error rates after the switch.
Google lets you restore a deleted key for 30 days with gcloud services api-keys undelete, which gives you a way back if something was missed. Put the next rotation date in a calendar or ticket, because the check will fail again when the new key reaches 90 days.
Included in
| Benchmark | CIS ID | Profile |
|---|---|---|
| CIS Google Cloud Platform Foundation v5.0.0 | 1.16 | Level 2 |
More checks in Identity and Access Management
- Use corporate-managed login credentials instead of consumer accountsCIS 1.2
- Enforce multi-factor authentication for all non-service accountsCIS 1.3
- Enforce security-key two-factor authentication for all admin accountsCIS 1.4
- Use only GCP-managed keys for each service account (no user-managed keys)CIS 1.5
- Ensure service accounts hold no admin (owner/editor) privilegesCIS 1.6
Go further
- Identity and Access Management21 controls in this section
- CIS Google Cloud Platform Foundation v5.0.093 controls
- CIS Google Cloud Platform Foundation checklistEvery control in one list, as CSV
- RemediationSee what a fix changes in your tenant before you apply it, then use the generated script
- Monitoring & DriftScheduled scans, drift detection and email alerts when a control regresses
Check this on your Google Cloud
ConfigCobra runs this check with every other control of the CIS Google Cloud Platform Foundation Benchmark, read-only.