terraform.azure.security.functionapp.functionapp-enable-http2.functionapp-enable-http2

profile photo of semgrepsemgrep
Author
unknown
Download Count*

Use the latest version of HTTP to ensure you are benefiting from security fixes. Add http2_enabled = true to your function app resource block

Run Locally

Run in CI

Defintion

rules:
  - id: functionapp-enable-http2
    message: Use the latest version of HTTP to ensure you are benefiting from
      security fixes. Add `http2_enabled = true` to your function app resource
      block
    patterns:
      - pattern: resource
      - pattern-not-inside: |
          resource "azurerm_function_app" "..." {
          ...
            site_config {
              ...
              http2_enabled = true
              ...
            }
          ...
          }
      - pattern-either:
          - pattern-inside: |
              resource "azurerm_function_app" "..." {
              ...
              }
          - pattern-inside: |
              resource "azurerm_function_app" "..." {
              ...
                site_config {
                  ...
                  http2_enabled = false
                  ...
                }
              ...
              }
    metadata:
      cwe:
        - "CWE-444: Inconsistent Interpretation of HTTP Requests ('HTTP
          Request/Response Smuggling')"
      category: security
      technology:
        - terraform
        - azure
      references:
        - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app#http2_enabled
      owasp:
        - A04:2021 - Insecure Design
      subcategory:
        - audit
      likelihood: LOW
      impact: LOW
      confidence: LOW
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]
      vulnerability_class:
        - Improper Validation
    languages:
      - hcl
    severity: INFO

Examples

functionapp-enable-http2.tf

resource "azurerm_function_app" "good_example" {
  name                = "example-function-app"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_function_app_plan.example.id

  site_config {
      http2_enabled = true
  }
}
# ruleid: functionapp-enable-http2
resource "azurerm_function_app" "bad_example" {
  name                = "example-function-app"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_function_app_plan.example.id

  site_config {
      http2_enabled = false
  }
}

# ruleid: functionapp-enable-http2
resource "azurerm_function_app" "bad_example" {
  name                = "example-function-app"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_function_app_plan.example.id
}