Skip to content

Use WAF prevention mode#

Security · Application Gateway · Azure.AppGw.Prevention

Internet exposed Application Gateways should use prevention mode to protect backend resources.

Description#

Application Gateways with Web Application Firewall (WAF) enabled support two modes of operation:

  • Detection - Monitors and logs all threat alerts. In this mode, the WAF doesn't block incoming requests that are potentially malicious.
  • Protection - Blocks potentially malicious attack patterns that the rules detect.

Recommendation#

Consider switching Internet exposed Application Gateways to use prevention mode to protect backend resources.

Examples#

Configure with Azure template#

To deploy Application Gateways that pass this rule:

  • Set the properties.webApplicationFirewallConfiguration.firewallMode property to Prevention.

For example:

{
    "type": "Microsoft.Network/applicationGateways",
    "apiVersion": "2020-11-01",
    "name": "[parameters('appGwName')]",
    "location": "[resourceGroup().location]",
    "properties": {
        "sku": {
            "name": "WAF_v2",
            "tier": "WAF_v2"
        },
        "webApplicationFirewallConfiguration": {
            "enabled": true,
            "firewallMode": "Prevention",
            "ruleSetType": "OWASP",
            "ruleSetVersion": "3.2",
            "disabledRuleGroups": [],
            "requestBodyCheck": true,
            "maxRequestBodySizeInKb": 128,
            "fileUploadLimitInMb": 100
        }
    }
}

Configure with Bicep#

To deploy Application Gateways that pass this rule:

  • Set the properties.webApplicationFirewallConfiguration.firewallMode property to Prevention.

For example:

resource appGw 'Microsoft.Network/applicationGateways@2021-02-01' = {
  name: 'appGw-001'
  properties: {
    sku: {
      name: 'WAF_v2'
      tier: 'WAF_v2'
    }
    webApplicationFirewallConfiguration: {
      enabled: true
      firewallMode: 'Prevention'
      ruleSetType: 'OWASP'
      ruleSetVersion: '3.2'
    }
  }
}

Configure with Azure CLI#

az network application-gateway waf-config set --enabled true --firewall-mode Prevention -n '<name>' -g '<resource_group>'

Configure with Azure PowerShell#

$AppGw = Get-AzApplicationGateway -Name '<name>' -ResourceGroupName '<resource_group>'
Set-AzApplicationGatewayWebApplicationFirewallConfiguration -ApplicationGateway $AppGw -Enabled $True -FirewallMode 'Prevention'

Last update: 2021-09-24