More Info:

Security risks involved in using API-Keys are below: • API keys are simple encrypted strings • API keys do not identify the user or the application making the API request • API keys are typically accessible to clients, making it easy to discover and steal an API key In light of these potential risks, Google recommends using the standard authentication flow instead of API-Keys. However, there are limited cases where API keys are more appropriate. For example, if there is a mobile application that needs to use the Google Cloud Translation API, but doesn’t otherwise need a backend server, API keys are the simplest way to authenticate to that API. In order to reduce attack surfaces by providing least privileges, API-Keys can be restricted to use (call) only APIs required by an application.

Risk Level

Medium

Address

Security, Reliability

Compliance Standards

CISGCP, CBP

Triage and Remediation

Remediation

To remediate the misconfiguration “Ensure API Keys Are Restricted To Necessary APIs” for GCP using GCP console, please follow the below steps:

  1. Login to GCP console (https://console.cloud.google.com/).
  2. Select the project for which you want to remediate the misconfiguration.
  3. In the left-hand menu, click on “APIs & Services” and then click on “Credentials”.
  4. Select the API key that you want to restrict.
  5. Under “Key restriction”, select “HTTP referrers (web sites)“.
  6. In the “Website restrictions” section, add the domain name(s) of the websites that are allowed to use this API key.
  7. In the “API restrictions” section, select the APIs that are allowed to use this API key.
  8. Click on “Save” to apply the changes.

By following these steps, the API key will be restricted to only the necessary APIs and the risk of unauthorized access will be reduced.

Additional Reading: