Skip to Content
Asterrr's Handbook
3 · Infrastructure security

Edge Security with CloudFront, WAF and Shield

Layered edge protection. WAF rules, Shield DDoS, origin lockdown with OAC and secret headers, and central policy through Firewall Manager.

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?

Put the controls where traffic first lands. CloudFront absorbs and caches, AWS WAF filters web requests, Shield mitigates DDoS, and Firewall Manager applies the same policy to every account. Then make the origin accept traffic only from the edge.

HTTPSsecret headerOAC signedrulesDDoSpolicyrotateInternetCloudFrontAWS WAFShieldFirewall ManagerSecrets ManagerALB originS3 origin
Edge filtering with WAF and Shield, then origin lockdown. S3 trusts only the distribution through OAC. The ALB checks a secret header that Secrets Manager rotates.

Which one to use

SYN or UDP flood,reflection (L3/L4)HTTP flood or abusiveclient (L7)yesnoSQLi, XSS, bad inputsscrapers, credentialstuffing, fake sign-upsusers bypass CloudFrontand hit the originbrowser script fromanother site reads dataThreat at the edgeWhat kind?Shield Standard(automatic,free)Need SRT help, costprotection or auto L7mitigation?Shield Advanced+ WAFWAF rate-basedrule orAnti-DDoS ruleWAF managed rule groups(Core rule set, SQLdatabase)Bot Control, ATP, ACFPOAC for S3, VPC origins orsecret header for ALBS3 CORS rules and responseheaders policy
Decision tree for matching the threat to the edge control
Threat or needEdge controlPage
Volumetric layer 3 and 4 floodShield Standard (automatic). CloudFront and Route 53 absorb traffic at the edgeShield
Layer 7 flood, DDoS response team, cost protectionShield AdvancedShield
SQL injection, XSS, OWASP Top 10 payloadsWAF managed rule groupsWAF
Abusive client, scraper, credential stuffingWAF rate-based rules, Bot Control, Fraud ControlWAF
Same WAF rules in every accountFirewall ManagerWAF and Firewall Manager
Viewers bypassing CloudFront to hit the originOAC, VPC origins, secret headerCloudFront edge security
Missing security headersResponse headers policyCloudFront edge security
Browser blocked from a cross-origin S3 callCORS rule on the bucketS3 CORS
Device fleet publishing to AWS IoTIoT Core policy on the certificateThis page

AWS WAF

ItemDetail
ProtectsCloudFront, ALB, API Gateway REST API, AppSync GraphQL API, Cognito user pool, App Runner, Verified Access, Amplify and Bedrock AgentCore Gateway. Not EC2 directly
ContainerA web ACL (the console now calls it a protection pack) holds rules and rule groups
CapacityUp to 5,000 WCU per web ACL. Above 1,500 WCU costs more
Body inspection8 KB for ALB and AppSync. CloudFront, API Gateway, Cognito and others default to 16 KB, adjustable to 64 KB
Rate-based rulesUp to 10 per web ACL. Minimum rate is 10 requests
Default limits100 web ACLs, 100 rule groups, 100 IP sets per Region. 10,000 CIDRs per IP set
Blocked responseHTTP 403 by default, or a custom response

Managed rule groups

SourceCost
AWS Managed Rules (baseline, use-case specific and IP reputation groups, covering common web exploits such as OWASP Top 10 risks)No extra charge
Bot Control, Account Takeover Prevention (ATP), Account Creation Fraud Prevention (ACFP)Extra fee
AWS Marketplace rule groups from vendorsSubscription priced by the seller

You cannot read the individual rules in a managed group. AWS updates them as threats appear.

Shield

ItemShield StandardShield Advanced
CostIncluded for all customersSubscription
CoverageAutomatic protection against common DDoS attacksLayers 3, 4 and 7 on resources you explicitly add
ResourcesAutomaticCloudFront, Route 53 hosted zones, Global Accelerator standard accelerators, Elastic IPs, ALB, Classic LB, NLB (through an Elastic IP)
SelectionNothing to enableYou choose resources, or use a Firewall Manager policy

Firewall Manager

Needs AWS Organizations. One policy covers WAF, Shield Advanced, security groups, network ACLs, Network Firewall and DNS Firewall. It can protect every resource of a type or with a tag, and automatically covers new resources and accounts. You pay the underlying services such as WAF and AWS Config.

CloudFront origin protection

OriginControl
S3Origin access control (OAC). CloudFront signs requests with SigV4. The bucket policy grants cloudfront.amazonaws.com access with an AWS:SourceArn condition for the distribution. A KMS-encrypted bucket also needs a key policy statement for CloudFront. S3 website endpoints cannot use OAC
ALB or customAdd a custom header with a secret value in CloudFront. Add a WAF rule on the ALB that only passes requests carrying it. Rotate the secret with Secrets Manager
Both layersPut WAF at CloudFront and at the ALB so a direct hit on the ALB is blocked

OAC supports every Region, SSE-KMS, and PUT and DELETE. The older origin access identity (OAI) does not, so migrate from OAI to OAC.

Exam signal

"Only CloudFront may read the S3 bucket" means OAC with a bucket policy. "Apply WAF rules to every account automatically" means Firewall Manager. "Enhanced DDoS detection and mitigation for an ALB or Elastic IP" means Shield Advanced.

Exam trap

A WAF web ACL cannot be attached to an EC2 instance, a Network Load Balancer or an S3 bucket. Put the workload behind an ALB or CloudFront first.

Legacy

OAI (origin access identity) is the older CloudFront S3 mechanism. Newer features and Regions only work with OAC.

Integrations and third-party rules

  • 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 and their aws-waf-logs- destination naming are covered on AWS WAF and Firewall Manager.
  • Normalizing WAF and other logs into OCSF is covered on Security Lake and OCSF integrations.

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.

Further reading

On this page