Skip to content

Commit 33d52fa

Browse files
authored
Merge pull request #210617 from johndowns/waf-front-door-exclusions
Front Door WAF - Update exclusions documentation
2 parents 3670f4f + f53fb5a commit 33d52fa

File tree

9 files changed

+303
-44
lines changed

9 files changed

+303
-44
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
---
2+
title: Configure WAF exclusion lists for Front Door
3+
description: Learn how to configure a WAF exclusion list for an existing Front Door endpoint.
4+
services: web-application-firewall
5+
author: johndowns
6+
ms.service: web-application-firewall
7+
ms.date: 10/18/2022
8+
ms.author: jodowns
9+
ms.topic: conceptual
10+
zone_pivot_groups: web-application-firewall-configuration
11+
---
12+
13+
# Configure Web Application Firewall exclusion lists
14+
15+
Sometimes the Front Door Web Application Firewall (WAF) might block a legitimate request. As part of tuning your WAF, you can configure the WAF to allow the request for your application. WAF exclusion lists allow you to omit specific request attributes from a WAF evaluation. The rest of the request is evaluated as normal. For more information about exclusion lists, see [Web Application Firewall (WAF) with Front Door exclusion lists](waf-front-door-exclusion.md).
16+
17+
An exclusion list can be configured by using [Azure PowerShell](/powershell/module/az.frontdoor/New-AzFrontDoorWafManagedRuleExclusionObject), the [Azure CLI](/cli/azure/network/front-door/waf-policy/managed-rules/exclusion#az-network-front-door-waf-policy-managed-rules-exclusion-add), the [REST API](/rest/api/frontdoorservice/webapplicationfirewall/policies/createorupdate), Bicep, ARM templates, and the Azure portal.
18+
19+
## Scenario
20+
21+
Suppose you've created an API. Your clients send requests to your API that include headers with names like `userid` and `user-id`.
22+
23+
While tuning your WAF, you've noticed that some legitimate requests have been blocked because the user headers included character sequences that the WAF detected as SQL injection attacks. Specifically, rule ID 942230 detects the request headers and blocks the requests. [Rule 942230 is part of the SQLI rule group.](waf-front-door-drs.md#drs942-20)
24+
25+
You decide to create an exclusion to allow these legitimate requests to pass through without the WAF blocking them.
26+
27+
::: zone pivot="portal"
28+
29+
## Create an exclusion
30+
31+
1. Open your Front Door WAF policy.
32+
33+
1. Select **Managed rules**, and then select **Manage exclusions** on the toolbar.
34+
35+
:::image type="content" source="../media/waf-front-door-exclusion-configure/managed-rules-exclusion.png" alt-text="Screenshot of the Azure portal showing the WAF policy's managed rules page, with the 'Manage exclusions' button highlighted." :::
36+
37+
1. Select the **Add** button.
38+
39+
:::image type="content" source="../media/waf-front-door-exclusion-configure/exclusion-add.png" alt-text="Screenshot of the Azure portal showing the exclusion list, with the Add button highlighted." :::
40+
41+
1. Configure the exclusion's **Applies to** section as follows:
42+
43+
| Field | Value |
44+
|-|-|
45+
| Rule set | Microsoft_DefaultRuleSet_2.0 |
46+
| Rule group | SQLI |
47+
| Rule | 942230 Detects conditional SQL injection attempts |
48+
49+
1. Configure the exclusion match conditions as follows:
50+
51+
| Field | Value |
52+
|-|-|
53+
| Match variable | Request header name |
54+
| Operator | Starts with |
55+
| Selector | user |
56+
57+
1. Review the exclusion, which should look like the following screenshot:
58+
59+
:::image type="content" source="../media/waf-front-door-exclusion-configure/exclusion-details.png" alt-text="Screenshot of the Azure portal showing the exclusion configuration." :::
60+
61+
This exclusion applies to any request headers that start with the word `user`. The match condition is case insensitive, so headers that start with `User` are also covered by the exclusion. If WAF rule 942230 detects a risk in these header values, it ignores the header and moves on.
62+
63+
1. Select **Save**.
64+
65+
::: zone-end
66+
67+
::: zone pivot="powershell"
68+
69+
## Define an exclusion selector
70+
71+
Use the [New-AzFrontDoorWafManagedRuleExclusionObject](/powershell/module/az.frontdoor/new-azfrontdoorwafmanagedruleexclusionobject) cmdlet to define a new exclusion selector.
72+
73+
The following example identifies request headers that start with the word `user`. The match condition is case insensitive, so headers that start with `User` are also covered by the exclusion.
74+
75+
```azurepowershell
76+
$exclusionSelector = New-AzFrontDoorWafManagedRuleExclusionObject `
77+
-Variable RequestHeaderNames `
78+
-Operator StartsWith `
79+
-Selector 'user'
80+
```
81+
82+
## Define a per-rule exclusion
83+
84+
Use the [New-AzFrontDoorWafManagedRuleOverrideObject](/powershell/module/az.frontdoor/new-azfrontdoorwafmanagedruleoverrideobject) cmdlet to define a new per-rule exclusion, which includes the selector you created in the previous step.
85+
86+
The following example creates an exclusion for rule ID 942230.
87+
88+
```azurepowershell
89+
$exclusion = New-AzFrontDoorWafManagedRuleOverrideObject `
90+
-RuleId '942230' `
91+
-Exclusion $exclusionSelector
92+
```
93+
94+
## Apply the exclusion to the rule group
95+
96+
Use the [New-AzFrontDoorWafRuleGroupOverrideObject](/powershell/module/az.frontdoor/new-azfrontdoorwafrulegroupoverrideobject) cmdlet to create a rule group override, which applies the exclusion to the appropriate rule group.
97+
98+
The example below uses the SQLI rule group, because that group contains rule ID 942230.
99+
100+
```azurepowershell
101+
$ruleGroupOverride = New-AzFrontDoorWafRuleGroupOverrideObject `
102+
-RuleGroupName 'SQLI' `
103+
-ManagedRuleOverride $exclusion
104+
```
105+
106+
## Configure the managed rule set
107+
108+
Use the [New-AzFrontDoorWafManagedRuleObject](/powershell/module/az.frontdoor/new-azfrontdoorwafmanagedruleobject) cmdlet to configure the managed rule set, including the rule group override that you created in the previous step.
109+
110+
The example below configures the DRS 2.0 rule set with the rule group override and its exclusion.
111+
112+
```azurepowershell
113+
$managedRuleSet = New-AzFrontDoorWafManagedRuleObject `
114+
-Type 'Microsoft_DefaultRuleSet' `
115+
-Version '2.0' `
116+
-Action Block `
117+
-RuleGroupOverride $ruleGroupOverride
118+
```
119+
120+
## Apply the managed rule set configuration to the WAF profile
121+
122+
Use the [Update-AzFrontDoorWafPolicy](/powershell/module/az.frontdoor/update-azfrontdoorwafpolicy) cmdlet to update your WAF policy to include the configuration you created above. Ensure that you use the correct resource group name and WAF policy name for your own environment.
123+
124+
```azurepowershell
125+
Update-AzFrontDoorWafPolicy `
126+
-ResourceGroupName 'FrontDoorWafPolicy' `
127+
-Name 'WafPolicy'
128+
-ManagedRule $managedRuleSet
129+
```
130+
131+
::: zone-end
132+
133+
::: zone pivot="cli"
134+
135+
## Create an exclusion
136+
137+
Use the [`az network front-door waf-policy managed-rules exclusion add`](/cli/azure/network/front-door/waf-policy/managed-rules/exclusion) command to update your WAF policy to add a new exclusion.
138+
139+
The exclusion identifies request headers that start with the word `user`. The match condition is case insensitive, so headers that start with `User` are also covered by the exclusion.
140+
141+
Ensure that you use the correct resource group name and WAF policy name for your own environment.
142+
143+
```azurecli
144+
az network front-door waf-policy managed-rules exclusion add \
145+
--resource-group FrontDoorWafPolicy \
146+
--policy-name WafPolicy \
147+
--type Microsoft_DefaultRuleSet \
148+
--rule-group-id SQLI \
149+
--rule-id 942230 \
150+
--match-variable RequestHeaderNames \
151+
--operator StartsWith \
152+
--value user
153+
```
154+
155+
::: zone-end
156+
157+
::: zone pivot="bicep"
158+
159+
## Example Bicep file
160+
161+
The following example Bicep file shows how to do the following steps:
162+
163+
- Create a Front Door WAF policy.
164+
- Enable the DRS 2.0 rule set.
165+
- Configure an exclusion for rule 942230, which exists within the SQLI rule group. This exclusion applies to any request headers that start with the word `user`. The match condition is case insensitive, so headers that start with `User` are also covered by the exclusion. If WAF rule 942230 detects a risk in these header values, it ignores the header and moves on.
166+
167+
```bicep
168+
param wafPolicyName string = 'WafPolicy'
169+
170+
@description('The mode that the WAF should be deployed using. In "Prevention" mode, the WAF will block requests it detects as malicious. In "Detection" mode, the WAF will not block requests and will simply log the request.')
171+
@allowed([
172+
'Detection'
173+
'Prevention'
174+
])
175+
param wafMode string = 'Prevention'
176+
177+
resource wafPolicy 'Microsoft.Network/frontDoorWebApplicationFirewallPolicies@2022-05-01' = {
178+
name: wafPolicyName
179+
location: 'Global'
180+
sku: {
181+
name: 'Premium_AzureFrontDoor'
182+
}
183+
properties: {
184+
policySettings: {
185+
enabledState: 'Enabled'
186+
mode: wafMode
187+
}
188+
managedRules: {
189+
managedRuleSets: [
190+
{
191+
ruleSetType: 'Microsoft_DefaultRuleSet'
192+
ruleSetVersion: '2.0'
193+
ruleSetAction: 'Block'
194+
ruleGroupOverrides: [
195+
{
196+
ruleGroupName: 'SQLI'
197+
rules: [
198+
{
199+
ruleId: '942230'
200+
enabledState: 'Enabled'
201+
action: 'AnomalyScoring'
202+
exclusions: [
203+
{
204+
matchVariable: 'RequestHeaderNames'
205+
selectorMatchOperator: 'StartsWith'
206+
selector: 'user'
207+
}
208+
]
209+
}
210+
]
211+
}
212+
]
213+
}
214+
]
215+
}
216+
}
217+
}
218+
```
219+
220+
::: zone-end
221+
222+
## Next steps
223+
224+
- Learn more about [Front Door](../../frontdoor/front-door-overview.md).

0 commit comments

Comments
 (0)