Review WAF configuration for Azure Application Gateway

Apply required WAF inspection and blocking to web traffic.

Description

Check the WAF configuration or policy applied to the Application Gateway listener and path that serve your application. Selecting Prevention has no effect while the WAF is disabled.

Potential impact

Requests that should be blocked can reach the backend through an unprotected path.

Remediation

On a WAF-capable SKU, the inline waf_configuration applies gateway-wide. To protect a specific listener or path, associate a WAF policy with it. Detection logs rule matches. To block matching requests, use Prevention and test that legitimate traffic still passes.

Examples

Both excerpts select rule set 3.2 and Prevention. The second changes enabled to true. Supply the WAF_v2 SKU, listeners, backends and routing rules in the full configuration.

Before

hcl
resource "azurerm_application_gateway" "example" {
  name                = "example-appgateway"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location

  waf_configuration {
    firewall_mode    = "Prevention"
    rule_set_version = "3.2"
    enabled = false
  }
}

After

hcl
resource "azurerm_application_gateway" "example" {
  name                = "example-appgateway"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location

  waf_configuration {
    firewall_mode    = "Prevention"
    rule_set_version = "3.2"
    enabled = true
  }
}

References