Asterrr's Handbook

Edge protection

AWS WAF rules, managed rule groups, rate limiting, Bot Control and Fraud Control, Shield Standard and Advanced, CloudFront security headers and origin protection, S3 CORS, Firewall Manager, OCSF integrations and AWS IoT policies.

Exam tasks: 3.1 (edge security strategy, edge protection with CloudFront headers, WAF, IoT policies, OWASP Top 10, S3 CORS and Shield Advanced, rules for geography, rate limiting and client fingerprinting, OCSF and third-party WAF integrations)

The decision: which layer of the attack are you stopping (flood, abusive client, malicious payload, direct origin access), and which edge service stops it before it costs you capacity?

Matching the threat to the edge control

AWS WAF building blocks

The new console calls a web ACL a protection pack (web ACL). The API still uses WebACL.

  • Where it attaches: CloudFront, Application Load Balancer, API Gateway REST APIs, AppSync, Cognito user pools, App Runner, Amplify and Verified Access. Not NLB, and not EC2 directly.
  • Scope: CloudFront protection packs are global and must be created in us-east-1. Every other resource uses a regional protection pack in its own Region.
  • Rules are evaluated by priority. The first terminating action (Allow, Block, CAPTCHA or Challenge after failure) stops evaluation. Count records a match, adds labels and moves on.
  • Default action (Allow or Block) applies when nothing matches. Allow-by-default with block rules is normal for public sites. Block-by-default suits an API used only by known partners.
  • Labels let one rule tag a request and a later rule act on the tag. Managed rule groups emit labels you can match, which is how you override one noisy rule without dropping the group.
  • Capacity: each rule costs WCUs. A protection pack has 1,500 WCUs included, and you can pay for more up to 5,000.
  • Body inspection looks only at the first part of the body: 16 KB by default for CloudFront, API Gateway, Cognito, App Runner and Verified Access (raise to 64 KB for a fee), and a fixed 8 KB for ALB and AppSync. Set the oversize handling to Match or Block for APIs that must not accept uninspected payloads.

Rule statements worth knowing

NeedStatement
Allow or block known addressesIP set match (up to 10,000 CIDRs per set)
Country-level policyGeo match, optionally on a forwarded IP header. It adds country and region labels
Specific strings, User-Agent, pathString match or regex pattern set, with text transformations (URL decode, lowercase)
InjectionSQLi and XSS match statements, or the managed groups
Too many requestsRate-based rule (next section)
Header-order or TLS client identityJA3 / JA4 fingerprint match on the TLS ClientHello
Reuse rulesYour own rule group, or managed groups from AWS or AWS Marketplace

Exam signal

"The same client keeps rotating IP addresses" means IP-based blocking won't hold. Match or rate limit on a JA3/JA4 fingerprint, a header, a cookie or a session token instead. The TLS fingerprint stays the same while the address changes.

Rate-based rules

  • Count requests per aggregation key over an evaluation window of 60, 120, 300 (default) or 600 seconds.
  • Keys: source IP (default), IP from a header such as X-Forwarded-For, ASN, or custom keys combining headers, cookies, query arguments, URI path, HTTP method, labels, JA3 or JA4 fingerprint.
  • Count all with a scope-down statement rate limits a whole class of traffic, for example all POST /login requests from one country.
  • A scope-down statement narrows what gets counted. To throttle only one path or User-Agent, put the match in the scope-down, not in a separate rule.
  • The action can be Block, Count, CAPTCHA or Challenge, never Allow. The limit is approximate, not exact.

Rate limiting behind a proxy

Behind CloudFront or another proxy, every request to an ALB's protection pack comes from a proxy address. A rate-based rule keyed on source IP then throttles the proxy, not the attacker. Put the protection pack on CloudFront, or key on the forwarded IP header and accept that clients can spoof it.

Managed rule groups

GroupProtects againstExtra fee
Core rule set (CRS)Broad OWASP Top 10 web exploitsNo
Known bad inputs, Admin protectionLog4j-style payloads, exposed admin pathsNo
SQL database, Linux/POSIX/Windows OS, PHP, WordPressStack-specific exploitsNo
Amazon IP reputation, Anonymous IP listKnown-bad sources, VPNs, Tor, hosting providersNo
Bot Control (common or targeted level)Scrapers, crawlers, automation. Targeted adds browser interrogation, fingerprinting and MLYes
Fraud Control ATP (account takeover prevention)Credential stuffing on the login endpoint, checks for stolen credentialsYes
Fraud Control ACFP (account creation fraud prevention)Fake sign-ups on the registration endpointYes
Anti-DDoSLayer 7 floods, with Challenge for suspect clientsYes (included with Shield Advanced)
AWS Marketplace groupsVendor rules from firms such as F5, Fortinet, ImpervaSubscription
  • ATP and ACFP need you to tell WAF the login or registration path and where the username and password sit in the request. Add the application integration SDK (JavaScript or mobile) so clients get tokens, which makes Challenge and silent verification work.
  • Deploy a new managed group in Count first, read the labels in the logs, then switch to its default actions. Override one rule to Count if it blocks good traffic.
  • Pin a version of a managed group if you need change control. Otherwise AWS updates it automatically.

Legacy: use AWS WAF (v2) instead

AWS WAF Classic (conditions, separate regional and global APIs, rate-based rules fixed at 5 minutes) no longer accepts new configurations. Older material that talks about "conditions" and "rules with predicates" describes Classic.

Shield Standard vs Shield Advanced

Shield StandardShield Advanced
CostFree, always onMonthly subscription per organization, plus data transfer fees
LayersL3/L4 infrastructure attacksL3/L4 and L7, with WAF included at no extra WAF charge for protected resources
ResourcesAll AWS customers, all resourcesCloudFront, Route 53 hosted zones, Global Accelerator, ALB, CLB, Elastic IPs (EC2, NLB)
Automatic L7 mitigationNoYes: Shield adds and manages WAF rules during an attack
Health-based detectionNoYes, with Route 53 health checks. Required for proactive engagement
Shield Response Team (SRT)NoYes, 24/7. Requires Business or Enterprise Support
Cost protectionNoService credits for scaling charges caused by a DDoS attack
VisibilityBasicNear-real-time attack metrics and reports
  • Grant the SRT access with a role (AWSShieldDRTAccessPolicy) and, if they need your logs, access to the WAF log bucket.
  • Protection groups treat several resources as one for detection, for example all ALBs behind one app.
  • Resilience still comes from architecture: CloudFront and Route 53 absorb traffic at the edge, Auto Scaling absorbs what gets through, and a small attack surface means fewer targets.

Exam signal

Shield Advanced appears when the question says "DDoS cost protection", "access to AWS DDoS experts", "24/7 response team" or "automatic application layer DDoS mitigation". "Protect against DDoS at no extra cost" means Shield Standard, which every account already has.

us-east-1
Region for protection packs attached to CloudFront (and for ACM certificates used by CloudFront).
60–600 s
Rate-based evaluation window choices: 60, 120, 300 (default) or 600 seconds.
10
Lowest request limit a rate-based rule accepts.
1,500 WCU
Capacity included per protection pack before extra charges.
8 KB / 16 KB
Default body inspection limit for ALB and AppSync / for CloudFront and API Gateway.

CloudFront as a security layer

Security headers

  • A response headers policy adds headers to every response without touching the origin: HSTS (Strict-Transport-Security), X-Content-Type-Options: nosniff, X-Frame-Options, Referrer-Policy, Content-Security-Policy, and CORS headers.
  • Managed policies such as SecurityHeadersPolicy cover the common set. Create a custom policy for your own CSP.
  • CloudFront Functions are the lightweight option for custom header logic. Use Lambda@Edge only when you need the network, the body or longer run time.

Legacy: use response headers policies instead

Adding security headers with a Lambda@Edge origin-response function was the standard pattern before response headers policies existed. It still works, but it costs more and adds code you must maintain.

Keeping viewers off the origin

OriginHow to force traffic through CloudFront
S3 bucketOrigin access control (OAC) plus a bucket policy that allows cloudfront.amazonaws.com with AWS:SourceArn set to the distribution. Keep Block Public Access on. Works with SSE-KMS if the key policy allows the CloudFront service principal
Lambda function URLOAC with the function URL's auth type set to AWS_IAM
Private ALB, NLB or EC2VPC origins: the origin stays in private subnets with no internet-facing endpoint
Public ALBSecurity group allows only the CloudFront managed prefix list, and a WAF rule (or listener rule) requires a secret custom header that CloudFront adds. Rotate the secret with Secrets Manager

Legacy: use origin access control (OAC) instead

Origin access identity (OAI) doesn't support SSE-KMS objects, S3 in all Regions, or requests other than GET. Migrate OAI distributions to OAC and update the bucket policy to use the service principal.

  • Signed URLs (one object) and signed cookies (many objects) restrict who can fetch content. Use trusted key groups, not the root-user CloudFront key pair.
  • Geographic restrictions on the distribution allow or block whole countries. Use WAF geo match instead when you need exceptions, labels or combination with other conditions.
  • Set a modern TLS security policy for viewers, redirect HTTP to HTTPS, and use HTTPS to the origin.

S3 CORS

  • CORS tells a browser which other origins may read responses from your bucket with JavaScript. It isn't access control: curl and servers ignore it, and a CORS rule never grants S3 permissions.
  • A CORS configuration lists rules with AllowedOrigins, AllowedMethods, AllowedHeaders, ExposeHeaders and MaxAgeSeconds. S3 answers the browser's OPTIONS preflight from the first matching rule.
  • Troubleshooting: a browser error saying Access-Control-Allow-Origin is missing means no rule matched the origin, method or requested headers. Behind CloudFront, forward the Origin header (or use a CORS response headers policy), or cached responses will lack CORS headers.

Wildcard origins

AllowedOrigins: * with PUT or DELETE lets script on any website read responses and send writes to the bucket from a visitor's browser, as long as that script holds a presigned URL or credentials. Name the exact origins. And if the question says "users can download files directly by URL", the fix is bucket policy or OAC, not CORS.

Central management with Firewall Manager

  • Needs AWS Organizations, a Firewall Manager administrator account (the management account or a delegated one) and AWS Config turned on in the member accounts and Regions.
  • Policy types: WAF, Shield Advanced, security groups (common, content audit, usage audit), network ACLs, Network Firewall, Route 53 Resolver DNS Firewall, and third-party firewalls (Palo Alto Networks Cloud NGFW, Fortinet FortiGate CNF).
  • A WAF policy puts a first and last rule group around each account's own rules. The security team owns the baseline, and application teams can still add rules in between.
  • Auto remediation applies the policy to new resources that match tags or resource types as they appear.

Integrations: OCSF and third-party rules

  • Amazon Security Lake normalizes logs into the Open Cybersecurity Schema Framework (OCSF) in Parquet. Native sources include CloudTrail, VPC Flow Logs, Route 53 resolver query logs, Security Hub findings, EKS audit logs and WAF logs.
  • A third-party or custom source (an on-premises WAF, a CDN, a SaaS app) must deliver OCSF-formatted Parquet to its own S3 prefix, partitioned by Region, account and event day. Subscribers (a SIEM, Athena) then query everything in one schema. See Logging strategy.
  • Third-party WAF rules come as AWS Marketplace managed rule groups: subscribe, then add them to a protection pack like any managed group.
  • WAF logs go to CloudWatch Logs, S3 or Data Firehose, and the destination name must start with aws-waf-logs-. Redact fields such as the Authorization header in the logging configuration.

AWS IoT policies

  • Devices authenticate to IoT Core with X.509 certificates (or custom authorizers). An IoT Core policy attached to the certificate authorizes iot:Connect, iot:Publish, iot:Subscribe and iot:Receive.
  • Use policy variables such as iot:Connection.Thing.ThingName in resource ARNs, so each device can only use its own client ID and topics. A wildcard iot:* on * lets one stolen certificate impersonate the fleet.
  • Revoke or deactivate a compromised device certificate. AWS IoT Device Defender audits over-permissive policies and shared certificates.

Scenarios

Scenario
A ticketing company serves its site through CloudFront with an ALB origin. When sales open, a botnet sends login requests at about 400 per minute per address, rotating through thousands of residential IP addresses. Legitimate users are rarely blocked by the current IP-based rate-based rule because each bot IP stays under the limit. The company wants to stop the credential stuffing with the least custom code. What should the security engineer do?
Scenario · choose 2
A static documentation site is hosted in an S3 bucket encrypted with SSE-KMS using a customer managed key, and served through CloudFront. The auditors found that objects can also be fetched from the bucket's S3 endpoint. The security engineer must make the bucket reachable only through CloudFront. Which TWO steps are required?
Scenario
A holding company runs 60 AWS accounts in AWS Organizations. Each business unit owns its web applications on ALBs and API Gateway. The security team must guarantee that every current and future internet-facing ALB and API has the Core rule set and the Amazon IP reputation list evaluated before any business-unit rules, while business units keep adding their own rules. What should the team do?

Further reading

On this page