Skip to main content

Triage and Remediation

Remediation

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:
  1. Login to your GCP console and navigate to the IAM & Admin page.
  2. In the IAM & Admin page, select the “Roles” tab.
  3. Search for the “Cloud KMS Admin” role and click on it.
  4. Under the “Permissions” tab, search for the “cloudkms.cryptoKeyRoles.*” permission.
  5. Click on the pencil icon next to the “cloudkms.cryptoKeyRoles.*” permission to edit it.
  6. Uncheck the “cloudkms.cryptoKeyRoles.*” permission and click on the “Save” button.
  7. Verify that the “cloudkms.cryptoKeyRoles.*” permission is no longer present under the “Permissions” tab for the “Cloud KMS Admin” role.
By following the above steps, you have successfully remediated the misconfiguration “KMS Admin Roles Should Not Have CryptoKey Role” in GCP using GCP console.

To remediate this issue in GCP using GCP CLI, you can follow the below steps:
  1. Open the Google Cloud Console and go to the Cloud Shell.
  2. Run the following command to list all the KMS admin roles in your project:
  3. Identify the KMS admin role that has the roles/cloudkms.cryptoKeyEncrypterDecrypter role.
  4. 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.
  5. 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 the roles/cloudkms.cryptoKeyEncrypterDecrypter role.
By following these steps, you should be able to remediate the issue of KMS admin roles having the roles/cloudkms.cryptoKeyEncrypterDecrypter role in GCP using GCP CLI.
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.
Substitute:
  • GOOGLE_KMS_CRYPTO_KEY_ID with the full resource ID of the CryptoKey.
  • PROJECT_ID with your GCP project ID.
  • Adjust the members lists so that no identity appears in both google_project_iam_binding.kms_admins and any google_kms_crypto_key_iam_* resource (binding/member/policy) for the same keys.
This cannot be remediated on a “gcp-securityandidentity-iam-user” resource directly because IAM in Terraform is managed on the project/organization, key ring, or crypto key resources, not on the user itself; you must update the IAM bindings as shown.Applying this change does not delete any KMS resources but will revoke the CryptoKey role from any removed principals. terraform plan should show updates (~) to the affected google_kms_crypto_key_iam_* and/or google_project_iam_* resources where members are being added/removed, with no new resources created or destroyed.