Skip to main content

lacework-global-638

7.6 (Legacy) Encrypt Virtual Hard Disks (VHD) (Manual)

Profile Applicability

• Level 2

Description

NOTE: This is a legacy recommendation. Managed Disks are default encrypted and recommended for all new VM implementations.

Blob storage stores VHD (Virtual Hard Disks), which are the old-style disks that attached to Virtual Machines. The blob VHD was then leased to the VM. By default, storage accounts are not encrypted, and Microsoft Defender recommends encrypting the OS disks. You can encrypt storage accounts as a whole using Platform Managed Key (PMK) or Customer Managed Key (CMK). Enable this for storage accounts containing VHDs.

Rationale

While it is recommended to use Managed Disks which are encrypted by default, "legacy" VHDs may exist for a variety of reasons and may need to remain in VHD format. VHDs are not encrypted by default, so this recommendation intends to address the security of these disks. In these niche cases, VHDs should be encrypted using the procedures in this recommendation to encrypt and protect the data content.

If a virtual machine is using a VHD and can be converted to a managed disk, instructions for this procedure can be found in the resources section of this recommendation under the title "Convert VHD to Managed Disk."

Impact

Depending on how the encryption is implemented will change the size of the impact. If provider-managed keys(PMK) are utilized, the impact is relatively low, but processes need to be put in place to regularly rotate the keys. If Customer-managed keys(CMK) are utilized, a key management process needs to be implemented to store and manage key rotation, thus the impact is medium to high depending on user maturity with key management.

Audit

From Azure CLI

For each virtual machine identify if the VM is using a legacy VHD by reviewing the VHD parameter in the output of the following command. The VHD parameter will contain the Storage Account name used for the VHD.

az vm show --name <MyVM> --resource-group <MyResourceGroup>

Next, identify if the storage account from the VHD parameter is encrypted by reviewing the encryption --> services --> blob --> enabled within the output of the following command and make sure its value is True.

az storage account show --name <storage account name> --resource-group <resource group>

From Azure PowerShell

Determine whether the VM is using a VHD for the OS Disk and any Data disks.

$virtualMachine = Get-AzVM --Name <vm name> --ResourceGroup <resource group name> |Select-Object -ExpandProperty StorageProfile

$virtualMachine.OsDisk
$virtualMachine.DataDisks

Next, use the value from VHD to see if the storage blob holding the VHD is encrypted.

$storageAccount = Get-AzStorageAccount -Name <storage account name from VHD setting> -ResourceGroupName <resource group name>

$storageAccount.Encryption.Services.Blob

Remediation

From Azure Portal

  1. Navigate to the storage account that you wish to encrypt.
  2. Select encryption.
  3. Select the encryption type that you wish to use.

If using a Microsoft-managed key (the default), saving at this point applies encryption to the account.

If you select Customer-managed keys, it asks for the location of the key (The default is an Azure Key Vault) and the key name. Once completed, save the configuration.

From Azure CLI

Create the Key Vault

az keyvault create --name <name> --resource-group <resourceGroup> --location <location> --enabled-for-disk-encryption

Encrypt the disk and store the key in Key Vault

az vm encryption enable -g <resourceGroup> --name <name> --disk-encryption-keyvault myKV

From Azure PowerShell

This process uses a Key Vault to store the keys. Create the Key Vault

New-AzKeyvault -name <name> -ResourceGroupName <resourceGroup> -Location <location> -EnabledForDiskEncryption

Encrypt the disk and store the key in Key Vault

$KeyVault = Get-AzKeyVault -VaultName <name> -ResourceGroupName <resourceGroup>
Set-AzVMDiskEncryptionExtension -ResourceGroupName <resourceGroup> -VMName <name> -DiskEncryptionKeyVaultUrl $KeyVault.VaultUri -DiskEncryptionKeyVaultId $KeyVault.ResourceId

References

CLI
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disk-encryption-cli-quickstart
Powershell
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disk-encryption-powershell-quickstart
https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-data-protection#dp-5-encrypt-sensitive-data-at-rest
Convert VHD to Managed Disk
https://docs.microsoft.com/en-us/previous-versions/azure/virtual-machines/scripts/virtual-machines-powershell-sample-create-managed-disk-from-vhd