How Amazon WAF handles rule and rule group actions in a web ACL
This section explains how Amazon WAF uses rules and rule groups to handle actions.
When you configure your rules and rule groups, you choose how you want Amazon WAF to handle matching web requests:
-
Allow and Block are terminating actions – Allow and Block actions stop all other processing of the web ACL on the matching web request. If a rule in a web ACL finds a match for a request and the rule action is Allow or Block, that match determines the final disposition of the web request for the web ACL. Amazon WAF doesn't process any other rules in the web ACL that come after the matching one. This is true for rules that you add directly to the web ACL and rules that are inside an added rule group. With the Block action, the protected resource doesn't receive or process the web request.
-
Count is a non-terminating action – When a rule with a Count action matches a request, Amazon WAF counts the request, then continues processing the rules that follow in the web ACL rule set.
-
CAPTCHA and Challenge can be non-terminating or terminating actions – When a rule with one of these actions matches a request, Amazon WAF checks its token status. If the request has a valid token, Amazon WAF treats the match similar to a Count match, and then continues processing the rules that follow in the web ACL rule set. If the request doesn't have a valid token, Amazon WAF terminates the evaluation and sends the client a CAPTCHA puzzle or silent background client session challenge to solve.
If the rule evaluation doesn't result in any terminating action, then Amazon WAF applies the web ACL default action to the request. For information, see Setting the web ACL default action in Amazon WAF.
In your web ACL, you can override the action settings for rules inside a rule group and you can override the action that's returned by a rule group. For information, see Overriding rule group actions in Amazon WAF.
Interaction between actions and priority settings
The actions that Amazon WAF applies to a web request are affected by the numeric priority settings of the rules in the web ACL. For example, say that your web ACL has a rule with Allow action and a numeric priority of 50 and another rule with Count action and a numeric priority of 100. Amazon WAF evaluates the rules in a web ACL in the order of their priority, starting from the lowest setting, so it will evaluate the allow rule before the count rule. A web request that matches both rules will match the allow rule first. Since Allow is a terminating action, Amazon WAF will stop the evaluation at this match and won't evaluate the request against the count rule.
If you only want to include requests that don't match the allow rule in your count rule metrics, then the priority settings of the rules would work.
On the other hand, if you want count metrics from the count rule even for requests that match the allow rule, you'd need to give the count rule a lower numeric priority setting than the allow rule, so that it runs first.
For more information about priority settings, see Setting rule priority in a web ACL.