Edge Protection with WAF and Shield

Block common web attacks, bots and abusive traffic with AWS WAF rules and rate limiting, and understand DDoS protection with Shield.

Intermediate · about 3 hours · difficulty 3/5

Learn first: Route 53 and CloudFront at the Edge, Elastic Load Balancing: ALB and NLB

Public endpoints are attacked constantly by bots, scanners and occasional DDoS floods. AWS provides protection at the edge so bad traffic never reaches your app. Azure Web Application Firewall with Front Door and Google Cloud Armor are the equivalents.

AWS WAF

  • Attach a web ACL to CloudFront, an ALB, API Gateway, AppSync or Cognito.
  • Managed rule groups from AWS cover the OWASP Top 10 style attacks (SQL injection, cross-site scripting), known bad inputs and IP reputation lists.
  • Rate-based rules limit requests per IP, essential for login and OTP endpoints that attackers abuse for SMS pumping.
  • Custom rules on headers, paths, query strings and geography.
  • Bot Control and CAPTCHA or challenge actions for automated traffic.
  • Start rules in count mode, check logs for false positives, then switch to block.

AWS Shield

  • Shield Standard is free and automatic for all customers, protecting against common network and transport layer DDoS attacks.
  • Shield Advanced is a paid subscription with application-layer DDoS mitigation, a response team and cost protection for scaling during attacks.

Defense in depth at the edge

CloudFront in front of origins, origins locked to accept traffic only from CloudFront, WAF on the distribution, and rate limits on sensitive endpoints.

Pitfalls

  • Blocking mode on day one, breaking legitimate users.
  • WAF on the ALB while attackers hit the origin directly by IP.

You are ready to move on when you can attach a web ACL with managed rules and a rate limit to an ALB or CloudFront, and prove the limit blocks a flood of requests.

Key concepts

  • Web ACLs
  • Managed rule groups
  • Rate-based rules
  • Count mode and WAF logs
  • Bot Control
  • Shield Standard vs Advanced
  • OWASP Top 10

Mini project

Attach a WAF web ACL with the AWS core rule set and a rate-based rule of 100 requests per 5 minutes to your CloudFront distribution or API. Use a loop of curl requests to trigger the block and view it in WAF logs. WAF bills per web ACL and rule monthly, so delete the web ACL the same day.

Check yourself

Why should you run new WAF rules in count mode first?

Free resources