Triage and Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “KMS Admin Roles Should Not Have CryptoKey Role” in GCP using GCP console, you can follow the below steps:
- Login to your GCP console and navigate to the IAM & Admin page.
- In the IAM & Admin page, select the “Roles” tab.
- Search for the “Cloud KMS Admin” role and click on it.
- Under the “Permissions” tab, search for the “cloudkms.cryptoKeyRoles.*” permission.
- Click on the pencil icon next to the “cloudkms.cryptoKeyRoles.*” permission to edit it.
- Uncheck the “cloudkms.cryptoKeyRoles.*” permission and click on the “Save” button.
- Verify that the “cloudkms.cryptoKeyRoles.*” permission is no longer present under the “Permissions” tab for the “Cloud KMS Admin” role.
Using CLI
Using CLI
To remediate this issue in GCP using GCP CLI, you can follow the below steps:
- Open the Google Cloud Console and go to the Cloud Shell.
-
Run the following command to list all the KMS admin roles in your project:
-
Identify the KMS admin role that has the
roles/cloudkms.cryptoKeyEncrypterDecrypter
role. -
Run the following command to remove the
roles/cloudkms.cryptoKeyEncrypterDecrypter
role from the KMS admin role:Replace[KMS_ADMIN_ROLE]
with the name of the KMS admin role that you identified in step 3. -
Verify that the
roles/cloudkms.cryptoKeyEncrypterDecrypter
role has been removed from the KMS admin role by running the following command:Replace[KMS_ADMIN_ROLE]
with the name of the KMS admin role that you identified in step 3. This command should output the details of the KMS admin role, which should not include theroles/cloudkms.cryptoKeyEncrypterDecrypter
role.
roles/cloudkms.cryptoKeyEncrypterDecrypter
role in GCP using GCP CLI.Using Python
Using Python
To remediate the misconfiguration “KMS Admin Roles Should Not Have CryptoKey Role” in GCP using Python, you can follow the below steps:Step 1: Create a list of all the KMS admin roles that have CryptoKey role.Step 2: Remove the CryptoKey role from all the KMS admin roles.Note: Replace the
path/to/service_account.json
, your_project_id
, location
, keyring_name
, and cryptokey_name
with the actual values in your GCP environment.