π Google API Key is not restricted for unused APIs π’
- Contextual name: π API Key is not restricted for unused APIs π’
- ID:
/ce/ca/google/api/api-key-for-application
- Located in: π Google API & Services
Flagsβ
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
Our Metadataβ
- Policy Type:
COMPLIANCE_POLICY
- Policy Category:
SECURITY
Similar Policiesβ
- Cloud Conformity
Logicβ
- π§ prod.logic.yaml π’
- π Google API Key
- π Google API Key - object.extracts.yaml
- π§ͺ test-data.json
Descriptionβ
Descriptionβ
API Keys should only be used for services in cases where other authentication methods are unavailable. API keys are always at risk because they can be viewed publicly, such as from within a browser, or they can be accessed on a device where the key resides. It is recommended to restrict API keys to use (call) only APIs required by an application.
Rationaleβ
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 keyIn 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.
... see more
Remediationβ
Remediationβ
From Consoleβ
- Go to
APIs & Services\Credentials
using https://console.cloud.google.com/apis/credentials- In the section
API Keys
, Click theAPI Key Name
. The API Key properties display on a new page.- In the
Key restrictions
section go toAPI restrictions
.- Click the
Select API
drop-down to choose an API.- Click
Save
.- Repeat steps 2,3,4,5 for every unrestricted API key
Note: Do not set
API restrictions
toGoogle Cloud APIs
, as this option allows access to all services offered by Google cloud.From Google Cloud CLIβ
List all API keys.
gcloud services api-keys list
Note the
UID
of the key to add restrictions to.Run the update command with the appropriate flags to add the required restrictions.
gcloud alpha services api-keys update <UID> <restriction_flags>
Note: Flags can be found by running
gcloud alpha services api-keys update --help
or in this documentation https://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/update
policy.yamlβ
Linked Framework Sectionsβ
Section | Sub Sections | Internal Rules | Policies | Flags |
---|---|---|---|---|
πΌ CIS GCP v3.0.0 β πΌ 1.14 Ensure API Keys Are Restricted to Only APIs That Application Needs Access - Level 2 (Automated) | 1 | |||
πΌ Cloudaware Framework β πΌ Cryptographic Configuration | 8 |