AWS WAF, Under the Hood
An expert-level walkthrough of how the Web ACL rule evaluation engine actually processes every request — for engineers who already know what a firewall rule is, and want to understand Web ACL Capacity Units, rule priority and labeling, managed rule group internals, and why a poorly ordered rule set can silently degrade both security and legitimate traffic.
AWS WAF is frequently deployed as a checkbox — attach a managed rule group, move on — which captures almost none of what makes the service genuinely powerful or genuinely dangerous to misconfigure. Underneath the console’s rule list sits a precise, ordered evaluation engine governed by Web ACL Capacity Units, rule priority, and a labeling system that lets rules communicate with each other mid-evaluation, all of it capable of either meaningfully hardening an application against real attacks or silently blocking legitimate customer traffic if configured carelessly. This guide skips the “add a managed rule group” introduction and goes straight into the advanced mechanics: how the rule evaluation engine actually processes a request in priority order, how WCU budgets constrain rule complexity, how rule labeling enables sophisticated multi-rule logic, and where teams get burned by deploying blocking rules without first validating them in count mode.
1Internal Working: Web ACLs, Rules, and the Evaluation Engine
A Web ACL is not a single filter but an ordered, priority-driven collection of rules and rule groups, evaluated sequentially against every request until a terminating action is reached — and that sequential, priority-driven nature explains nearly every advanced WAF behavior.
A Web ACL is attached to one of four supported resource types — CloudFront distributions, Application Load Balancers, API Gateway REST APIs, or AppSync GraphQL APIs — and every request to that resource is evaluated against the Web ACL’s rules in strict priority order. Each rule contains a statement (the condition being matched — an IP set, a regex pattern, a SQL injection detection, a geographic match) and an action (allow, block, count, CAPTCHA, or challenge). Critically, most actions are terminating: once a rule with a block or allow action matches, evaluation stops immediately and later rules are never even evaluated — while count actions are explicitly non-terminating, allowing evaluation to continue to subsequent rules regardless of the match.
Think of the Web ACL as airport security with an ordered sequence of checkpoints. A traveler flagged and definitively rejected at an early checkpoint (a terminating block) never reaches the checkpoints after it — but a checkpoint that simply logs a traveler’s details without stopping them (count) lets that traveler continue on to every subsequent checkpoint, accumulating whatever additional flags those checkpoints add along the way.
Rule groups — reusable, self-contained bundles of rules, either AWS-managed, AWS Marketplace-provided, or customer-authored — are themselves evaluated as a single unit within the Web ACL’s priority order, but the individual rules inside a rule group retain their own internal priority and terminating behavior relative to each other. This nested evaluation model is precisely why understanding rule and rule-group priority together, not in isolation, is essential for predicting how a complex, multi-rule-group Web ACL will actually behave against a given request.
Because most actions terminate evaluation immediately, a broadly scoped allow rule placed at a low priority number (evaluated early) can silently prevent every subsequent, more specific block rule from ever running — a request matching that early allow never reaches the security-critical rules positioned later, regardless of how well those later rules are configured.
2Data Flow: A Request’s Journey Through the Web ACL
Every request evaluated by a Web ACL follows a deterministic path through rule priority order, potentially picking up labels along the way that later rules can specifically match on — a mechanism that enables genuinely sophisticated, multi-stage detection logic.
flowchart TD
A["Request arrives at CloudFront / ALB / API Gateway / AppSync"] --> B["Web ACL evaluation begins at lowest priority number"]
B --> C{"Rule statement matches?"}
C -- No --> D["Move to next rule in priority order"]
C -- Yes --> E{"Action type"}
E -- Block/Allow/CAPTCHA/Challenge --> F["Evaluation terminates; action applied"]
E -- Count --> G["Label applied if configured; evaluation continues"]
D --> C
G --> D
F --> H["Response returned or request forwarded to origin"]
D -.-> I{"End of rule list reached?"}
I -- Yes --> J["Default action (Allow or Block) applied"]
Labels are the mechanism that turns this otherwise linear evaluation into something closer to a small rules-based state machine: a rule can apply a label to a request when its statement matches (typically alongside a non-terminating count action), and a later rule in the same evaluation can specifically condition its own statement on the presence of that label — enabling patterns like “only block this request if it matched pattern A earlier AND matches pattern B now,” which no single rule statement could express in isolation.
If a request reaches the end of the entire rule list without triggering any terminating action, the Web ACL’s configured default action applies — typically allow, though a default of block is used in genuinely high-security, deny-by-default architectures. This default action is easy to overlook during testing but determines the fate of every single request that no explicit rule ever matched.
Priority Evaluation
Rules and rule groups evaluated strictly in ascending priority order, lowest number first.
Terminating Action
Block, Allow, CAPTCHA, and Challenge stop evaluation immediately upon match.
Label Propagation
Count actions can attach labels that later rules condition their own logic upon.
Default Action
Applies only when no rule in the entire list ever produced a terminating match.
3Rule Types & Managed Rule Groups
Custom rules, AWS managed rule groups, and rate-based rules each solve a genuinely different threat-detection problem, and advanced Web ACLs almost always layer several types together rather than relying on any single one.
Custom rules, authored directly by the customer, express application-specific logic — blocking a specific known-bad header value, or allowing traffic only from a specific set of partner IP ranges — that no generic managed rule group could anticipate. AWS managed rule groups (the Core Rule Set for OWASP Top 10-style protections, the SQL Database rule group, the Known Bad Inputs rule group, and specialized bot-control and account-takeover-prevention rule groups) are maintained and updated by AWS’s own threat intelligence, giving continuous protection against emerging attack patterns without requiring the customer to write or maintain detection logic themselves. Rate-based rules track request volume from a given key (typically source IP, but configurable to other request attributes) over a rolling time window, automatically blocking or challenging sources that exceed a defined threshold — the primary mechanism for mitigating application-layer request floods and credential-stuffing attempts that a static signature-based rule would never catch.
| Rule Type | Detects | Maintained By | Best For |
|---|---|---|---|
| Custom Rule | Application-specific patterns | Customer | Business-logic-specific protections |
| AWS Managed Rule Group | Known attack signatures, OWASP Top 10 | AWS Threat Intelligence | Broad, continuously updated baseline protection |
| Rate-Based Rule | Volumetric abuse from a single source | Customer-configured threshold | Request floods, credential stuffing, scraping |
Anti-Pattern
Deploying an AWS managed rule group directly in block mode against production traffic without first observing it in count mode.
Why It Fails
Managed rule groups are tuned for broad applicability across many applications and can produce false positives against a specific application’s legitimate traffic patterns (unusual but valid header formats, for example) that only become visible once real production traffic is actually evaluated against the rule.
Better Approach
Deploy new managed rule groups in count mode first, review sampled requests and metrics for unexpected matches against known-legitimate traffic, and only switch to block mode once false-positive risk has been genuinely validated.
4Advanced Configuration: Logical Statements, CAPTCHA, and Custom Responses
Beyond simple single-condition rules, WAF supports genuinely composable logical statements, interactive challenge actions, and fully customizable block responses — the configuration surface that separates a sophisticated rule set from a blunt allow/block list.
Statements can be combined using AND, OR, and NOT logical operators, and nested to arbitrary depth, letting a single rule express conditions like “block if the request matches a known bad-input pattern AND does not originate from an already-authenticated session cookie” — composability that dramatically reduces both the number of rules needed and the risk of gaps between multiple, independently written simpler rules.
The CAPTCHA and Challenge actions provide a middle ground between outright blocking and passive allowing: rather than immediately rejecting a suspicious but not definitively malicious request, these actions present an interactive or silent browser-based challenge, letting legitimate human users (or genuinely compliant browser clients, for Challenge) pass through while filtering out simple automated bots that cannot complete the verification — a materially better experience for edge-case traffic than an outright block, particularly valuable in layered bot-mitigation strategies.
Custom response bodies let a blocked request receive an application-appropriate error page or JSON payload rather than WAF’s generic default block response, which matters for API-fronting Web ACLs where a consuming client expects a specific, parseable error format even in a blocked-request scenario.
Reserve outright Block actions for high-confidence detections (known malicious signatures, confirmed bad IP reputation), and use CAPTCHA or Challenge for lower-confidence, higher-ambiguity signals (unusual but not definitively malicious request patterns) — this tiered-confidence approach measurably reduces the false-positive impact on legitimate users compared to a uniformly aggressive block-everything-suspicious posture.
5High Availability & Reliability
WAF’s own availability inherits directly from whichever service it’s attached to — CloudFront’s global edge network or a regional ALB/API Gateway/AppSync deployment — and the genuine reliability consideration for operators is designing rules so a WAF misconfiguration never becomes an availability incident of its own.
For CloudFront-attached Web ACLs, evaluation happens at CloudFront’s globally distributed edge locations, inheriting that service’s inherent geographic redundancy with no separate multi-region WAF configuration needed. For ALB, API Gateway, and AppSync-attached Web ACLs, evaluation is regional, tied to the availability of the underlying regional service itself, requiring no additional WAF-specific HA configuration beyond whatever multi-AZ design already exists for the protected resource.
The reliability risk genuinely worth designing around is self-inflicted: an overly aggressive or poorly tested blocking rule can functionally take down legitimate traffic just as effectively as an actual outage, and unlike an infrastructure failure, this kind of self-inflicted availability incident is entirely preventable through the count-mode validation discipline from Chapter 3 — advanced WAF operators treat every new blocking rule change with the same caution as a production infrastructure deployment, not as a purely security-team configuration change with no availability blast radius.
6Performance & Scalability: Web ACL Capacity Units
Every rule, statement, and managed rule group consumes a measured amount of Web ACL Capacity Units (WCU) against a fixed per-Web-ACL budget, and understanding WCU economics is essential for building sophisticated rule sets without hitting an unexpected capacity ceiling.
Each rule statement type has an associated WCU cost reflecting its actual computational complexity — a simple IP match statement costs relatively little, while a regex pattern match or a nested logical statement combining several conditions costs considerably more, and managed rule groups declare their own aggregate WCU cost as a bundled unit. A Web ACL has a fixed total WCU capacity, meaning advanced rule-set design genuinely involves budgeting: prioritizing which managed rule groups and custom rules to include, and how to structure logical statements efficiently, to stay within that ceiling while maximizing actual protection coverage.
WAF’s evaluation itself scales transparently with request volume — there is no separate throughput-based scaling configuration for the customer to manage, since the service scales automatically alongside the CloudFront distribution or regional resource it protects. The genuine capacity planning conversation in WAF is about rule complexity budget (WCU), not raw request throughput.
Production Example — Layered Managed Rule Groups
E-commerce platforms combining the Core Rule Set, the Known Bad Inputs rule group, a bot-control rule group, and several custom business-logic rules routinely need to actively manage their combined WCU budget, sometimes removing overlapping or lower-value managed rules to make room for a genuinely high-value custom rule addressing a specific, previously observed attack pattern against their own application.
7Security: Layered Defense Against OWASP Top 10, Bots, and Account Takeover
WAF’s security value comes from layering several distinct, purpose-built protection categories together, since no single rule group or rule type covers the full range of application-layer threats an internet-facing service actually faces.
The Core Rule Set managed rule group provides broad protection aligned with common OWASP Top 10 categories — SQL injection, cross-site scripting, and similar well-established web application vulnerability classes — serving as a genuinely solid baseline for nearly any web application. Layered on top, specialized rule groups for bot control and account-takeover-prevention address threats that signature-based detection alone can’t catch: bot control specifically distinguishes automated traffic (search engine crawlers, legitimate monitoring tools, versus scraping and credential-stuffing bots) using behavioral and fingerprinting signals, while account-takeover-prevention specifically monitors login endpoints for credential-stuffing patterns and compromised-credential usage.
Signature-Based Protection
- Core Rule Set covers common injection and scripting attack patterns
- Known Bad Inputs catches previously identified malicious payload patterns
Behavioral Protection
- Bot Control distinguishes automated from human traffic via fingerprinting
- Account Takeover Prevention monitors login-specific credential-stuffing patterns
Relying solely on the Core Rule Set and assuming it provides comprehensive protection — signature-based rule groups do not address volumetric abuse, credential stuffing, or sophisticated bot traffic, all of which require the additional layered rule types (rate-based rules, bot control, account-takeover-prevention) covered elsewhere in this guide.
8Monitoring, Logging & Metrics
WAF provides both a lightweight sampled-request view and a full, detailed logging pipeline, and advanced operators use the two together — sampled requests for quick investigation, full logs for rigorous rule tuning and compliance evidence.
Sampled requests, available directly in the console with no additional configuration, provide a rolling window of recent requests matched by each rule, including which specific rule and action applied — the fastest way to quickly sanity-check whether a rule is behaving as expected during initial rollout. For comprehensive, complete request logging (every single request, not a sample), WAF streams logs to Amazon Kinesis Data Firehose, from which they can be delivered to S3, further analyzed, or fed into a SIEM — the necessary foundation for rigorous false-positive analysis, compliance audit trails, and post-incident forensic investigation that sampled requests alone cannot fully support.
Quick Validation
Sampled requests confirm a newly deployed rule is matching the traffic it was designed to catch.
Full Log Capture
Kinesis Data Firehose delivers complete request logs to S3 or a SIEM for exhaustive analysis.
False-Positive Analysis
Full logs reveal exactly which legitimate traffic patterns a count-mode rule would have blocked, before it goes live.
CloudWatch Alerting
Per-rule metrics (allowed, blocked, counted request volume) drive alerting on sudden traffic-pattern shifts.
9Design Patterns & Anti-Patterns
The durable WAF configurations deliberately layer broad managed protection with narrow, validated custom rules, and treat every blocking change with genuine deployment rigor — the recurring anti-patterns almost always involve skipping that validation discipline.
Layered Managed + Custom Rules
A broad managed rule group baseline supplemented by narrow, application-specific custom rules addressing gaps the baseline can’t anticipate.
Count-First Rollout
Every new blocking rule or managed rule group is deployed in count mode first, validated against real traffic, and only switched to block after confirming low false-positive risk.
Priority Misordering
Placing a broad allow rule at a lower priority number than critical security rules causes those security rules to never actually evaluate for matching traffic.
Ignoring WCU Budget Until It’s Exhausted
Adding rules opportunistically without tracking cumulative WCU consumption leads to an unplannable scramble when the Web ACL’s capacity ceiling is finally hit.
10Advantages, Disadvantages & Trade-offs
WAF trades the genuine complexity of correctly ordering and validating a multi-layered rule set for continuously updated, deeply integrated application-layer protection that would be extremely costly to build and maintain independently.
Advantages
- Continuously updated managed rule groups from AWS threat intelligence, requiring no independent signature research
- Deep native integration across CloudFront, ALB, API Gateway, and AppSync with no separate infrastructure to run
- Composable logical statements and labels enable genuinely sophisticated, multi-condition detection logic
- Full request logging via Kinesis Data Firehose supports rigorous compliance and forensic requirements
Disadvantages
- Rule priority ordering mistakes can silently disable intended protections with no obvious error
- WCU capacity constraints require active budgeting as rule sets grow more sophisticated
- Poorly validated blocking rules can cause self-inflicted availability incidents against legitimate traffic
- Genuine mastery requires understanding several interacting concepts (priority, labels, WCU, terminating vs. non-terminating actions) simultaneously
11Best Practices & Common Mistakes
Nearly every advanced WAF incident traces back to a rule deployed straight to block mode without validation, a priority-ordering mistake, or an availability impact caused by treating a security rule change as lower-stakes than an infrastructure change.
Enabling a managed rule group directly in block mode against production traffic on day one — the single most common cause of WAF-related legitimate-traffic incidents, and one the count-mode validation workflow exists specifically to prevent.
12Real-World & Industry Examples
Advanced WAF deployments consistently cluster around e-commerce bot mitigation, API-fronting security, and DDoS-adjacent volumetric protection paired with AWS Shield.
E-Commerce Bot and Scraping Mitigation
Retail platforms facing persistent inventory-scraping and checkout-automation bots layer Bot Control with rate-based rules specifically to distinguish and throttle automated traffic without impacting genuine shoppers, a distinction static IP-blocking approaches alone cannot reliably make.
API Gateway Protection for Public APIs
Organizations exposing public APIs use custom rules and the Known Bad Inputs managed rule group directly on API Gateway-attached Web ACLs, paired with custom response bodies returning application-appropriate JSON error payloads rather than WAF’s generic default block response, keeping API consumers’ error-handling logic consistent even during a blocked request.
Volumetric Attack Mitigation Alongside AWS Shield
Organizations facing large-scale application-layer request floods pair rate-based WAF rules with AWS Shield Advanced, using WAF’s granular request-level filtering to handle application-layer abuse patterns that Shield’s network and transport-layer DDoS protection is not designed to address on its own.
13Frequently Asked Questions
14Summary and Key Takeaways
Key Takeaways
- Web ACL evaluation is strictly sequential and priority-ordered — most actions terminate evaluation immediately, making rule order a genuine security-critical decision.
- Labels enable multi-stage, stateful-feeling detection logic across otherwise independent rules within a single evaluation pass.
- Custom rules, managed rule groups, and rate-based rules solve genuinely different threat categories — layering all three is the norm, not a single one alone.
- Logical statements, CAPTCHA, and Challenge actions provide tiered-confidence responses rather than a binary block-or-allow posture.
- WCU is the real capacity constraint, not request throughput, which WAF scales transparently on its own.
- Count-mode validation before block mode is the single most important operational discipline for avoiding self-inflicted availability incidents.
- Full request logging via Kinesis Data Firehose is essential for rigorous compliance and forensic needs that sampled requests alone cannot satisfy.