MEDIUM
Source
Trivy/CSPM
CSPM ID
key-expiration-enabled
ID
AVD-AZU-0014

Ensure that the expiration date is set on all keys

Expiration Date is an optional Key Vault Key behavior and is not set by default.

Set when the resource will be become inactive.

Impact

Follow the appropriate remediation steps below to resolve the issue.

  1. Log into the Microsoft Azure Management Console.

  2. Select the “Search resources, services, and docs” option at the top and search for Key Vault . Step

  3. On the “Key vault” page, select the “Key Vault” for which keys need to be verified.Step

  4. On the “Key vaults-test-vault-azure” page, scroll down the left navigation panel and choose the “Keys” option.Step

  5. On the “Key vaults-test-vault-azure - Keys” page, select the key and check for the “Expiration Date”. If no “Expiration Date” is showing then the select “Key” do not have “Key Expiration Enabled.”Step

  6. Repeat steps number 2 - 5 to verify other “Keys” in the “Key vaults."

  7. Navigate to the “Key vault”, scroll down the left naviagtion panel and choose the “Keys” option.

  8. Select the “Key” which needs to have “Key Expiration Enabled” by clicking on the “Name” as a link option.

  9. On the “Key vaults - Keys” page click on the “Current Version” of the selected key.

  10. On the selected “key” page, click on the “Activation Date” and select the “Date and Time” accordingly. Select the “Set expiration date” and “Time” as per the requirements under the “Settings” tab.

  11. Click on the “Save” button at the top to make the changes.

  12. Repeat steps number 7 - 11 to enable “Key Expiration” for all the keys in the account.

Set an expiration date on the vault key

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 resource "azurerm_key_vault_key" "good_example" {
   name         = "generated-certificate"
   key_vault_id = azurerm_key_vault.example.id
   key_type     = "RSA"
   key_size     = 2048
   expiration_date = "1982-12-31T00:00:00Z"
 
   key_opts = [
     "decrypt",
     "encrypt",
     "sign",
     "unwrapKey",
     "verify",
     "wrapKey",
   ]
 }