WAF basics
AWS WAF filters web requests before they reach an application.
How it works
- Attach a web ACLA web ACL groups request inspection rules associated with protected application resources. to a protected resource such as CloudFront or API Gateway.
- Rules inspect each HTTP(S) request.
- Matching requests are allowed, blocked or counted.
Exam cues
- If the question says block SQL injectionSQL injection attempts to add unauthorized database queries through application requests., cross-site scriptingCross-site scripting uses malicious script content in a web application attack. or IP addresses at the web layer, think AWS WAF.
Remember
- Works on HTTP(S) requests.
Trap: WAF filters web requests; security groups filter network traffic to instances.
Da documentação da AWS (3)
- AWS WAF is a web application firewall that watches HTTP(S) requests to resources such as CloudFront distributions and API Gateway APIs and allows or blocks them by rules.
- An AWS WAF geo match rule statement allows or blocks web requests by their country or region of origin.
- An AWS WAF SQL injection rule statement inspects web requests for malicious SQL code.
Web ACL scope and rule actions
AWS WAF filters web requests using a web access control listA web ACL groups request inspection rules associated with protected application resources. (web ACL), also called a protection pack. A web ACL contains rules associated with a supported application endpoint. It lets you choose which matching requests to allow, block, count or challenge.
How it works
- Associate the web ACL with a supported resource. Each resource can have one web ACL; one ACL can protect multiple compatible resources.
- Match the scope: create CloudFront WAF resources in
us-east-1, shown as Global (CloudFront). Regional resources need WAF resources in their own Region. Amplify also requires the Global CloudFront Region. - WAF evaluates rules in ascending numeric priority. A terminating actionA terminating action ends web ACL evaluation and determines the request outcome. ends evaluation immediately.
- If no rule terminates evaluation, WAF applies the configured default action.
- Test in staging and use Count with production traffic before enforcement. Enable logs in CloudWatch Logs, S3 or Data Firehose to inspect requests and rule matches.
| Action | Effect on evaluation |
|---|---|
| Allow | Accept and stop |
| Block | Reject and stop before the protected resource receives the request |
| Count | Record the match and continue |
| CAPTCHA or Challenge | Continue with a valid verification tokenA verification token lets WAF determine whether a client has passed a CAPTCHA or background challenge.; otherwise stop and ask the client to solve a puzzle or background challenge |
A token records client verification. A Regional ACL can protect an ALB, API Gateway REST API, AppSync GraphQL API, Cognito user pool, App Runner service, Bedrock AgentCore Gateway or Verified Access instance. CloudFront uses a global ACL. NLBs and EC2 instances are not direct WAF attachment targets.
For an ALB originAn origin is the backend from which CloudFront retrieves content. behind CloudFront, an origin is the backend serving CloudFront’s requests. CloudFront can add a secret header that the ALB’s WAF rule requires. Rotate the CloudFront header and the ALB rule together so direct requests without the secret remain blocked.
Exam cues
- If the question says Count metrics miss requests accepted by an earlier Allow rule, think priority order, because Allow ends evaluation before Count can run.
- If the question says protect CloudFront with a Regional ACL, think a global ACL created in
us-east-1, because a Regional ACL has the wrong scope. - If the question says audit matching web requests centrally, think WAF logging, because logs can go to CloudWatch Logs, S3 or Firehose.
- If the question says rotate an origin validation secret, think both CloudFront and the ALB WAF rule, because the sent and accepted values must stay aligned.
- If the question says block countries or SQL injectionSQL injection attempts to add unauthorized database queries through application requests., think AWS WAF, because it has geo match and SQL injection rule statements.
Remember
- Lowest numeric priority runs first.
- Each resource has at most one web ACL.
- Allow and Block stop evaluation. Count continues.
- CAPTCHA and Challenge depend on token validity.
- WAF logs can go to CloudWatch Logs, S3 or Data Firehose.
- Inspectable parts: method, headers, cookies, URI path, query string, body. AND, OR and NOT combine statements.
Trap: Count does not guarantee that a request reaches the application. A later rule or the default action can still block it.
Continue evaluation
No terminating match
Da documentação da AWS (21)
- A WAF web access control list (web ACL), also called a protection pack, associates request inspection rules with protected resources.
- CloudFront web ACLs and their WAF resources are created in us-east-1; a CloudFront-associated ACL cannot protect another resource type.
- Regional WAF resources include ALB, API Gateway REST API, AppSync GraphQL API, Cognito user pool, App Runner service, Bedrock AgentCore Gateway and Verified Access instance.
- Amplify apps require a web ACL in the Global CloudFront Region rather than an existing Regional ACL.
- A Regional web ACL and its WAF resources must be in the same Region as the protected regional resource.
- WAF does not list Network Load Balancers or EC2 instances as directly supported protected resource types.
- Each protected resource can have only one web ACL; a web ACL can protect multiple compatible resources.
- WAF evaluates rules from lowest to highest numeric priority, stopping at a terminating action or the end of the rules.
- Allow and Block terminate web ACL evaluation; Block prevents the protected resource from receiving the request.
- Count records a matching request and continues evaluating later rules.
- CAPTCHA and Challenge continue evaluation when a valid token is present; otherwise they terminate evaluation and request a puzzle or background challenge.
- If no rule produces a terminating action, WAF applies the web ACL default action.
- AWS recommends testing and tuning WAF in staging, then using Count on production traffic before enabling enforcement.
- WAF request logs can be sent to CloudWatch Logs, an S3 bucket or a Data Firehose delivery stream.
- CloudFront can add a secret origin header that an ALB WAF rule checks to block requests bypassing CloudFront.
- A Secrets Manager rotation workflow can update both the CloudFront custom origin header and the ALB WAF rule configuration.
- An IP set match statement checks the request IP against a list of CIDR ranges; an Allow rule on it with a Block default action restricts access to those ranges.
- An AWS WAF size constraint statement compares the byte size of a request component, such as the query string or body, with a number you set, without inspecting its contents.
- A web ACL can use up to 5,000 WAF capacity units (WCUs); its base price includes 1,500 WCUs and higher usage costs extra. A rule group can have at most 5,000 WCUs.
- AWS WAF rule statements can inspect request components such as the HTTP method, a single header or all headers, cookies, the URI path, the query string and the body.
- Logical rule statements combine or negate nested statements with AND, OR and NOT.
Managed and rate-based rules
AWS WAF managed rule groups provide maintained sets of request checks. Rate-based rules control high request volumes. Use both when an application faces exploit attempts as well as floods.
How it works
- Choose managed rule groups for the application. SQL injectionSQL injection attempts to add unauthorized database queries through application requests. means adding unauthorized database query instructions to a request. Cross-site scriptingCross-site scripting uses malicious script content in a web application attack. means sending script content intended to run in a user’s browser.
- For volume control, choose an aggregation keyAn aggregation key is a request value used to group requests into separate rate counters., the request value used to group requests into counters. The default is source IP. Custom keys can use headers, cookies, HTTP methods or paths.
- Add a scope-down statementA scope-down statement filters which requests a rate-based rule counts and limits., a filter that limits which requests are counted. For a combined limit on a login path, use Count all aggregation with a scope-down statement matching that path.
- WAF looks back over the evaluation window and applies the rate action when a grouping exceeds the limit.
- Test and tune in staging and Count mode before enforcing. Treat the rate limit as approximate availability protection, since detection can lag traffic changes.
A scope-down statement can also restrict a managed rule group to matching requests.
| Threat | Managed rule group |
|---|---|
| Common vulnerabilities, including cross-site scripting | Core rule set, AWSManagedRulesCommonRuleSet |
| Unauthorized SQL query patterns | SQL database group, AWSManagedRulesSQLiRuleSet |
| Known threatening or identity-obscuring IP sources | IP reputation groups |
| Automated botA bot is automated software that sends requests to a web application. requests | Bot Control, Common or Targeted protection |
Exam cues
- If the question says SQL injection and request floods, think managed exploit rules plus a rate-based rule, because matching malicious content and counting request volume solve different problems.
- If the question says many IPs flood one login path below each IP’s limit, think Count all with a path scope-down statement, because all matching login traffic shares the counter.
- If the question says a managed rule group should inspect only one path, think a scope-down statement, because the group evaluates only matching requests.
- If the question says bots hide their identity, think Bot Control Targeted protection, because it adds detection for bots that do not identify themselves.
Remember
- Count all requires a scope-down statement. It is an aggregation choice, separate from the Count rule action.
- Rate limiting is approximate and can react after a delay.
- Rule group owners: you, AWS Managed Rules, AWS Marketplace sellers, Firewall Manager or Shield Advanced.
Trap: A per-IP counter does not impose one shared limit on requests from all IPs. Choose aggregation to match the traffic grouping the question requires.
Da documentação da AWS (11)
- The WAF core rule set AWSManagedRulesCommonRuleSet includes protections against common web vulnerabilities, including cross-site scripting request patterns.
- AWSManagedRulesSQLiRuleSet detects patterns associated with SQL injection, where requests attempt to inject unauthorized database queries.
- WAF IP reputation rule groups inspect source IP addresses using threat intelligence or lists of identity-obscuring sources.
- Bot Control manages bot requests with Common protection for self-identifying bots and Targeted protection for more sophisticated bots.
- A rate-based rule counts request groupings over an evaluation window and applies its action to requests above the configured limit.
- Rate-based rules group by source IP by default, or can use forwarded IPs and custom keys such as headers, cookies, HTTP methods or paths.
- A scope-down statement narrows the requests counted and rate limited; Count all aggregates all matches together and requires a scope-down statement.
- A scope-down statement in a managed rule group limits evaluation to requests matching the statement.
- WAF rate limiting is approximate and can react after a delay; it does not guarantee an exact request quota.
- Test and tune WAF protections in staging, then Count mode on production traffic before enforcement.
- AWS WAF rule groups can be your own, managed by AWS Managed Rules, managed by AWS Marketplace sellers, or owned by services such as Firewall Manager and Shield Advanced.
Rate rules and logging operations
AWS WAF rate-based rules and logging have settings that affect how requests are evaluated and what data is recorded. Plan these settings alongside custom Block responses when operating a web ACLA web ACL groups request inspection rules associated with protected application resources..
How it works
- Choose a rate evaluation window and limit. A rate-based rule can use any rule action except Allow. See rate-based rule settings.
- Check the custom aggregation keyAn aggregation key is a request value used to group requests into separate rate counters., the request components used to group requests. A request missing any required component is omitted from that rule’s evaluation. See aggregation options.
- Plan changes to a live rule: changing rate settings resets its counts and can pause rate limiting for up to one minute. See rate-based rule caveats.
- Name a logging destination with the required prefix. Logging redaction does not affect request samplingRequest sampling collects a subset of evaluated web requests for inspection.; web ACL data protection can exclude fields from sampling. See S3 logging and WAF logging.
- For a tailored Block response, configure its response code, headers and body in place of the default 403 Forbidden. See custom responses.
Exam cues
- If the question says a session cookie is missing from a request, think omission from the rate rule, because every custom aggregation key component is required.
- If the question says a live rate rule’s window changed, think reset counts and a possible pause, because changing rate settings resets rate limiting counts.
- If the question says a blocked request needs a branded page, think a custom Block response, because it can set the status code, headers and body.
Remember
- Evaluation windows: 60, 120, 300 or 600 seconds; default: 300 seconds. Minimum limit: 10 requests per window.
- Rate-based rules cannot use Allow as their action.
- S3 buckets, CloudWatch Logs groups and Firehose streams used for WAF logging need names starting with
aws-waf-logs-.
Trap: Redacting a field in WAF logs does not remove it from sampled requests. Use web ACL data protection to exclude fields from sampling.
Da documentação da AWS (8)
- WAF rate evaluation windows are 60, 120, 300 or 600 seconds, with 300 seconds as the default.
- The minimum rate-based rule limit is 10 requests per evaluation window.
- A request missing a component required by a custom aggregation key is omitted from that rate-based rule evaluation.
- Changing rate-based rule rate settings resets its counts and can pause rate limiting for up to one minute.
- A WAF rate-based rule can use any rule action except Allow.
- WAF logging redaction does not affect request sampling; web ACL data protection can exclude fields from sampling.
- AWS WAF logging destinations (S3 bucket, CloudWatch Logs group or Firehose stream) must have names starting with aws-waf-logs-.
- A WAF Block action can return a custom response code, headers and body in place of the default 403 Forbidden response.
Flashcards
Nada para revisar aqui agora. Escolha outros tópicos ou outro filtro.
·
Todos os 28 flashcards em lista
A web application behind CloudFront must block SQL injection attempts and requests from certain IP addresses. Which service fits?
AWS WAF.
A company must block web requests to its application from specific countries. Which AWS service and rule type fit?
AWS WAF with a geo match rule statement.
Which AWS service can block SQL injection attempts in web requests?
AWS WAF, with an SQL injection rule statement.
Which resource types can AWS WAF protect with a web ACL?
CloudFront, ALB, API Gateway REST API, AppSync GraphQL API, Cognito user pool, App Runner, Bedrock AgentCore Gateway, Verified Access and Amplify. Amplify requires the Global CloudFront Region.
Can AWS WAF attach directly to an EC2 instance or Network Load Balancer?
No. Put HTTP request inspection on a supported resource, such as an Application Load Balancer or CloudFront distribution.
How does AWS WAF evaluate web ACL rules and choose the final action?
Lowest numeric priority first. Allow and Block terminate; Count continues. CAPTCHA and Challenge continue with a valid token and terminate otherwise. If nothing terminates, the default action applies.
How should a team test a new AWS WAF rule before blocking production requests?
Test and tune in staging, then use Count with production traffic before enforcing. Count allows evaluation to continue to later rules.
A service needs AWS WAF HTTP filtering in front of an NLB. Can WAF attach directly to the NLB?
No. WAF needs a supported resource, such as an ALB or CloudFront distribution.
A WAF Allow rule runs before a Count rule and both would match the request. Does the Count rule record it?
No. Allow terminates evaluation. Put Count first if it must observe requests that the Allow rule accepts.
A team needs an AWS WAF web ACL for a CloudFront distribution. Which Region must it use?
us-east-1, also shown as Global (CloudFront). Regional application resources normally need a web ACL in their own Region.
Where can a team send AWS WAF web request logs?
CloudWatch Logs, an S3 bucket or a Data Firehose delivery stream.
A CloudFront distribution sends a secret origin header checked by an ALB WAF rule. What must secret rotation update?
Both the CloudFront custom origin header and the ALB WAF rule configuration, so the value CloudFront sends is accepted at the origin.
A CloudFront distribution must accept requests only from the company's office IP ranges. How with AWS WAF?
An IP set of the CIDR ranges, an Allow rule on that IP set, and Block as the web ACL default action.
A web app must reject requests whose query string is longer than 100 bytes. Which AWS WAF rule statement fits?
A size constraint statement on the query string with a greater-than comparison.
An AWS WAF rule must block requests that have a particular header value AND come from outside one country. How is that built?
Nest a header match statement and a negated geo match statement under a logical AND statement.
A public ALB application faces SQL injection, cross-site scripting and request floods. Which AWS WAF protections should a team combine?
Use the SQL database managed rule group, the core rule set and a rate-based rule. Test and tune in staging and Count mode before enforcing.
A login endpoint receives a distributed flood with each IP below a per-IP limit. How can AWS WAF rate limit the combined login traffic?
Use a rate-based rule with Count all aggregation and a scope-down statement matching the login path. Its rate action applies to the combined matching request group.
Which AWS WAF managed protections fit known malicious IPs and automated bot requests?
IP reputation rule groups for source IP intelligence, and Bot Control for bot requests. Bot Control Common handles self-identifying bots; Targeted adds sophisticated bot detection.
An API must accept exactly a fixed request quota with no delay. Does an AWS WAF rate-based rule guarantee that quota?
No. WAF rate limiting is approximate and can take time to react to traffic changes.
An AWS WAF managed rule group should inspect only requests to a login path. What should the team add?
Add a scope-down statement matching the login path. Only matching requests are evaluated by the group.
A team wants vendor-maintained AWS WAF protection for a specific application type instead of writing rules. What can it add?
A managed rule group, from AWS Managed Rules or an AWS Marketplace seller.
What evaluation windows and minimum limit can an AWS WAF rate-based rule use?
60, 120, 300 or 600 seconds; 300 seconds is the default. The lowest limit is 10 requests per evaluation window.
An AWS WAF rate-based rule groups by a custom session cookie. What happens to a request without that cookie?
The rule omits it from evaluation because the required aggregation component is missing.
A team edits the evaluation window of a live AWS WAF rate-based rule. What happens to its request counts?
The counts reset, and rate limiting can pause for up to one minute.
Can an AWS WAF rate-based rule use Allow as its rate action?
No. Its rate action can use the other rule actions, but not Allow.
A team redacts a request header in AWS WAF logs. Is that header automatically excluded from sampled requests?
No. Logging redaction does not affect sampling. Use web ACL data protection to exclude fields from sampling.
AWS WAF refuses an S3 bucket as its log destination. What naming rule applies?
The destination name must start with aws-waf-logs-.
Blocked requests must get a branded HTML page with status 429 instead of the default AWS WAF response. What should the team configure?
A custom response on the Block action: status code, headers and body. It replaces the default 403 Forbidden.