Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Customer Supplied Encryption Key Should Be Enabled For Disks” 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 Customer Supplied Encryption Key.
  2. In the left navigation menu, select “Compute Engine” and then select “Disks”.
  3. Select the disk for which you want to enable Customer Supplied Encryption Key.
  4. Click on “Edit” at the top of the page.
  5. In the Encryption section, select “Customer-supplied encryption key”.
  6. Enter the 256-bit encryption key in the “Key” field.
  7. Click on “Save” to save the changes.
Once you have completed the above steps, the disk will be encrypted using the customer-supplied encryption key. It is recommended to create a backup of the encryption key and store it in a secure location, as it will be required to access the data on the disk.

To remediate the “Customer Supplied Encryption Key Should Be Enabled For Disks” misconfiguration in GCP using GCP CLI, you can follow the below steps:
  1. Open the Cloud Shell in your GCP console.
  2. Run the following command to check if the customer-supplied encryption key is enabled for the disks:
    Replace [DISK_NAME] with the name of the disk that you want to check and [ZONE] with the zone in which the disk is located.
  3. If the output of the previous command is “False”, then the customer-supplied encryption key is not enabled for the disk. To enable it, run the following command:
    Replace [DISK_NAME] with the name of the disk that you want to encrypt and [ZONE] with the zone in which the disk is located. Replace [USER_EMAIL] with the email address of the user who will be able to encrypt and decrypt the disk.
  4. After running the above command, the customer-supplied encryption key will be enabled for the disk. You can verify it by running the following command:
    The output of the above command should be “True”, indicating that the customer-supplied encryption key is enabled for the disk.
By following the above steps, you can remediate the “Customer Supplied Encryption Key Should Be Enabled For Disks” misconfiguration in GCP using GCP CLI.
To remediate the misconfiguration “Customer Supplied Encryption Key Should Be Enabled For Disks” in GCP using Python, you can follow the below steps:Step 1: Install the required packages
Step 2: Authenticate to GCP
Step 3: Import the required libraries
Step 4: Create a service account and grant it the required permissions
Step 5: Create a function to enable customer-supplied encryption key for disks
Step 6: Call the function to enable customer-supplied encryption key for the disk
Note: Replace the placeholders <project-id>, <zone>, <instance-name>, <disk-name>, and <encryption-key> with the actual values for your GCP project.
Substitute:
  • CSEK_PROTECTED_DISK_NAME with the desired disk name.
  • DISK_ZONE with the disk’s zone.
  • RAW_KEY_BASE64 with your base64-encoded 256-bit customer-supplied key (do not check this into source control; load from a secure variable/store).
Enabling CSEK on an existing disk requires deleting and recreating the disk; this change forces replacement of the disk and permanent loss of any data that is not backed up and restored from snapshot/image.To verify, terraform plan should show the existing google_compute_disk scheduled for -/+ (destroy and create) with the addition of the disk_encryption_key.raw_key argument on the new disk.