terraform.azure.security.azure-automation-encrypted.azure-automation-encrypted

profile photo of semgrepsemgrep
Author
unknown
Download Count*

Ensure that Automation account variables are encrypted

Run Locally

Run in CI

Defintion

rules:
  - id: azure-automation-encrypted
    patterns:
      - pattern-either:
          - pattern-inside: |
              resource "azurerm_automation_variable_string" "..." {
              ...
              }
          - pattern-inside: |
              resource "azurerm_automation_variable_datetime" "..." {
              ...
              }
          - pattern-inside: |
              resource "azurerm_automation_variable_int" "..." {
              ...
              }
      - pattern-not-inside: |
          resource "azurerm_automation_variable_string" "..." {
          ...
          encrypted = true
          ...
          }
      - pattern-not-inside: |
          resource "azurerm_automation_variable_datetime" "..." {
          ...
          encrypted = true
          ...
          }
      - pattern-not-inside: |
          resource "azurerm_automation_variable_int" "..." {
          ...
          encrypted = true
          ...
          }
    message: Ensure that Automation account variables are encrypted
    languages:
      - hcl
    severity: WARNING
    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

Examples

azure-automation-encrypted.tf

# fail
# ruleid: azure-automation-encrypted
resource "azurerm_automation_variable_string" "example" {
    name                    = "tfex-example-var"
    resource_group_name     = azurerm_resource_group.example.name
    automation_account_name = azurerm_automation_account.example.name
    value                   = "Hello, Terraform Basic Test."
    encrypted               = false
}

# fail
# ruleid: azure-automation-encrypted
resource "azurerm_automation_variable_datetime" "example" {
    name                    = "tfex-example-var"
    resource_group_name     = azurerm_resource_group.example.name
    automation_account_name = azurerm_automation_account.example.name
    value                   = "Hello, Terraform Basic Test."
}

# pass
resource "azurerm_automation_variable_int" "example" {
    name                    = "tfex-example-var"
    resource_group_name     = azurerm_resource_group.example.name
    automation_account_name = azurerm_automation_account.example.name
    value                   = "Hello, Terraform Basic Test."
    encrypted               = true
}