Skip to main content

More Info:

GKE cluster should have Workload Identity enabled

Risk Level

Critical

Address

Security, Reliability, Best Practice

Compliance Standards

CBP

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Workload Identity Should Be Enabled” for GCP using GCP console, please follow the below steps:
  1. Open the GCP console and select the project for which you want to enable the Workload Identity.
  2. Go to the “IAM & Admin” section from the left-hand side menu.
  3. Click on “Service Accounts” from the IAM menu.
  4. Select the service account for which you want to enable Workload Identity.
  5. Click on “Edit” from the top menu bar.
  6. Scroll down to the “Identity and API access” section.
  7. Click on the “Enable Workload Identity” checkbox.
  8. Click on “Save” to enable the Workload Identity for the selected service account.
  9. Repeat the above steps for all the service accounts in your GCP project.
Enabling Workload Identity for all the service accounts in your GCP project ensures that your applications running on GCP can securely access other Google Cloud services without the need for managing and storing service account keys.

To remediate the misconfiguration “Workload Identity Should Be Enabled” in GCP using GCP CLI, follow the below steps:
  1. Open the Cloud Shell in GCP console.
  2. Run the following command to enable the Workload Identity API:
  1. Create a Kubernetes service account:
Replace the [SA-NAME], [SA-DESCRIPTION], and [SA-DISPLAY-NAME] with the desired values.
  1. Bind the Kubernetes service account to the GCP service account:
Replace the [SA-NAME], [PROJECT-ID], and [NAMESPACE] with the desired values.
  1. Annotate the Kubernetes service account to use the GCP service account:
Replace the [NAMESPACE], [SA-NAME], and [PROJECT-ID] with the desired values.
  1. Verify that the workload identity is enabled by running the following command:
  1. Run the following command to authenticate using the Kubernetes service account:
  1. Run the following command to verify that the authentication was successful:
If the authentication was successful, you should see the Kubernetes service account listed.These steps should remediate the misconfiguration “Workload Identity Should Be Enabled” for GCP using GCP CLI.
To remediate the “Workload Identity Should Be Enabled” misconfiguration in GCP using Python, follow these steps:
  1. Install the necessary libraries:
  2. Set up an authentication method for your GCP account. You can either use a service account or your own user credentials.
  3. Create a Python script that will enable Workload Identity for your GCP project. Here’s an example script that you can modify according to your needs:
  4. Replace 'path/to/service_account.json' with the path to your service account file.
  5. Replace 'your-project-id' with the ID of the GCP project that you want to enable Workload Identity for.
  6. Save the Python script and run it using the command python script_name.py.
  7. Verify that Workload Identity has been enabled for your GCP project by checking the Cloud IAM page in the GCP console.