API keys should exist only for services that are actively used
This check looks at the API keys in each Google Cloud project and whether each one is still needed by a live service. The safe setting is that only keys in active use exist, and unused keys are deleted.
Why it matters
An API key is a simple string that identifies a project and, unless restricted, can be used by anyone who holds it. Keys end up in source code, mobile apps, spreadsheets and old scripts. A key created for a prototype two years ago is still valid today and nobody remembers it exists, so nobody would notice if it leaked.
Google's documentation on API keys explains that keys do not identify a user and recommends restricting them and removing the ones you no longer need. Each key that is not needed is a credential that can be abused, can generate cost on your project, and widens what an incident response team has to review. Deleting unused keys is a low-cost way to shrink that surface.
The review is also useful in itself: it shows which services depend on keys at all and which could move to stronger methods such as service accounts.
How to check it yourself
Portal path: in the Google Cloud console choose the project, open APIs & Services, then Credentials. The API keys list shows each key's name, creation date and restrictions. For each key, open APIs & Services, Metrics to see whether the services it unlocks received requests recently, and ask the owning team whether the key is still needed.
Read-only command (gcloud, run against a test project first):
gcloud services api-keys list --project=<project-id> --format="table(displayName, uid, createTime, restrictions.apiTargets.service)"Repeat the command for every project in scope. Any key that nobody can match to a live service or owner fails the check.
How to fix it
Portal steps: in APIs & Services, Credentials, locate the unused key, select the three-dot menu and choose Delete. Where a key is still needed, leave it in place and restrict it to the specific API and the specific application or host that uses it.
Script option (run it yourself with the right permissions; ConfigCobra itself never changes your Google Cloud environment):
gcloud services api-keys delete <key-uid> --project=<project-id>Deleted keys can be restored for a short period through the API's undelete operation, which gives you a safety net, though you should not rely on it. Afterwards, rerun the list command to confirm only the intended keys remain.
What changes when you fix it
Any application, website or script that still uses a deleted key will start receiving authentication errors straight away. Mobile app builds, embedded maps, scheduled exports and partner integrations are the usual surprises. Before deleting, confirm usage with the metrics view, search your code repositories for the key string, and ask the project owner.
Nothing else in the project changes: service accounts, IAM roles and enabled APIs stay as they are. A careful approach is to restrict the suspect key to a single harmless API first, wait for complaints over an agreed period, and only then delete it. Record who approved the removal so the decision can be traced later.
Included in
| Benchmark | CIS ID | Profile |
|---|---|---|
| CIS Google Cloud Platform Foundation v5.0.0 | 1.13 | 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.