Terraform Purge Protection Disabled
Description
Detects Azure Key Vaults that have purge protection disabled or not configured, which could allow permanent deletion of sensitive key material. Without purge protection, deleted keys, secrets and certificates can be permanently erased, preventing recovery even within the standard retention period.
Detection Strategy
• Identifies 'azurerm_key_vault' resources in Terraform configurations
• Reports a vulnerability if 'purge_protection_enabled' attribute is explicitly set to 'false'
• Reports a vulnerability if 'purge_protection_enabled' attribute is missing/not configured
Vulnerable code example
resource "azurerm_key_vault" "vulnerable" {
name = "examplekeyvault"
location = "eastus"
resource_group_name = "example-rg"
enabled_for_disk_encryption = true
tenant_id = "tenant-id"
soft_delete_retention_days = 7
purge_protection_enabled = false # Vulnerable: Disabled purge protection allows permanent deletion of secrets...✅ Secure code example
resource "azurerm_key_vault" "secure" {
name = "examplekeyvault"
location = "eastus"
resource_group_name = "example-rg"
enabled_for_disk_encryption = true
tenant_id = data.azurerm_client_config.current.tenant_id # Use dynamic tenant ID from current config
soft_delete_retention_days = 90 # Increased retention period for better security
purge_protection_enabled = true # Enable purge protection to prevent permanent deletion...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.