
AWS Web Application Firewall
AWS Web Application Firewall (AWS WAF) is a managed security service that helps protect web applications and APIs by inspecting HTTP and HTTPS requests and applying rules to allow, block, count, challenge, or otherwise control matching traffic. This article explains AWS WAF architecture, Web ACLs, rules, AWS Managed Rules, rate-based protection, bot control, logging, monitoring, request-inspection limits, cost considerations, and practical production best practices.
Series: Modern Technology (5 articles)
- …
- 4AWS Web Application Firewall This article
Why AWS WAF Matters
A network security control can decide whether traffic should be allowed to reach a service based on information such as IP addresses, ports, and protocols.
For example, a security group may allow:
Protocol: TCPPort: 443Source: InternetThat allows HTTPS connectivity.
But allowing HTTPS does not mean every HTTP request inside that connection is safe.
A legitimate application request might be:
GET /products?id=100while a malicious request could contain input designed to exploit an application vulnerability.
Both can arrive through TCP port 443.
This is where AWS WAF becomes useful.
AWS WAF monitors HTTP and HTTPS requests forwarded to supported AWS application resources and lets you control those requests according to conditions that you define.
In simple terms:
Normal User | v AWS WAF | Allow | vApplication
Suspicious Request | v AWS WAF | Block XApplicationAWS WAF complements network security controls by focusing on web-request characteristics rather than only network connectivity.
Where AWS WAF Fits in AWS Architecture
AWS WAF is not a virtual firewall appliance that you deploy inside a VPC subnet.
Instead, you create a Web Access Control List (Web ACL) and associate it with a supported AWS application resource.
A common architecture is:
Internet Users | v Amazon Route 53 | v Amazon CloudFront | AWS WAF | v Application Load Balancer | +--------+--------+ | | EC2 EC2 | | +--------+--------+ | v Amazon RDSAWS WAF evaluates requests before the protected resource processes them.
If AWS WAF blocks a request, that request does not continue to the protected application.
Which AWS Resources Can AWS WAF Protect?
AWS currently documents support for the following resource types:
- Amazon CloudFront distributions
- Amazon API Gateway REST APIs
- Application Load Balancers
- AWS AppSync GraphQL APIs
- Amazon Cognito user pools
- AWS App Runner services
- Amazon Bedrock AgentCore Gateway
- AWS Verified Access instances
- AWS Amplify
CloudFront is treated as a global resource, while the other supported integrations are Regional resources.
For workloads running on services such as Amazon ECS or Amazon EKS, AWS WAF is commonly associated with a supported entry point such as an Application Load Balancer or CloudFront distribution rather than individual containers.
CloudFront vs Regional WAF
One detail that is especially important when using Terraform, CloudFormation, AWS CLI, or CI/CD pipelines is AWS WAF scope.
For CloudFront:
Scope = CLOUDFRONTRegion = us-east-1AWS requires Web ACLs and related WAF resources used with CloudFront to be created through US East (N. Virginia), us-east-1. Some interfaces display this as:
Global (CloudFront)For Regional resources such as Application Load Balancers, the Web ACL is created in the applicable AWS Region.
Understanding the Web ACL
The core AWS WAF policy is the Web ACL.
A Web ACL contains rules that define how AWS WAF should inspect and handle incoming requests.
Example:
Production-WebACL
Priority 0Amazon IP Reputation
Priority 10Known Bad Inputs
Priority 20Core Rule Set
Priority 30Application Rules
Priority 40Rate-Based Protection
Priority 50Bot ControlThe Web ACL also has a default action.
A typical public website might use:
Default Action = ALLOWand explicitly block unwanted traffic.
A restricted application could instead use:
Default Action = BLOCKand allow only specifically approved requests.
AWS documents both allow-by-default and block-by-default approaches.
How AWS WAF Rules Work
A rule defines:
What should AWS WAF inspect?
+
What should happen when it matches?For example:
IF
Source IP belongs to Blocked-IP-Set
THEN
BLOCKA more application-specific rule might be:
IF
URI path starts with /admin
AND
Source IP is NOT in Trusted-Admin-IPs
THEN
BLOCKAWS WAF rules can inspect different portions and characteristics of a request, including URI paths, query strings, headers, cookies, body content, JSON bodies, source IP addresses, and other request attributes. Rules exist inside a Web ACL or rule group rather than as standalone AWS resources.
Rule Priority Is Critical
AWS WAF evaluates Web ACL rules according to their assigned priority.
Lower numerical priorities are evaluated before higher ones.
For example:
Priority 0IP Reputation
Priority 10Known Bad Inputs
Priority 20Core Rule Set
Priority 30Rate Limit
Priority 40Custom RulesThis becomes important because some rule actions are terminating.
Suppose you configure:
Priority 0ALLOW Trusted-IP
Priority 10BLOCK /adminIf a request matches the first terminating Allow rule, AWS WAF stops evaluating subsequent Web ACL rules for that request.
Therefore, having the correct rules is not enough.
The order in which those rules are evaluated is part of the security design.
AWS WAF Rule Actions
AWS WAF provides several actions for handling matching requests.
Allow
Allow forwards the request to the protected resource.
It is a terminating action.
Request | vAWS WAF | ALLOW | vApplicationBlock
Block prevents the protected resource from receiving the request.
Block is also terminating.
The normal WAF block response is HTTP
403 Forbidden , although custom responses can be configured.Count
Count records the matching request but does not terminate Web ACL processing.
This is extremely useful for testing a new protection before enforcing it.
New Rule | v COUNT | vMonitor | vTune | v BLOCKAWS specifically documents Count as useful for monitoring and testing new request-handling rules.
CAPTCHA
CAPTCHA can require a client to complete an interactive verification before continuing.
Challenge
Challenge performs client verification without necessarily requiring an interactive CAPTCHA from the user.
CAPTCHA and Challenge are useful particularly when mitigating automated traffic.
AWS WAF now also contains specialized actions for certain newer use cases, but Allow, Block, Count, CAPTCHA, and Challenge remain the actions most administrators will encounter in normal WAF deployments.
Why Count Mode Should Be Used Before Blocking
One of the easiest ways to cause a WAF-related production incident is to introduce an aggressive rule directly in Block mode.
Consider a legitimate application request that happens to resemble an attack pattern.
If the rule immediately blocks it:
Legitimate User | vNew WAF Rule | BLOCK XApplicationyour security control has become an availability problem.
A safer deployment pattern is:
Create Rule | vCOUNT | vEnable Logging | vObserve Production Traffic | vIdentify False Positives | vTune Rule | vEnable BLOCKThis is particularly important when deploying managed rule groups against an existing production application.
AWS Managed Rules
AWS Managed Rules are predefined rule groups maintained by AWS.
They reduce the need to build every threat-detection rule manually.
Common AWS-managed protection categories include:
- Core Rule Set
- Known Bad Inputs
- SQL database protection
- Linux protection
- POSIX protection
- Windows protection
- PHP protection
- WordPress protection
- Amazon IP Reputation List
- Anonymous IP List
- Bot Control
- Account Takeover Prevention
- Account Creation Fraud Prevention
Managed rule groups are collections of ready-to-use rules maintained by AWS or AWS Marketplace sellers. Most standard AWS Managed Rules groups do not have an additional managed-rule subscription fee beyond normal AWS WAF charges, while Bot Control and Fraud Control protections have additional fees.
Core Rule Set
The AWS Managed Rules Core Rule Set provides general protection against a range of common web-application attack patterns.
It is frequently suitable as part of a baseline WAF policy.
However:
AWS Managed ≠Safe to block every application immediatelyManaged rules still need to be evaluated against real application traffic.
Applications have different request formats, APIs, URLs, payloads, authentication flows, and integrations.
SQL Injection Protection
SQL injection attempts try to manipulate application input in a way that affects database queries.
For example:
Normal request:
/products?id=100A malicious request may attempt to insert SQL-like syntax into the parameter.
With WAF protection:
Request | vAWS WAF |SQL Injection Inspection |+--+----------------+| |Normal Suspicious| |Allow BlockAWS provides SQL-injection inspection capabilities and managed rules designed for SQL database exploitation patterns.
But this point is important:
AWS WAF does not replace secure database programming.
Applications should still use controls such as:
- Parameterized queries
- Input validation
- Appropriate authorization
- Least-privilege database credentials
- Secure dependency management
A WAF is another defense layer, not permission to deploy insecure application code.
Cross-Site Scripting Protection
Cross-site scripting, or XSS, attempts to cause malicious browser-side content to be processed through vulnerable application behavior.
AWS WAF includes XSS inspection capabilities.
Conceptually:
HTTP Request | v AWS WAF |XSS Inspection | +---+---+ | |Clean Suspicious | |Allow BlockThe application should still implement proper encoding, validation, browser-security controls, and secure development practices.
IP Reputation Protection
AWS provides managed IP-reputation capabilities that use AWS threat intelligence to identify sources associated with malicious activity.
This can add an early filtering layer to a Web ACL.
For example:
Incoming Request | vIP Reputation | vKnown Bad Inputs | vCore Rule Set | vApplication RulesOne important operational principle is to understand the rules inside a managed rule group instead of treating the whole group as an unexplained security checkbox.
IP Sets
AWS WAF allows administrators to create reusable sets of IPv4 or IPv6 CIDR ranges.
For example:
Trusted-Admin-IPs
203.0.113.0/24198.51.100.25/32A custom rule could then enforce:
IF
URI starts with /admin
AND
Source IP is NOT in Trusted-Admin-IPs
THEN
BLOCKThis can reduce exposure of sensitive application paths.
However, IP filtering should complement rather than replace strong authentication and authorization.
Geographic Matching
AWS WAF can make decisions based on the geographic location associated with a request's source IP.
For example:
Request | vGeo Match |+--+----------------+| |Approved OtherCountry Country| |Allow BlockA more focused policy could be:
IF
URI = /admin
AND
Country is outside approved locations
THEN
BLOCKGeographic information should be treated as a security signal rather than user identity.
A determined attacker can use proxies, VPNs, cloud infrastructure, or compromised hosts in other locations.
Rate-Based Rules
Rate-based rules are one of the most useful WAF protections for endpoints that are frequently abused.
Consider:
POST /loginA normal user might make several requests.
An automated attacker could make thousands.
AWS WAF rate-based rules count request aggregates and apply rate limiting when the estimated rate becomes too high.
Supported evaluation windows are:
60 seconds120 seconds300 seconds600 secondsor:
1 minute2 minutes5 minutes10 minutesThe default is five minutes.
A practical rule might be:
IF
URI path = /login
AND
Request rate exceeds threshold
THEN
CHALLENGEor:
BLOCK
Rate-Based Rules Are Not Exact API Quotas
AWS explicitly notes that WAF rate limiting is designed to control high request rates, not to provide mathematically precise request quotas.
AWS estimates the request rate, and enforcement occurs near the configured threshold rather than guaranteeing an exact request count.
Therefore, a requirement such as:
Exactly 100 API calls per customer every 5 minutesshould not rely solely on AWS WAF.
Application- or API-specific quota mechanisms may be more appropriate for that requirement.
Scope Rate Protection to Sensitive Paths
Applying one aggressive rate limit across an entire application can cause unnecessary problems.
Consider:
//images/products/search/login/checkoutThe legitimate request pattern for
/images could be completely different from /login .A better policy could be:
/login | +--> Strict rate protection
/checkout | +--> Bot / fraud controls
/static | +--> Different protection profileApplication-aware controls are normally more effective than blindly applying identical thresholds everywhere.
AWS WAF Bot Control
Automated traffic is not automatically malicious.
Useful bots can include:
- Search engines
- Monitoring systems
- Authorized crawlers
- Approved automation
Unwanted bots can include:
- Credential-stuffing tools
- Scrapers
- Vulnerability scanners
- Automated browsers
- Fraud automation
AWS WAF Bot Control can monitor, label, block, challenge, or rate-limit bot traffic. AWS provides Common and Targeted protection levels. Targeted protection adds techniques for detecting more sophisticated automated traffic.
Bot Control also generates labels that can be used by subsequent custom WAF rules.
This makes policies more flexible than simply:
Bot = BlockFor example, an organization may choose to allow a verified search crawler while challenging suspicious automated clients.
AWS has also continued expanding Bot Control, including capabilities for identifying authenticated bots and AI agents in newer Bot Control versions.
Bot Control has additional pricing, so it should be deployed where the additional protection is justified.
Fraud Control
AWS WAF also provides specialized intelligent threat-mitigation capabilities.
These include:
Account Takeover Prevention (ATP) for protecting login workflows against account takeover activity.
Account Creation Fraud Prevention (ACFP) for protecting account-registration workflows from malicious or fraudulent account creation.
These protections sit beyond basic WAF filtering and have additional charges.
They can be particularly relevant to:
- E-commerce platforms
- SaaS applications
- Subscription platforms
- Customer portals
- Financial applications
- Promotional or loyalty systems
Request Body Inspection Limits
A technically accurate AWS WAF architecture must acknowledge request-inspection limits.
AWS WAF does not necessarily inspect an unlimited request body.
For Application Load Balancer and AWS AppSync:
Maximum request-body inspection:8 KBFor CloudFront, API Gateway, Amazon Cognito, App Runner, Verified Access, and Amazon Bedrock AgentCore Gateway:
Default:16 KBThe inspection setting for these resource types can be increased in 16-KB increments to:
32 KB48 KB64 KBAWS also states that WAF request-body inspection rules do not support gRPC request bodies.
This matters because claiming:
"AWS WAF scans the complete request body"
would be incorrect.
Oversized Requests
When inspected content exceeds the amount AWS WAF can examine, rules need appropriate oversize handling.
This becomes particularly important for applications handling large uploads, large API payloads, or unusual request formats.
Security teams should understand:
What portion of the request is inspected?
What happens when the request exceeds that limit?
Could malicious content exist beyond the inspected portion?AWS WAF provides configurable oversize-handling behavior for applicable request components.
AWS WAF Logging
A WAF that blocks requests without giving engineers enough visibility into why they were blocked is difficult to operate safely.
AWS WAF can send Web ACL traffic logs to:
- Amazon CloudWatch Logs
- Amazon S3
- Amazon Data Firehose
WAF logs can contain information about when the request was received, request details, and which rules matched the request.
A typical security workflow is:
Web Request | v AWS WAF | v WAF Logs | +---+---------------+ | |CloudWatch S3 | | +---------+---------+ | v Security AnalysisLogs are especially useful for identifying:
- False positives
- Attacking source addresses
- Targeted URLs
- Rule matches
- Changes in attack traffic
- Unusual bot behavior
- Repeated authentication attacks
Logging should still be designed carefully because HTTP requests can contain sensitive information.
Monitoring with Amazon CloudWatch
Logging explains individual requests.
Metrics explain broader behavior.
AWS WAF integrates with Amazon CloudWatch so engineers can monitor traffic and rule activity.
A useful WAF dashboard should help answer questions such as:
Has blocked traffic increased?
Which rule is matching most frequently?
Are legitimate requests being counted?
Is /login receiving abnormal traffic?
Has automated traffic increased?
Did a new WAF deployment change application behavior?Monitoring should therefore be considered part of the WAF implementation rather than an optional activity after deployment.
Web ACL Capacity Units
AWS WAF uses Web ACL Capacity Units (WCUs) to represent the processing requirements of rules and rule groups.
Simple rule types generally require fewer WCUs than more complex inspections.
For example, regex processing can require more capacity than a simple size-based statement.
AWS currently documents:
Maximum Web ACL capacity:5,000 WCUand:
Basic Web ACL price includes:Up to 1,500 WCUUsing more than 1,500 WCUs results in additional pricing.
This creates an important architectural principle:
More WAF rules ≠Automatically better securityRules should exist because they address a meaningful risk.
AWS WAF Pricing
AWS WAF uses a usage-based pricing model.
Current pricing considers elements including:
- Web ACLs
- Rules
- Requests processed
- Managed rule groups where applicable
- WCU usage above the included capacity
- Bot Control
- Fraud Control
- Logging and related services
AWS currently states that an additional request charge applies for every 500 WCUs used beyond the standard 1,500-WCU allocation. Pricing varies depending on the feature and Region, so production estimates should always use the current AWS pricing page rather than figures copied from an old tutorial.
AWS WAF vs Security Groups
AWS WAF and security groups address different layers of security.
AWS WAF | Security Group |
|---|---|
Web application protection | Network access control |
Understands HTTP(S) request characteristics | Controls IPs, ports and protocols |
Can inspect URI paths | Does not understand application URLs |
SQLi/XSS inspection | No equivalent application inspection |
Bot controls | No bot-classification capability |
Rate-based web controls | No equivalent HTTP request-rate analysis |
A production architecture frequently uses both:
Internet | vAWS WAF | vALB | vSecurity Group | vApplication
AWS WAF vs AWS Shield
AWS WAF and AWS Shield should also not be treated as interchangeable.
AWS WAF focuses on application-layer request inspection and filtering.
AWS Shield provides DDoS protection capabilities.
A defense-in-depth architecture can use them together rather than selecting one as a replacement for the other.
AWS Firewall Manager
Large organizations may operate many AWS accounts and applications.
Without centralized governance, this can result in:
Account A → Different WAF policy
Account B → Different WAF policy
Account C → No WAF
Account D → Outdated configurationAWS Firewall Manager can centrally manage protections such as AWS WAF across accounts and resources in an AWS organization.
This is especially valuable in multi-account enterprise environments.
A Practical Production Deployment Strategy
A strong WAF implementation should follow a controlled lifecycle.
Understand the application | vIdentify exposed endpoints | vUnderstand normal traffic | vCreate Web ACL | vAdd relevant protections | vStart new rules in COUNTwhen appropriate | vEnable logging | vObserve production traffic | vIdentify false positives | vTune rules and scope | vEnable BLOCK | vAdd endpoint-specificrate / bot controls | vMonitor continuouslyThis process is more important than the number of rules in the Web ACL.
Example Production Web ACL
A conceptual Web ACL might look like:
Production-WebACL
Priority 0Business-specific exceptions
Priority 10IP Reputation Protection
Priority 20Known Bad Inputs
Priority 30Core Rule Set
Priority 40Application-specific protections
Priority 50/login Rate Protection
Priority 60Bot Controls
Default ActionALLOWThis is an example architecture, not a universal AWS-recommended rule order.
The correct policy depends on:
- Application architecture
- Normal traffic
- APIs
- User geography
- Authentication behavior
- Third-party integrations
- Business requirements
- Threat model
Copying another organization's WAF configuration without understanding those differences can create both security gaps and application outages.
Common AWS WAF Mistakes
Enabling every available managed rule can create unnecessary capacity use, false positives, and operational complexity.
Blocking immediately makes a new rule capable of causing an outage before engineers understand its impact.
Ignoring rule priority can cause an early terminating rule to prevent later protections from being evaluated.
Using the same rate limit everywhere ignores the fact that
/login , /api , /images , and /checkout have very different legitimate traffic patterns.Ignoring request inspection limits can lead security teams to assume WAF inspected content that was never actually available to the service.
Ignoring logs and metrics makes it much harder to investigate attacks or false positives.
Treating geography as identity ignores the reality that attackers can use proxies and distributed infrastructure.
Treating WAF as a replacement for secure development leaves vulnerabilities that a web application firewall cannot solve.
Recommended Defense-in-Depth Architecture
A mature AWS architecture may resemble:
Internet | v Amazon CloudFront | AWS WAF | +-------------------+-------------------+ | | | Managed Rules Rate Protection Bot Control | | | +-------------------+-------------------+ | v Application Load Balancer | Security Groups | +----------+----------+ | | Application Application Server Server | | +----------+----------+ | v Database LayerAlongside:
IAMEncryptionSecrets managementSecure codingPatch managementCloudWatchWAF loggingDDoS protectionInfrastructure as CodeContinuous monitoringEach control addresses a different part of the security problem.
That is the principle of defense in depth.
Final Thoughts
AWS WAF is much more than an IP-blocking service.
It provides a programmable application-security layer that can inspect HTTP and HTTPS requests, apply managed and custom rules, control excessive request rates, manage automated traffic, support specialized fraud protections, and provide detailed security visibility.
However, simply enabling AWS WAF does not automatically make an application secure.
The strongest WAF implementation follows a simple principle:
Understand | vObserve | vProtect | vMeasure | vTune | vImproveA good Web ACL is therefore not necessarily the one with the largest number of rules.
It is the one that accurately identifies unwanted traffic while allowing legitimate users to use the application normally.
When AWS WAF is combined with secure application development, appropriate network controls, IAM, logging, monitoring, encryption, DDoS protection, and continuous policy review, it becomes an important part of a resilient AWS security architecture.
For cloud and DevSecOps engineers, that is where AWS WAF provides its greatest value: a measurable, automatable, and continuously tunable security layer in front of modern web applications and APIs.
Series: Modern Technology (5 articles)
- …
- 4AWS Web Application Firewall This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article