<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Peakhour.IO - Managed Rules</title><link href="https://www.peakhour.io/" rel="alternate"></link><link href="https://www.peakhour.io/feeds/tag/managed-rules.atom.xml" rel="self"></link><id>https://www.peakhour.io/</id><updated>2026-07-29T09:15:00+10:00</updated><entry><title>How to Tune AWS WAF with Count, Labels and Rule Priority</title><link href="https://www.peakhour.io/blog/how-to-tune-aws-waf/" rel="alternate"></link><published>2026-07-29T09:15:00+10:00</published><updated>2026-07-29T09:15:00+10:00</updated><author><name>AC</name></author><id>tag:www.peakhour.io,2026-07-29:/blog/how-to-tune-aws-waf/</id><summary type="html">&lt;p&gt;Use Count overrides, managed-rule labels and rule priority to fix AWS WAF false positives while keeping the rest of the managed rule group in force.&lt;/p&gt;</summary><content type="html">&lt;p&gt;An AWS managed rule blocks a real customer. You find the request, change the entire rule group to Count and promise to revisit it next week.&lt;/p&gt;
&lt;p&gt;Six months later, it is still counting.&lt;/p&gt;
&lt;p&gt;AWS WAF lets you change one rule inside a managed rule group to Count, keep the label it adds to matching requests and add a blocking rule immediately after the group. The other managed rules keep their configured actions throughout the investigation.&lt;/p&gt;
&lt;p&gt;The &lt;a href="/blog/how-to-tune-your-waf/"&gt;general WAF tuning guide&lt;/a&gt; explains how to classify the request and document the exception. The AWS configuration begins with the managed rule that matched.&lt;/p&gt;
&lt;h2&gt;Put the rule in Count&lt;/h2&gt;
&lt;p&gt;Start with the named rule that caused the false positive.&lt;/p&gt;
&lt;p&gt;AWS WAF lets you apply a rule action override to an individual rule inside a managed rule group. Set that rule to &lt;code&gt;Count&lt;/code&gt;. The override changes how that rule handles matches in your web ACL; it leaves the managed rule group itself unchanged. AWS describes Count as a non-terminating action, so evaluation continues through the rules that follow. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-rule-group-override-options.html"&gt;AWS documents individual rule action overrides and the behaviour of Count&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Use the individual override for this job. The older rule-group return override changes the result returned by the group after its internal evaluation. AWS recommends rule action overrides when you want the rules inside the group to count their matches.&lt;/p&gt;
&lt;p&gt;Keep the change small:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Record the managed rule group, version and rule name.&lt;/li&gt;
&lt;li&gt;Change that rule to Count.&lt;/li&gt;
&lt;li&gt;Leave the remaining rules at their current actions.&lt;/li&gt;
&lt;li&gt;Reproduce the legitimate request.&lt;/li&gt;
&lt;li&gt;Check the Count match and the label added by the managed rule.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;AWS Managed Rules add labels to matching requests, and later rules in the same web ACL can inspect those labels. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-labels.html"&gt;AWS lists labels as the supported way to create exceptions for managed rule groups&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Read the request that matched&lt;/h2&gt;
&lt;p&gt;The sampled-requests view supports a quick investigation. Full WAF logs provide the history needed to compare matches across users, hosts or endpoints.&lt;/p&gt;
&lt;p&gt;With the rule set to Count, look for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the managed rule name;&lt;/li&gt;
&lt;li&gt;its fully qualified label;&lt;/li&gt;
&lt;li&gt;host, URI and method;&lt;/li&gt;
&lt;li&gt;the matching request component, when AWS supplies it;&lt;/li&gt;
&lt;li&gt;the final action taken on the request;&lt;/li&gt;
&lt;li&gt;the number of clients and routes producing the same match.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;AWS records Count matches from managed rule groups under &lt;code&gt;ruleGroupList[].nonTerminatingMatchingRules&lt;/code&gt;. Labels added during evaluation appear in the top-level &lt;code&gt;labels&lt;/code&gt; field. AWS populates &lt;code&gt;ruleMatchDetails&lt;/code&gt; for SQL injection and cross-site scripting match statements. Other managed detections may provide less detail. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/logging-fields.html"&gt;The AWS WAF log-field reference describes these fields and their limits&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Treat request data as customer data. Query strings, headers and bodies may contain credentials or personal information. Logging redaction applies to the configured log destination. Web ACL data protection masks matching data before it reaches either logs or sampled requests. Disable sampled requests when they could expose a field that data protection does not cover. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-data-protection-and-logging.html"&gt;AWS explains the distinction in its logging and data-protection guidance&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Group repeated matches by rule name, label, host, path and method. Ask the developer who owns the route what the field means and how the application uses it. Investigate a JSON field containing source code separately from a malformed body that the application accepts.&lt;/p&gt;
&lt;h2&gt;Block the managed-rule label in the next rule&lt;/h2&gt;
&lt;p&gt;Suppose a managed SQL injection rule repeatedly matches legitimate messages sent to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;POST api.example.com/v1/messages
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The managed rule now runs in Count and adds its documented label. Add a custom rule after the managed rule group. That custom rule should match:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;the managed-rule label
AND NOT (
    host = api.example.com
    AND path = /v1/messages
    AND method = POST
)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Give the custom rule a Block action.&lt;/p&gt;
&lt;p&gt;Requests that match the managed rule continue to be blocked everywhere except the route you reviewed. On that route, this particular managed-rule match can pass to the rules that follow and eventually to the web ACL's default action.&lt;/p&gt;
&lt;p&gt;The order creates the behaviour. AWS WAF evaluates rules from the lowest numeric priority upwards. A later rule can see a label only after the managed rule has added it. Put the managed rule group first and the label-matching rule directly after it. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-processing-order.html"&gt;AWS documents both priority order&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-label-overview.html"&gt;when labels become available to later rules&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Check the rules that come before the group as well. An earlier &lt;code&gt;Allow&lt;/code&gt; or &lt;code&gt;Block&lt;/code&gt; action ends evaluation before the managed rule runs. AWS documents &lt;code&gt;Allow&lt;/code&gt; and &lt;code&gt;Block&lt;/code&gt; as terminating actions, while Count continues to later rules. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-rule-actions.html"&gt;The rule-action guide explains how actions and priority interact&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;The exception covers every field on the exempt route&lt;/h2&gt;
&lt;p&gt;The label tells you that the managed rule matched. AWS applies the later rule action to that match for the whole request.&lt;/p&gt;
&lt;p&gt;On the exempt route, the later Block rule ignores that label regardless of which request field caused the managed-rule match. A different field can trigger the same rule and receive the same exception.&lt;/p&gt;
&lt;p&gt;Keep the condition tied to the smallest stable part of the application:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;exact host;&lt;/li&gt;
&lt;li&gt;exact path or a reviewed path family;&lt;/li&gt;
&lt;li&gt;HTTP method;&lt;/li&gt;
&lt;li&gt;another server-controlled distinction, when one exists.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A query parameter, header or cookie supplied by the client can narrow which requests match the exception. Confirm the matched request component from the event investigation.&lt;/p&gt;
&lt;p&gt;AWS also supports a scope-down statement on a managed rule group. The statement selects which requests enter the group for inspection; every other request bypasses the whole group. Reserve that option for traffic the whole rule group should exclude. AWS describes this evaluation behaviour in its &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-scope-down-statements.html"&gt;scope-down statement documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Test the complete rule path&lt;/h2&gt;
&lt;p&gt;Replay this test set:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the original legitimate request on the exempt route;&lt;/li&gt;
&lt;li&gt;the same harmless input on another route;&lt;/li&gt;
&lt;li&gt;a safe security test that triggers the managed rule on the exempt route;&lt;/li&gt;
&lt;li&gt;the same test on another route;&lt;/li&gt;
&lt;li&gt;requests that match earlier terminating rules;&lt;/li&gt;
&lt;li&gt;normal requests that should pass unchanged.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then check the WAF logs. Confirm that the managed rule still counts and labels the request, the later rule blocks the label outside the exception, and the final action is the one you intended.&lt;/p&gt;
&lt;p&gt;Run the configuration against production traffic in Count while you establish its normal match rate. AWS recommends monitoring metrics, sampled requests and logs, then repeating the tuning cycle until the web ACL behaves as intended. AWS also recommends completing the final stage with production traffic. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-testing-activities.html"&gt;Its testing guidance lays out that process&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Restore enforcement&lt;/h2&gt;
&lt;p&gt;The label rule can remain as the enforcement point when the application genuinely needs a route-specific exception. Document:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the managed rule group and version;&lt;/li&gt;
&lt;li&gt;the original rule action;&lt;/li&gt;
&lt;li&gt;the overridden rule name and label;&lt;/li&gt;
&lt;li&gt;the hosts, paths and methods allowed through;&lt;/li&gt;
&lt;li&gt;the application owner who confirmed the behaviour;&lt;/li&gt;
&lt;li&gt;the requests used to test the change;&lt;/li&gt;
&lt;li&gt;the logs and metrics that will reveal a regression;&lt;/li&gt;
&lt;li&gt;the next review date.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the development team removes the input that caused the false positive, remove the custom exception and return the managed rule to its original action. Test that change in Count first, then restore enforcement.&lt;/p&gt;
&lt;p&gt;Review the exception after managed rule group updates and application releases. AWS managed groups can use versioned releases, and the label, traffic shape or rule behaviour you investigated may change with the deployed version. &lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-list.html"&gt;AWS publishes the available managed groups, their rules and their labels&lt;/a&gt;.&lt;/p&gt;</content><category term="Application Security"></category><category term="AWS WAF"></category><category term="WAF"></category><category term="Application Security"></category><category term="Managed Rules"></category><category term="False Positives"></category><category term="WAF Tuning"></category></entry></feed>