Skip to main content
Cloud basicsLesson 11 of 17

Protecting a Public Endpoint (WAF and DDoS)

A shop's public site gets real users, a botnet and an attacker probing for SQL injection, all at once. Follow which layer stops which traffic: the provider's edge for network floods, a WAF (web application firewall) for bad HTTP requests, and a locked origin so nobody can go around them.

Attack—
WAF action—
Response—
Origin loadNormal
Your VPCUsersReal shoppersBotnetThousands of IPsAttackerSQLi probesProvider edgeCDN · anycastWAFWeb ACL rulesWAF logsEvery decisionLoad balancerPublic DNS nameAppOriginHTTPSFloodProbe
RequestResponse / reportAppears in a later step

What you will learn

  • Network floods are absorbed at the edge, HTTP floods are not
  • Managed rule sets for SQL injection, XSS and known bad inputs
  • Rate-based rules per IP, bot control and geo rules
  • Start in count mode to find false positives
  • Lock the origin so nobody can bypass the WAF

Which layer stops which attack​

AttackLayerWhat stops itExamples
SYN flood, UDP reflection, DNS amplificationL3/L4Provider edge, anycast and network DDoS protectionAWS Shield, Azure DDoS Protection, Google Cloud Armor, Cloudflare
HTTP flood on a costly pageL7WAF rate-based rules, Challenge or CAPTCHA, caching at the CDNRate-based rule scoped to /search
SQL injection, XSS, path traversalL7Managed rule sets, and safe code in the appCore rule set, SQL injection rules
Known exploit payloadsL7Known bad inputs rule setLog4j-style headers
Credential stuffing, scraping botsL7Bot control, rate limits on loginBot control rule group
Traffic from regions you do not serveL7Geo match rule (block or challenge)Country allow list
Requests sent straight to the originNetworkOrigin locked to the CDN or WAFCDN prefix list, secret header, private origin

Try it yourself​

aws wafv2 list-web-acls --scope REGIONAL --region us-east-1 # Web ACLs for load balancers (use CLOUDFRONT for CDN)
aws wafv2 list-available-managed-rule-groups --scope REGIONAL --region us-east-1 # Managed rule sets you can add
aws wafv2 get-web-acl --name shop-acl --id <acl-id> --scope REGIONAL --region us-east-1 \
--query 'WebACL.Rules[].{name:Name,prio:Priority,action:Action,override:OverrideAction}' # Count or Block per rule
aws wafv2 get-rate-based-statement-managed-keys --scope REGIONAL --region us-east-1 \
--web-acl-name shop-acl --web-acl-id <acl-id> --rule-name search-rate # IPs currently rate limited
aws wafv2 get-logging-configuration --resource-arn <acl-arn> --region us-east-1 # Are logs going somewhere?
curl -s -o /dev/null -w '%{http_code}\n' -G https://shop.example.com/ --data-urlencode "id=1' OR '1'='1" # Expect 403
curl -s -o /dev/null -w '%{http_code}\n' --max-time 5 https://<origin-lb-dns-name>/ # Origin lock: expect a timeout or 403
aws ec2 describe-managed-prefix-lists --filters Name=prefix-list-name,Values=com.amazonaws.global.cloudfront.origin-facing # CDN ranges for the origin firewall

Check yourself

  1. Why does network-level DDoS protection at the edge not stop an HTTP flood?
  2. Why start a new managed rule group in count mode?
  3. The WAF is on the CDN, yet attackers still overload the app. What is the most likely cause?

Further reading: AWS WAF · AWS Shield · AWS managed rule groups · Google Cloud Armor overview · OWASP Top 10 · How a CDN Serves a Request · Reverse Proxies and Load Balancing