AWS WAF · Web application firewall · L7

Inspects HTTP requests and decides in rule order

AWS WAF is a managed web application firewall that inspects HTTP(S) requests sent to resources such as CloudFront, ALB, and API Gateway. You stack rules in a web ACL by priority, and each request is handled with one of Allow, Block, Count, CAPTCHA, or Challenge.

web ACL · priority orderdefault: Allow

POST /api/login · 203.0.113.7 · UA: python-requests

  1. 0IP set · allowlistCorporate CIDRsno match
  2. 1AWSManagedRulesCommonRuleSetCore rule set · OWASP-class risksno match
  3. 2AWSManagedRulesBotControlRuleSetrule action override: Count+ awswaf:managed:aws:bot-control:bot:category:http_libraryCount
  4. 3block-bot-labellabel match → label added by an earlier ruleBlock

Count only adds labels and moves on to the next rule. Block ends evaluation and returns a 403.

5

Rule actions (Allow · Block · Count · CAPTCHA · Challenge)

1,500 WCU

Capacity included in the base web ACL price (up to 5,000)

9

Associable resource types

3

Log destinations (CloudWatch Logs · S3 · Firehose)

Why AWS WAF

When decisions must be based on request content, not ports

Security groups and Network Firewall look at addresses, ports, and flows. SQL injection, credential stuffing, and scraping bots happen inside legitimate HTTPS sessions, so you need an L7 layer that examines headers, query strings, bodies, and client behavior.

Inline

A firewall attached to the service

No separate appliance or routing changes: associate a web ACL with a resource such as a CloudFront distribution or ALB, and inspection starts immediately.

Managed

Move fast with managed rules

Use AWS Managed Rules and AWS Marketplace rule groups to block common web exploits, low-reputation IPs, and bots first, then layer custom rules on top.

Observe

Observe with Count first

Add rules in Count mode, check for false positives with CloudWatch metrics, sampled requests, and full logs, then switch them to Block.

Rules · labels

Rules are JSON statements; labels carry decisions forward

Below is a rate-based rule that limits requests per IP on the login path, excluding requests that carry the corporate-IP label. Using labels added by earlier rules as conditions in later rules lets you split rules into small pieces and combine them.

rate-limit-login.jsonwafv2 Rule
{
  "Name": "rate-limit-login",
  "Priority": 4,
  "Statement": {
    "RateBasedStatement": {
      "Limit": 100,
      "EvaluationWindowSec": 300,
      "AggregateKeyType": "IP",
      "ScopeDownStatement": { "AndStatement": { "Statements": [
        { "ByteMatchStatement": { "SearchString": "/api/login",
            "FieldToMatch": { "UriPath": {} }, "PositionalConstraint": "STARTS_WITH",
            "TextTransformations": [{ "Priority": 0, "Type": "LOWERCASE" }] } },
        { "NotStatement": { "Statement": { "LabelMatchStatement": {
            "Scope": "LABEL", "Key": "corp:trusted-ip" } } } }
      ] } }
    }
  },
  "Action": { "Block": {} },  // Allow is not supported
  "VisibilityConfig": { "SampledRequestsEnabled": true,
    "CloudWatchMetricsEnabled": true, "MetricName": "rate-limit-login" }
}
Example AWS WAF rule that applies a per-IP rate limit to the login path and excludes the trusted label
  1. Evaluated in priority order Priority

    A web ACL evaluates rules from the lowest number up. It stops at a terminating action such as Allow or Block; if nothing matches, the web ACL default action applies.

  2. Count and labels Label

    Count is a non-terminating action that records the match and moves on to the next rule. Labels added by rules and managed rule groups can be referenced by later rules in the same web ACL with LabelMatchStatement.

  3. Rate-based rule 60–600s

    Choose an evaluation window of 60, 120, 300, or 600 seconds; the minimum limit is 10. Requests are aggregated by combining keys such as IP, forwarded IP, headers, query arguments, and label namespaces. It is meant to curb high request rates, not to enforce precise quotas.

Features

Key features

Managed rules

AWS Managed Rules

Use versioned rule groups such as Core rule set, Known bad inputs, SQL database, and IP reputation. Override the action of individual rules in a group, or narrow their scope with a scope-down statement.

Bot Control

Bot detection and management

The Common level classifies self-identifying bots and labels them; the Targeted level also catches bots that hide their identity, using browser interrogation and behavioral analysis. Useful bots such as search engines are allowed after verification.

Fraud Control

ATP · ACFP

ATP detects credential stuffing and account takeover attempts on login pages; ACFP detects fake account creation on sign-up pages. Decisions use compromised-credential checks and session-level aggregation.

CAPTCHA · Challenge

Human and browser verification

CAPTCHA asks the user to solve a puzzle; Challenge silently checks the browser environment. On success, an AWS WAF token is issued and the client isn't asked again during the immunity time.

App integration

Client integration SDKs

With the JavaScript, iOS, and Android SDKs, clients acquire a token in advance and attach it to requests. SDK integration is recommended to get the full benefit of Bot Control Targeted and Fraud Control.

Logging

Full request logs

Send web ACL logs to CloudWatch Logs, Amazon S3, or Amazon Data Firehose. Destination names must start with aws-waf-logs-; use field redaction and log filtering to reduce volume.

L7 DDoS

Anti-DDoS managed rule group

AWSManagedRulesAntiDDoSRuleSet learns a per-resource traffic baseline and detects L7 DDoS within seconds. Low-suspicion requests are mitigated with a silent Challenge and high-suspicion requests with Block. It is a paid rule group.

AI traffic

AI bot and agent management

Bot Control classifies AI crawlers and agents and shows them in the AI activity dashboard. Bots verified with Web Bot Auth signatures are allowed by default, and on CloudFront you can also charge with HTTP 402 through AI traffic monetization.

Request handling

Label forwarding and normalization

Dynamic label interpolation inserts label namespaces, client IP, and JA3 · JA4 fingerprints into custom headers or response bodies with a single rule. Pre-parse text transformation normalizes query strings before parsing to prevent evasion.

Custom responses: specify a status code, headers, and body on a Block action to return a custom response, and with Allow or Count you can insert custom headers into requests forwarded to the origin.

Protected resources

Resources you can associate a web ACL with

One web ACL can be associated with multiple resources of the same scope, but each resource can have only one web ACL. Create web ACLs for CloudFront in the global scope, and all others in the same Region as the resource.

EdgeGlobal scope

Amazon CloudFront · AWS Amplify

Requests are inspected at edge locations, so attack traffic never reaches the origin. The CloudFront body inspection limit is 16 KB by default and can be raised to 64 KB.

CloudFront distributionAmplify appscope: CLOUDFRONT
LB · APIRegional

ALB · API Gateway · AppSync

Protects Regional entry points directly. The body inspection limit is fixed at 8 KB for ALB and AppSync; for API Gateway REST APIs it is 16 KB by default and can be increased.

Application Load BalancerAPI Gateway REST APIAppSync GraphQL API
AppRegional

Cognito · App Runner · Verified Access · AgentCore Gateway

Apply the same rules in front of user pool sign-in endpoints, containerized web services, zero trust application access, and agent tool gateways.

Cognito user poolApp Runner serviceVerified Access instanceBedrock AgentCore Gateway

You can't associate a web ACL directly with an NLB, an API Gateway HTTP API, or an EC2 Elastic IP. Protect such entry points by placing CloudFront in front, or with Shield Advanced and Network Firewall.

Where it fits

AWS WAF and neighboring security services

They work at different layers and inspect different things, so they complement rather than replace each other.

Comparison of AWS WAF, Shield, Network Firewall, and security groups
ServiceLayerInspectsWhere it attaches
AWS WAFL7 HTTP(S)Headers, URI, query, body, cookies, IP · country, request rate, bot signalsweb ACL associated with resources such as CloudFront, ALB, API Gateway
AWS ShieldL3 · L4 (+ L7 Advanced)Volumetric and state-exhaustion DDoS. Advanced mitigates L7 with the Anti-DDoS rule group included in the subscriptionStandard is automatic. Advanced on designated protected resources
Network FirewallL3 – L7 flows5-tuple, Suricata signatures, TLS SNI · domains, all protocolsFirewall endpoints in the VPC · TGW routing path
Security groups · NACLsL3 · L4IP, port, protocolENI · subnet

Reference architecture

Filter at the edge first, and apply one baseline across the organization

Web traffic is inspected first at CloudFront, which has a global web ACL associated. The Regional API Gateway gets a Regional web ACL. Firewall Manager enforces common rule groups across every account in the organization, and logs from each web ACL are collected in one place.

AWS WAF reference architecture Users, bots, and attack traffic arrive from the internet. Web traffic is inspected by Managed Rules, Bot Control, and a rate-based rule on a CloudFront distribution with a global-scope web ACL, and blocked requests receive a 403 at the edge. Allowed requests go to the Application Load Balancer and the application in the Region. API calls from the mobile app go to an API Gateway REST API with a Regional-scope web ACL. In the organization management area, the Firewall Manager administrator account uses policies to deploy the first and last rule groups of each account's web ACL; web ACL logs are collected in S3 through Amazon Data Firehose, and CloudWatch metrics are collected alongside. INTERNET AWS EDGE · GLOBAL WEB ACL REGION · WORKLOAD ACCOUNT Usersbrowser Bots · attacksscraper · SQLi · flood Mobile appWAF SDK token CloudFront + web ACL 0 FMS first rule groups 1 AWS Managed Rules 2 Bot Control · CAPTCHA 3 rate-based · label match default action: Allow Blocked →403 at edge ALBCloudFront origin ApplicationECS · EC2 API GatewayREST · regional web ACL LambdaAPI backend allowed API calls Firewall ManagerAWS WAF policy · org-wide Data Firehoseaws-waf-logs-* S3 · CloudWatchlogs · metrics deploy policy logs ORGANIZATION · SECURITY ACCOUNT
Client requests Bot · attack requests (blocked at the edge) Traffic that passed inspection Firewall Manager policy deployment In-Region requests · log delivery

On narrow screens, swipe the diagram sideways.

Getting started

Steps to deploy your first web ACL

  1. STEP 1

    Create a web ACL

    Choose the scope of the resources to protect (CloudFront or Regional) and set the default action. The new console shows it as a protection pack.

  2. STEP 2

    Add managed rules

    Add AWS Managed Rules such as Core rule set and IP reputation, and check WCU usage.

  3. STEP 3

    Observe with Count

    Keep rules in Count, enable logging and CloudWatch metrics, find false positives, and create exceptions.

  4. STEP 4

    Switch to Block

    Switch verified rules to Block first, then add rate-based rules and Bot Control.

  5. STEP 5

    Scale to the organization

    Use Firewall Manager policies to apply common rule groups automatically to all accounts and new resources.

Pricing

Cost components

You pay for what you use. The basics are monthly charges per web ACL and per rule, plus the number of requests processed; enabling intelligent threat mitigation features and extended options adds charges.

AWS WAF billing components
ComponentBilled byNotes
web ACLMonthly fee per web ACLProrated by the hours in use
RulesMonthly fee per rule · rule group in a web ACLEach managed rule group counts as one rule
RequestsPer 1 million requests processedApplies to every request the web ACL inspects
WCU · extended body inspectionWCUs above 1,500 · body inspection beyond 16 KBAdditional WCUs are priced in tiers. If you raise the body limit, extra charges apply only to requests larger than 16 KB
Bot Control · Fraud Control · DDoSMonthly subscription + requests · attemptsBot Control is priced per Common · Targeted level (with a free request tier), ATP by login attempts, and ACFP by account creation attempts. The Anti-DDoS rule group is also charged separately
CAPTCHA · ChallengeAttempts · responsesCharged for CAPTCHA puzzles presented and Challenge responses
Related chargesBilled by other servicesAWS Marketplace rule group subscriptions, Firewall Manager policies, log destinations (S3 · Firehose, and CloudWatch Logs beyond 500 MB per 1 million requests)

For resources protected by Shield Advanced, standard AWS WAF charges are included in the subscription (excluding Bot Control, Fraud Control, CAPTCHA, and similar). For CloudFront distributions you can also choose flat-rate pricing plans (launched November 2025) that include AWS WAF and DDoS protection in a monthly fee. Prices are subject to change; check the AWS WAF pricing page.

Next step

Design a web ACL that fits your service

Bring a summary of your internet-facing entry points, login and sign-up paths, share of bot traffic, and account structure, and we'll review the rule configuration and the Count → Block transition plan together.