Skip to main content

Triage and Remediation

Remediation

Using Console

Here are the steps to remediate the OS Disks Lacking Encryption misconfiguration in AZURE using the AZURE console:
  1. Log in to the AZURE portal.
  2. Navigate to the Virtual Machines blade.
  3. Select the virtual machine that has the OS Disks Lacking Encryption misconfiguration.
  4. Click on the “Disks” option under the Settings section.
  5. Select the OS disk that you want to encrypt.
  6. Click on the “Disk Encryption” option under the “Settings” section.
  7. Click on the “Enable” button to enable the disk encryption.
  8. Choose the encryption type and the encryption key.
  9. Click on the “Save” button to save the changes.
Once the encryption is enabled, the OS disk will be encrypted, and the misconfiguration will be remediated. It is important to note that the encryption process may take some time to complete, depending on the size of the disk.

To remediate the misconfiguration of OS Disks lacking encryption in AZURE using AZURE CLI, you can follow the below steps:
  1. Open the Azure CLI on your local machine or Azure Cloud Shell.
  2. Run the following command to check if the encryption is enabled on the VM: az vm encryption show --resource-group <resource-group-name> --name <vm-name> Replace <resource-group-name> with the name of the resource group in which the VM is located, and <vm-name> with the name of the VM.
  3. If encryption is not enabled on the VM, run the following command to enable encryption: az vm encryption enable --resource-group <resource-group-name> --name <vm-name> --disk-encryption-keyvault <key-vault-name> --key-encryption-keyvault <key-vault-name> --volume-type ALL Replace <resource-group-name> with the name of the resource group in which the VM is located, <vm-name> with the name of the VM, and <key-vault-name> with the name of the key vault where encryption keys are stored.
  4. Once the command is executed successfully, the encryption process will start, and it may take some time depending on the size of the VM.
  5. After the encryption process is complete, run the following command to verify that encryption is enabled: az vm encryption show --resource-group <resource-group-name> --name <vm-name> This command will display the encryption status of the VM.
  6. Finally, confirm that the OS disks are encrypted by logging into the VM and checking the disk properties.
By following these steps, you can remediate the misconfiguration of OS disks lacking encryption in Azure using Azure CLI.
To remediate the misconfiguration of OS Disks Lacking Encryption in AZURE using python, follow these steps:
  1. Install the Azure SDK for Python using the following command:
  1. Import the necessary modules:
  1. Authenticate to the Azure account using the DefaultAzureCredential class:
  1. Get a list of all the virtual machines in the subscription:
  1. For each virtual machine, check if the OS disk is encrypted or not:
  1. Save the script and run it to remediate the misconfiguration.
Note: This script assumes that the virtual machines are using managed disks. If the virtual machines are using unmanaged disks, you will need to modify the script accordingly.
Changing or adding disk_encryption_set_id on the existing OS disk forces replacement of the OS disk and VM (planned downtime and data loss on that disk), so apply only after backups or migration.For an existing standalone managed OS disk (azurerm_managed_disk), set disk_encryption_set_id similarly on that resource; this also forces disk replacement.Verification: terraform plan should show creation of azurerm_disk_encryption_set.OS_DISK_DES (and its Key Vault/key if new) and an update to the VM (or managed disk) adding disk_encryption_set_id on the OS disk, with a note that the disk and VM will be recreated.