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
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
| Attack | Layer | What stops it | Examples |
|---|---|---|---|
| SYN flood, UDP reflection, DNS amplification | L3/L4 | Provider edge, anycast and network DDoS protection | AWS Shield, Azure DDoS Protection, Google Cloud Armor, Cloudflare |
| HTTP flood on a costly page | L7 | WAF rate-based rules, Challenge or CAPTCHA, caching at the CDN | Rate-based rule scoped to /search |
| SQL injection, XSS, path traversal | L7 | Managed rule sets, and safe code in the app | Core rule set, SQL injection rules |
| Known exploit payloads | L7 | Known bad inputs rule set | Log4j-style headers |
| Credential stuffing, scraping bots | L7 | Bot control, rate limits on login | Bot control rule group |
| Traffic from regions you do not serve | L7 | Geo match rule (block or challenge) | Country allow list |
| Requests sent straight to the origin | Network | Origin locked to the CDN or WAF | CDN 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
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