Application Gateway should have WAF enabled

High Azure General appgw-waf

Applies to

  • Microsoft.Network/applicationGateways

What CGPulse checks

A resource passes this rule when webApplicationFirewall.enabled must equal true. Anything else is reported as a finding with the evaluated property value attached as evidence.

How to fix it

Enable WAF to block common web attacks like SQL injection and XSS. In Azure Portal: Application Gateway > Web application firewall > enable WAF (requires WAF_v2 SKU). See: https://learn.microsoft.com/en-us/azure/web-application-firewall/ag/ag-overview

CLI

az network application-gateway waf-config set --gateway-name "{name}" -g "{rg}" --enabled true --firewall-mode Prevention --rule-set-version 3.2

Bicep

// TODO: Start with Detection mode to monitor before switching to Prevention

resource appGw 'Microsoft.Network/applicationGateways@2023-11-01' existing = {{
  name: '{name}'
}}
// Note: WAF requires sku.name = 'WAF_v2'. If currently Standard_v2, update the SKU first

Terraform

# WAF requires WAF_v2 SKU - may increase costs
resource "azurerm_application_gateway" "{name}" {
  name                = "{name}"
  resource_group_name = "{rg}"
  location            = var.location
  sku {
    name = "WAF_v2"
    tier = "WAF_v2"
  }
  waf_configuration {
    enabled          = true
    firewall_mode    = "Prevention"
    rule_set_version = "3.2"
  }
  # Configure gateway_ip_configuration, frontend, backend, etc.
}

Compliance frameworks

Vendor documentation

Is your environment compliant with this rule?

CGPulse checks it — and 621 others — against your Azure and AWS accounts with read-only access.

Run a free scan

Related Azure rules

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.