terraform.azure.security.azure-managed-disk-encryption-set.azure-managed-disk-encryption-set

profile photo of semgrepsemgrep
Author
unknown
Download Count*

Ensure that managed disks use a specific set of disk encryption sets for the customer-managed key encryption

Run Locally

Run in CI

Defintion

rules:
  - id: azure-managed-disk-encryption-set
    message: Ensure that managed disks use a specific set of disk encryption sets
      for the customer-managed key encryption
    patterns:
      - pattern: resource
      - pattern-not-inside: |
          resource "azurerm_managed_disk" "..." {
          ...
          disk_encryption_set_id = ...
          ...
          }
      - pattern-inside: |
          resource "azurerm_managed_disk" "..." {
          ...
          }
    metadata:
      owasp:
        - A03:2017 - Sensitive Data Exposure
      cwe:
        - "CWE-320: CWE CATEGORY: Key Management Errors"
      category: security
      technology:
        - terraform
        - azure
      references:
        - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
      subcategory:
        - audit
      likelihood: LOW
      impact: LOW
      confidence: LOW
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]
      vulnerability_class:
        - Cryptographic Issues
    languages:
      - hcl
    severity: WARNING

Examples

azure-managed-disk-encryption-set.tf

# fail
# ruleid: azure-managed-disk-encryption-set
resource "azurerm_managed_disk" "source" {
    name                 = "acctestmd1"
    location             = "West US 2"
    resource_group_name  = azurerm_resource_group.example.name
    storage_account_type = "Standard_LRS"
    create_option        = "Empty"
    disk_size_gb         = "1"
    tags = {
    environment = "staging"
    }
}

# pass
resource "azurerm_managed_disk" "source" {
    name                 = "acctestmd1"
    location             = "West US 2"
    resource_group_name  = azurerm_resource_group.example.name
    storage_account_type = "Standard_LRS"
    create_option        = "Empty"
    disk_size_gb         = "1"
    disk_encryption_set_id = "koko"
    tags = {
    environment = "staging"
    }
}