AWS WAF
Cloud service · AWS · Updated

AWS WAF

In short

AWS WAF (Web Application Firewall) is a web application firewall service that helps protect web applications and APIs from common web exploits and bots that may affect availability, compromise security, or consume excessive resources.

Cloud Services Hub →

8 key features of AWS WAF

AWS WAF provides customizable web security rules, real-time visibility into web traffic, managed rules from AWS, protection against DDoS with rate-based rules, seamless integration with AWS services, bot management, and rule prioritization for comprehensive application protection.

01
Customizable Web Security Rules

AWS WAF allows users to create custom security rules tailored to their application's needs to block common attack patterns, such as SQL injection or cross-site scripting (XSS).

02
Real-Time Visibility

Provides real-time metrics and captures detailed logs of web traffic, enabling quick identification and response to threats.

03
Managed Rules

Offers pre-configured rule sets from AWS security experts and AWS Marketplace sellers to protect applications against common web exploits with minimal setup.

04
Rate-Based Rules

Enables automatic blocking of IP addresses that send requests at a rate above a given threshold, effectively mitigating DDoS attacks and brute force attempts.

05
Integration with AWS Services

Seamlessly integrates with Amazon CloudFront, Application Load Balancer (ALB), Amazon API Gateway, and AWS AppSync, allowing for protection in various layers of a cloud architecture.

06
Bot Control

AWS WAF includes a managed rule group that helps you control bot traffic to your application, distinguishing between benign and malicious bots.

07
Rule Prioritization

Offers the flexibility to prioritize the order in which rules are evaluated, ensuring more critical rules are applied first for efficient threat mitigation.

08
Custom Responses

Based on configured request conditions, protected resources can return a custom response instead of requested content or an HTTP 403 Forbidden response.

Where AWS WAF is used

AWS WAF is used for preventing SQL injection and XSS attacks, mitigating DDoS attacks, controlling bot traffic, and managing country-based access to web applications.

  1. 01
    Preventing SQL Injection Attacks

    AWS WAF allows users to create custom web security rules to block common web attack patterns, such as SQL injection, by inspecting elements like SQL tokens and statement structures within web requests. This can protect databases from unauthorized data exposure or corruption.

  2. 02
    Blocking Cross-Site Scripting (XSS) Attacks

    With AWS WAF, users can prevent XSS attacks where attackers inject malicious scripts into content viewed by other users. Rules can be configured to identify and block malicious scripts, safeguarding website integrity and user data privacy.

  3. 03
    Mitigating DDoS Attacks

    AWS WAF can be utilized in conjunction with AWS Shield for mitigating Distributed Denial of Service (DDoS) attacks. Users can create rules that help in filtering traffic patterns and volumes that are typically indicative of DDoS, thus preserving application availability and performance.

  4. 04
    Controlling Bot Traffic

    AWS WAF helps in distinguishing between legitimate and malicious bot traffic. Users can create rules to allow, block, or monitor web request patterns identified as automated bot interactions—protecting against scrapping, fraud, and abuse without impacting user experience.

  5. 05
    Country-based Access Control

    Businesses operating in multiple jurisdictions can use AWS WAF to implement geo-blocking or geo-allow policies. This enables restricting or allowing access to web applications based on the geographic location of the request, aiding in compliance with regional regulations.

How AWS WAF is priced

AWS WAF utilizes a request-based pricing model complemented by additional fees for optional managed rules, with costs accruing based on the volume of web requests and the use of managed rule groups.

Web ACL, Rule, and Request Pricing

AWS WAF charges for each web ACL created, each rule created per web ACL, and the number of web requests processed by the web ACL. Pricing may vary by AWS Region, and monthly fees are prorated hourly.

Managed Rules Pricing

In addition to request-based pricing, using AWS managed rules or third-party rules from the AWS Marketplace incurs additional costs. These are typically charged on a monthly basis per rule group that you add to your web ACL.

Additional Capacity and Body Inspection

AWS WAF charges an additional $0.20 per million requests for each 500 WCUs used beyond the default allocation of 1,500, and $0.30 per million requests for each additional 16 KB analyzed beyond the default body inspection limit.

CAPTCHA and Challenge Pricing

CAPTCHA attempts and Challenge responses incur separate charges; standard Allow, Block, and Count actions have no additional action charge.

Bot Control Pricing

Bot Control has subscription and request fees in addition to base AWS WAF charges. Common Bot Control includes the first 10 million requests per month for free, while Targeted Bot Control includes the first 1 million requests per month for free.

Fraud Control Pricing

Account Takeover Prevention and Account Creation Fraud Prevention charge request fees for analyzed requests and a $10 monthly subscription per web ACL for each managed rule group used.

DDoS Protection Pricing

AWS WAF Layer 7 DDoS Protection is billed per web ACL per month, prorated hourly, and per million requests.

CloudFront Flat-Rate Plans

AWS WAF is also included in CloudFront flat-rate website delivery and security plans for a monthly price with no overage charges.

Services AWS WAF works with

Amazon CloudFrontAmazon CloudFront

AWS WAF can be deployed with Amazon CloudFront to help protect edge locations and deliver secure content to viewers with low latency and high transfer speeds.

Amazon API GatewayAmazon API Gateway

AWS WAF associates a web ACL with an API Gateway REST API stage to inspect incoming requests. Rules can block malicious payloads, restrict source IP addresses, or rate-limit requests before they reach the API.

Amazon AthenaAmazon Athena

AWS WAF request logs stored in Amazon S3 can be queried with Athena using tables defined for the WAF log format. This lets you investigate blocked requests, identify frequently targeted paths, and evaluate rule matches with SQL.

Amazon Bedrock AgentCore

AWS WAF protects Bedrock AgentCore Gateway endpoints through an associated web ACL. Its rules inspect incoming requests and can block malicious traffic or limit excessive requests to the gateway.

Amazon CloudWatchAmazon CloudWatch

AWS WAF publishes traffic and rule metrics to CloudWatch and can deliver detailed request logs to CloudWatch Logs. You can create alarms for increases in blocked requests and use Logs Insights to investigate matching traffic.

Amazon CognitoAmazon Cognito

AWS WAF associates a web ACL with a Cognito user pool to inspect supported requests to its endpoints. This can restrict suspicious sign-up and sign-in traffic using IP restrictions, rate-based rules, and other request filters.

Amazon Data FirehoseAmazon Data Firehose

AWS WAF can send request logs to a Data Firehose delivery stream. Firehose buffers and delivers those records to a configured destination for storage or security analysis.

Amazon Elastic Container Service (Amazon ECS)Amazon Elastic Container Service (Amazon ECS)

AWS WAF protects HTTP and HTTPS traffic to ECS services through a WAF-enabled Application Load Balancer. The load balancer applies the associated web ACL before forwarding requests to the service's container tasks.

Amazon Elastic Kubernetes Service (Amazon EKS)Amazon Elastic Kubernetes Service (Amazon EKS)

AWS WAF can protect EKS applications exposed through an Application Load Balancer managed by the AWS Load Balancer Controller. An Ingress annotation specifies the WAF web ACL that the controller associates with the load balancer.

Amazon EventBridgeAmazon EventBridge

AWS WAF management API activity recorded by CloudTrail can match EventBridge rules. For example, a rule can route web ACL changes to a notification or automated review workflow.

AWS WAF exam questions

Real practice exam questions on AWS WAF, with the correct answer and its explanation. Answer them with every option in the exam simulator.

CLF-C02

A company hosts a public web application behind an Application Load Balancer. The security team has identified requests containing SQL injection attempts in URL query strings. The company needs to block these requests before they reach the application without changing the application code. Which solution best meets these requirements?

Show answerCORRECT ANSWER

Associate an AWS WAF web ACL with the Application Load Balancer and enable SQL injection protection rules with a block action.

AWS WAF can inspect web request components, including URL query strings, for SQL injection patterns. A web ACL associated with the Application Load Balancer can block matching requests before they reach the application.

SOA-C03

A company runs a public application behind an Application Load Balancer (ALB) in a single AWS account. The ALB is protected by AWS Shield Advanced and has an AWS WAF web ACL associated with it. Automatic application-layer DDoS mitigation is enabled in observation-only mode.

During an audit, a CloudOps engineer confirms that attack-specific rules were generated during a recent HTTP flood, but matching requests were counted rather than blocked. Company policy now requires these automatically generated mitigations to block matching requests during attacks. The company must retain its existing web ACL rules and avoid maintaining fixed request-rate thresholds.

Which change should the engineer make?

Show answerCORRECT ANSWER

Update the ALB's Shield Advanced automatic application-layer DDoS mitigation configuration to use the Block action instead of Count.

Shield Advanced automatic application-layer DDoS mitigation supports Count and Block actions. Changing its action to Block makes its automatically managed attack-specific rules enforce mitigation without requiring the company to maintain fixed rate thresholds or replace existing web ACL rules.

SAP-C03

A financial services company runs three independently managed web applications in one VPC. Each application has a dedicated internet-facing Application Load Balancer (ALB), EC2 application instances in private subnets, and an Amazon RDS database in isolated subnets. The application tiers share private subnets, and the databases share isolated subnets. No application requires connectivity to another application's resources.

Currently, all application instances and databases use a shared security group that allows all traffic from the VPC CIDR. An assessment finds that an attacker who exploits one application could connect directly to the other applications and databases. Moving resources to different subnets or VPCs is not permitted during the remediation window.

The company requires a design that blocks common malicious HTTP requests before they reach application instances, prevents a compromised instance from establishing connections to another application's instances or database, and records accepted and rejected network flows for investigation. Legitimate ALB-to-application and application-to-database connections must continue to work. The design must assume that some attacks can evade HTTP request filtering.

Which solution meets these requirements?

Show answerCORRECT ANSWER

Associate an AWS WAF web ACL with each ALB. Replace the shared security group with separate ALB, application, and database security groups for each application. Permit application ingress only from its ALB security group on required ports and database ingress only from its application security group on the database port. Remove other workload ingress permissions. Enable VPC Flow Logs for accepted and rejected traffic.

This combines application-layer filtering, independent workload-level segmentation, and network visibility. Dedicated security groups prevent a compromised instance from initiating connections to another application's instances or database, even if an exploit evades AWS WAF. Security group references preserve the required communication paths, and stateful filtering permits their return traffic. VPC Flow Logs provide connection metadata for investigation.

Practice AWS WAF in a full exam

Questions on AWS WAF in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is AWS WAF

3 min read

AWS WAF, or Amazon Web Services Web Application Firewall, plays a pivotal role in safeguarding web applications from a myriad of threats over the internet. It serves as a formidable barrier between your web application and common threats such as SQL injection, cross-site scripting (XSS), and other exploits that could compromise the security, availability, or resilience of your application. AWS WAF is deeply integrated into the Amazon ecosystem, providing a seamless and highly customizable defense mechanism for applications hosted on services like Amazon CloudFront, the Amazon API Gateway, and AWS AppSync. 

AWS WAF can also protect Amazon Cognito user pools, AWS App Runner services, Amazon Bedrock AgentCore Gateway, AWS Verified Access instances, and AWS Amplify.

One of the primary advantages of AWS WAF is its flexibility. Users can create custom security rules that precisely target and mitigate specific threats. This means that in addition to using predefined rules and rule groups that AWS provides and maintains, which cover common web vulnerabilities and attack patterns, users can tailor their security posture to meet the unique demands of their application. These custom rules can be based on a variety of conditions, including HTTP headers, IP addresses, HTTP bodies, or URI strings, enabling a granular approach to threat mitigation. AWS WAF operates at the application layer (Layer 7 in the OSI model), allowing it to inspect the content of HTTP/S traffic and make informed decisions on whether to allow, block, or count the traffic based on the conditions defined in the rules. This is instrumental in preventing the exploitation of vulnerabilities within the application or the underlying infrastructure. 

A web ACL also has a default action that allows or blocks requests that its rules have not already allowed or blocked.

AWS WAF Bot Control is a managed rule group for monitoring, blocking, or rate-limiting automated traffic such as scrapers, scanners, and crawlers while allowing common bots such as status monitors and search engines.

AWS WAF Fraud Control consists of Account Takeover Prevention and Account Creation Fraud Prevention, providing managed rules that protect login and sign-up pages against credential stuffing, credential cracking, and fake account creation attacks.

AWS WAF also supports CAPTCHA and silent challenge controls for requests matching your criteria to help reduce bot traffic.

Moreover, AWS WAF is capable of providing real-time visibility into the traffic, thereby enabling timely and informed reactions to emerging threats. This visibility is not just limited to threats but extends to monitoring legitimate access, helping in understanding traffic patterns and potentially uncovering insights that can be leveraged to optimize application performance and user experience. Moreover, AWS WAF can be configured to provide automated responses to certain types of threats, thus enhancing the ability to quickly mitigate potential attacks without the need for manual intervention. 

AWS WAF application layer (L7) DDoS protection is a managed rule group that establishes a normal traffic baseline and uses machine learning to detect anomalies and automatically apply mitigation rules. It protects applications on Amazon CloudFront, Application Load Balancer, and API Gateway.

The service integrates well with other AWS services such as Amazon CloudWatch for logging and monitoring and AWS Lambda for executing custom functions in response to certain triggers, offering a comprehensive security solution that is not only reactive but also proactive. 

Another noteworthy aspect of AWS WAF is its cost-effectiveness. Pricing is based on the number of web access control lists (web ACLs) created, the number of rules added per web ACL, and the number of web requests received. This pay-as-you-go model ensures that businesses of all sizes can access robust web application security without a significant upfront investment. 

Flat-rate pricing plans provide an alternative to pay-as-you-go, with plans selected according to the total number of requests and desired features.

In the landscape of cyber threats that evolves every day, AWS WAF stands out as a critical tool in the arsenal of web application protection. Its adaptability, integration capabilities, and cost-efficiency make it an attractive solution for businesses looking to protect their web applications from the ever-present and ever-evolving threats of the digital world.

Learn AWS WAF in lessons

19 short lessons on AWS WAF in 6 certification courses.

and 13 more lessons

Open the lessons

Concepts related to AWS WAF

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.