SkillPilotAI

DDoS Protection, WAF and Bot Protection

Stopping fake traffic floods, hacking attempts (SQL injection, XSS) and bots at the edge, before they reach the website.

8.1 Why is it used?

  • In a DDoS attack lakhs of infected machines (a botnet) send traffic at once. Without protection the site goes down in minutes.
  • A WAF blocks OWASP Top 10 attacks like SQL injection, XSS and path traversal at the request level.
  • Bots buy up ticket/flash-sale stock, scrape prices and do credential stuffing. Genuine users lose out.
  • Downtime = direct revenue loss and brand damage, which is why big sites keep always-on protection.
  • Compliance (such as PCI-DSS) expects web application protection.

8.2 How it works

Defense in depth: bot attack + DDoS on a flash sale
  1. 1.Attack traffic (500 Gbps UDP flood + bots + HTTP flood) -> Anycast edge: traffic is spread across many PoPs and scrubbed, and nothing reaches the origin
  2. 2.WAF: managed rules (OWASP CRS) + a rate-based rule (2000+ requests from one IP in 5 min = block) + SQL injection payloads blocked
  3. 3.Bot management: bot score, JS challenge / CAPTCHA (reCAPTCHA / hCaptcha / Turnstile) on suspicious traffic
  4. 4.The origin (ALB) accepts traffic only from CDN/WAF IP ranges, so a direct origin attack fails
  5. 5.Genuine users' checkout keeps working; rules are tuned later from the logs

Defense in depth: CDN -> WAF -> rate limit -> app

  • DDoS types: L3/L4 volumetric (UDP flood, SYN flood, amplification) and L7 (HTTP flood, requests that look genuine).
  • Anycast + scrubbing: attack traffic gets spread across many edge locations around the world and is filtered there, and clean traffic goes to the origin.
  • WAF rules: managed rule sets (OWASP Core Rule Set, AWS Managed Rules) + custom rules (country block, header check, rate rules).
  • Bot management: browser fingerprinting, behaviour analysis, JS challenge, bot score. Good bots (Googlebot) are allowed, bad ones blocked.
  • CAPTCHA / challenge: verify suspicious traffic with reCAPTCHA, hCaptcha or Cloudflare Turnstile.
  • Rate-based rules: more than 2000 requests from one IP in 5 minutes means block. Against L7 floods.
  • Origin protection: hide the origin's IP and allow only CDN/WAF IPs, otherwise the attacker will hit the origin directly.
  • Modes: test a rule first in 'count/log' mode, then 'block'. To avoid false positives.

8.3 Which tools can be used

ToolTypeHow it is used
CloudflareEdge DDoS + WAF + Bot ManagementUnmetered DDoS protection (in all plans), managed WAF, Bot Management, Turnstile CAPTCHA.
AWS ShieldDDoS protection (AWS)Shield Standard is free (L3/L4); Shield Advanced is paid: L7 help, 24x7 response team, cost protection.
AWS WAFWeb Application FirewallAttached to CloudFront/ALB/API Gateway; managed rules, rate-based rules, Bot Control add-on.
Akamai (Prolexic, App & API Protector, Bot Manager)Enterprise security suiteLarge scrubbing capacity, common in banks and big e-commerce.
Google reCAPTCHABot detection / CAPTCHAv3 gives every request a score (0.0-1.0); extra verification or a block on a low score.
Azure DDoS Protection + Azure WAFDDoS + WAF (Azure)VNet-level DDoS protection; the WAF sits on Front Door or Application Gateway.
ModSecurity + OWASP CRSOpen-source WAFSelf-hosted WAF rules with Nginx/Apache.

8.4 Comparison: Cloudflare vs AWS Shield+WAF vs Akamai

PointCloudflareAWS Shield + WAFAkamai
Where it worksIts own anycast edge, in front of any originOn AWS resources (CloudFront, ALB, API GW)Its own global edge + scrubbing centers
DDoS (L3/L4)Unmetered, in all plansShield Standard free, Advanced paidProlexic: very large scrubbing capacity
WAFManaged rules, easy dashboardManaged + custom rules, pay per rule/requestApp & API Protector, managed tuning
Bot protectionBot Management (Enterprise), TurnstileAWS WAF Bot Control add-onBot Manager: advanced, expensive
SetupDNS change, in minutesAWS console/IaC, easy inside AWSEnterprise onboarding, weeks
CostStarts with a free planPay as you go; Shield Advanced ~3000 USD/monthEnterprise contract, the most expensive
Best forSites of every size, multi-cloudAWS-only workloadsBig banks, OTT, e-commerce

8.5 When to choose which

  • Cloudflare: when you want quick and cheap all-in-one protection, with the origin anywhere.
  • AWS Shield + WAF: when the app is entirely on AWS and CloudFront/ALB is already in use.
  • Akamai: a very large enterprise, a regulated industry, when you need dedicated SOC support.
  • reCAPTCHA / Turnstile: to stop bots on forms like login, signup, OTP, checkout. Use it together with a WAF.
  • Self-hosted ModSecurity: an on-prem app where a cloud WAF cannot be used.

8.6 Real-world example

Scenario: bot attack + DDoS on a flash sale

  1. A phone flash sale is at 12 PM; scalper bots start sending thousands of requests/second from 11:59.
  2. Alongside, the attacker also launches a 500 Gbps UDP flood; the anycast edge spreads it across many PoPs and scrubs it. Nothing reaches the origin.
  3. An HTTP flood at L7: a WAF rate-based rule (2000+ requests from one IP in 5 min) blocks those IPs.
  4. Bot management computes a bot score for every request; anything with headless-browser-like patterns gets a JS challenge/CAPTCHA.
  5. A SQL injection payload like ' OR 1=1 -- typed into the search box is blocked by the WAF managed rules.
  6. The origin ALB takes traffic only from CDN/WAF IP ranges, so a direct origin attack fails.
  7. Genuine users' checkout keeps working; the security team tunes the rules later by looking at the logs.

8.7 Interview tips

  • Explain the difference between L3/L4 and L7 DDoS, and say 'defense in depth: CDN -> WAF -> rate limit -> app'.
  • Mistake: putting the WAF straight into block mode. Genuine users can get blocked. Test in count/log mode first.
  • Mistake: leaving the origin IP public. The CDN/WAF gets bypassed. Allow only CDN IP ranges in the security group.
  • Mistake: relying only on CAPTCHA. CAPTCHA-solving services exist, so you need layered defense (rate limit + bot score + WAF).
  • Number: an example rate rule is 2000+ requests from one IP in 5 min = block; Shield Advanced is ~3000 USD/month.