Skip to main content

More Info:

Ensure that your Azure virtual machine disk volumes are using customer-managed keys (also known as Bring Your Own Keys - BYOKs) instead of service-managed keys (default keys used by Microsoft Azure for disk encryption), in order to have a more granular control over your VM data encryption/decryption process.

Risk Level

High

Address

Security

Compliance Standards

  • HITRUST CSF
  • NIST CSF
  • PCI
  • SOC2
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of not using BYOK for disk volume encryption in Azure, follow these steps:
  1. Log in to the Azure portal (https://portal.azure.com/).
  2. Navigate to the “Key Vaults” menu and create a new Key Vault if you do not have an existing one.
  3. In the “Key Vaults” menu, select the Key Vault that you want to use for BYOK.
  4. In the Key Vault, select the “Keys” menu and create a new key.
  5. Provide a name for the key, select “RSA” as the key type, and provide a key size of at least 2048 bits.
  6. Select the “BYOK” option under “Key Options” and provide the URI of your on-premises key management service (KMS).
  7. Save the key and take note of the key identifier (URI) for later use.
  8. Navigate to the “Disks” menu and select the disk that you want to encrypt using BYOK.
  9. Under the “Encryption” tab, select “Disk encryption set” and click “Create new”.
  10. Provide a name for the disk encryption set and select the Key Vault that you created in step 2.
  11. In the “Key management” section, select “Bring your own key (BYOK)” and provide the key identifier (URI) that you noted in step 7.
  12. Save the disk encryption set and wait for the encryption process to complete.
By following these steps, you have successfully remediated the misconfiguration by using BYOK for disk volume encryption in Azure.

To remediate the misconfiguration of not using Bring Your Own Key (BYOK) for Disk Volumes Encryption on Azure using Azure CLI, follow the below steps:
  1. Create a new Key Vault in Azure or use an existing one.
  2. Create a new Key in the Key Vault or use an existing one.
  3. Grant the Disk Encryption Set (DES) access to the Key Vault and Key.
  4. Enable disk encryption using the Key Vault and Key.
The following are the detailed steps to remediate the misconfiguration:Step 1: Create a new Key Vault in Azure or use an existing oneUse the below command to create a new Key Vault in Azure:
Replace “key-vault-name” with the name of the Key Vault, “resource-group-name” with the name of the resource group, and “location” with the location of the Key Vault.Step 2: Create a new Key in the Key Vault or use an existing oneUse the below command to create a new Key in the Key Vault:
Replace “key-vault-name” with the name of the Key Vault and “key-name” with the name of the Key.Step 3: Grant the Disk Encryption Set (DES) access to the Key Vault and KeyUse the below command to grant the Disk Encryption Set (DES) access to the Key Vault:
Replace “key-vault-name” with the name of the Key Vault and “object-id” with the object ID of the Disk Encryption Set (DES).Use the below command to grant the Disk Encryption Set (DES) access to the Key:
Replace “key-vault-name” with the name of the Key Vault and “object-id” with the object ID of the Disk Encryption Set (DES).Step 4: Enable disk encryption using the Key Vault and KeyUse the below command to enable disk encryption using the Key Vault and Key:
Replace “resource-group-name” with the name of the resource group, “disk-encryption-set-name” with the name of the Disk Encryption Set (DES), “key-url” with the URL of the Key, and “key-vault-id” with the ID of the Key Vault.After following these steps, the misconfiguration of not using BYOK for Disk Volumes Encryption on Azure using Azure CLI will be remediated.
To remediate the misconfiguration of not using BYOK for Disk Volumes Encryption in AZURE using Python, follow the steps below:
  1. First, you need to create a new key vault in Azure. To create a key vault, you can use the azure-mgmt-keyvault Python package. Install the package using the following command:
    Then, use the following code snippet to create a new key vault:
  2. Next, you need to create a new key in the key vault. To create a new key, you can use the azure-keyvault-keys Python package. Install the package using the following command:
    Then, use the following code snippet to create a new key:
  3. Finally, you need to enable BYOK for disk volume encryption in Azure. To do this, you can use the azure-mgmt-compute Python package. Install the package using the following command:
    Then, use the following code snippet to enable BYOK for disk volume encryption:
    Note that you need to replace the placeholders <your-subscription-id>, <your-resource-group-name>, <your-key-vault-name>, <your-region>, <your-tenant-id>, <your-object-id>, <your-key-name>, <your-disk-encryption-set-name> with your own values.
This change moves the VM’s OS and data disks from service-managed keys to a customer-managed key via a Disk Encryption Set.
Changing an existing VM’s disk_encryption_set_id usually forces replacement of the OS/data disks and may recreate the VM, causing downtime; plan carefully before applying.
To verify, run terraform plan and ensure it shows:
  • creation of azurerm_key_vault, azurerm_key_vault_key, azurerm_disk_encryption_set, and azurerm_key_vault_access_policy
  • updates (or replacements) to the VM where os_disk.disk_encryption_set_id (and any data_disk[*].disk_encryption_set_id) are set to the Disk Encryption Set ID.