Skip to main content
Five Steps for Cloud Compliance Readiness·A practical playbook for security teamsDownload
CIS Google Cloud Platform Foundation v5.0.0 · 1.15

API keys should be limited to the specific APIs the application calls

  • Level 2
  • Identity and Access Management

This check looks at each API key in your Google Cloud projects and whether it has an API restriction that names the services it may call. The safe setting is that every key can only reach the APIs its application actually needs.

Why it matters

By default a new API key can call every API that is enabled in its project. If such a key leaks, the person holding it can use any of those services, not just the one you meant to expose. An API restriction turns the key into a narrow credential: a map key can only load maps, a translation key can only translate.

Google's API key documentation lists API restrictions as one of the two kinds of restriction a key can carry, next to application restrictions, and its best-practices page recommends using both. Restricting the key also keeps the damage of a leak inside one service and one budget line.

How to check it yourself

In the console go to APIs & Services → Credentials, open a key and read API restrictions. Don't restrict key means the key can call any enabled API.

Read-only listing from the command line, showing the API targets per key (an empty column means unrestricted):

gcloud services api-keys list --project=my-project-id \
  --format="table(displayName,name.basename(),restrictions.apiTargets[].service)"

Across all projects you can see:

for p in $(gcloud projects list --format="value(projectId)"); do
  echo "== $p"
  gcloud services api-keys list --project="$p" \
    --format="table(displayName,restrictions.apiTargets[].service)"
done

Both commands only read key metadata. Try them against a test project before a production one.

How to fix it

For each unrestricted key, work out which Google APIs the application really calls, open the key under APIs & Services → Credentials, choose Restrict key under API restrictions, tick only those APIs and save.

The same change with gcloud:

gcloud services api-keys update KEY_ID --project=my-project-id \
  --api-target=service=translate.googleapis.com

# Several services: repeat the flag
gcloud services api-keys update KEY_ID --project=my-project-id \
  --api-target=service=maps-backend.googleapis.com \
  --api-target=service=geocoding-backend.googleapis.com

You apply the change yourself; ConfigCobra is read-only and never edits your projects, it only reports the finding and suggests the steps. Pair this with an application restriction on the same key so it is limited both by service and by where it is used.

What changes when you fix it

Requests from that key to any service outside the allowed list are rejected. An application that quietly relied on the key for a second API, for example a site that uses both a maps service and a places service, will break for that feature until you add the missing service to the list.

To avoid surprises, check the API usage metrics for the project and for the key before narrowing it, and confirm with the application team which services they call. Make the change in a quiet period, test the feature end to end, and keep a note of the previous setting. End users notice nothing if the list matches what the application already uses.

Included in

BenchmarkCIS IDProfile
CIS Google Cloud Platform Foundation v5.0.01.15Level 2

Check this on your Google Cloud

ConfigCobra runs this check with every other control of the CIS Google Cloud Platform Foundation Benchmark, read-only.

Get in touch

Let's talk.

Whether you're evaluating ConfigCobra, running an audit, or managing a client fleet — we respond within one business day.

Free trial