40. DoS and DDoS – Availability Attacks
40.7 Detection and Defence Stack
Layered availability defence (ek tool nahi):
| Layer | What | Why |
|---|---|---|
| Monitoring / baselines | bps, PPS, RPS, latency, 5xx rate | You cannot fight what you do not see |
| Border / ISP / cloud scrubbing | Absorb volumetric junk upstream | Origin pipe is small |
| Anycast CDN | Spread attack across many PoPs | Classic large-site pattern |
| WAF / bot management | App-layer floods and scrapers | Cheap HTTP hurts origin |
| Origin rate limits + timeouts | nginx/Apache limits | Last line on your VM |
| Firewalld / ufw basics | Drop unexpected; rate modules where available | Host-only lab + prod alike |
| Architecture | Cache, queue, degrade gracefully | Fail soft, not black hole forever |
# firewalld example on Amazon Linux / CentOS-class lab YOU own
sudo yum install -y firewalld
sudo service firewalld start
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
# Ubuntu: sudo apt install ufw && sudo ufw allow 80/tcp && sudo ufw enable
# Always: rules first in lab snapshot; don't lock yourself out of SSH without console
| Red team (attacker) does | Blue team (defender) detects / stops |
|---|---|
| Multi-vector (UDP + SYN + HTTP) | Multi-layer scrub + WAF + origin limits |
| Rotates bot IPs | Behaviour / JA3 / challenge; not only static IP blocklists |
| Hopes SME has no on-call | Runbook + ISP/CDN contacts printed for Rani |
Ravindra Bagale's Tip
"We put Cloudflare in front, so we're 100% safe" – say students, and sometimes bosses. An origin IP leak = the CDN is bypassed. Hide the origin; allowlist only the CDN ranges on the firewall where the design fits. Interview: describe a stack, not a single product name.
Ravindra Bagale's Tip – मराठी
"Cloudflare लावला = 100% safe" – students आणि कधी कधी bosses. Origin IP leak = CDN bypass. Origin लपवा; design बसत असेल तिथे firewall वर फक्त CDN ranges allowlist करा. Interview: stack सांगा, एकाच product चे नाव नाही.
Ravindra Bagale's Tip – हिंदी
"Cloudflare लगा दिया = 100% safe" – students और कभी-कभी bosses. Origin IP leak = CDN bypass. Origin छिपाओ; जहाँ design fit हो वहाँ firewall पर सिर्फ़ CDN ranges allowlist करो. Interview: stack बताओ, एक product का नाम नहीं.
Lab
Draw defence stack diagram for Sahyadri Traders web shop: user → CDN/WAF → origin nginx 192.168.56.40 (lab). List 5 metrics Shahrukh (fictional SOC) watches. Enable firewalld/ufw on the origin VM; confirm Kali can still hit port 80 host-only; confirm random other ports closed.
Extended teaching notes
Why this lesson matters
Availability attacks try to exhaust bandwidth, connections or app workers. Learning them is about detection and defence — never about stressing networks you do not own (that can be illegal and harmful).
- Rate limits and WAF/CDN at the edge.
- SYN cookies / tuning on servers.
- Autoscaling with care (cost controls).
- Keep IoT devices off default passwords (Mirai lesson).
- Lab simulations only on isolated networks you own.
Mini case study
Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.
Defender's worksheet (do this today)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.
Indian workplace (sample data)
Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).
Global practice
Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.
Everyday analogy
Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.
Key terms
- Control: a safeguard (patch, config, process, detection).
- Finding: a weakness backed by evidence.
- Remediation: the fix plus how you verified it.
- Scope: systems you have written permission to touch.
- Least privilege: only the access the task needs.
- Defence in depth: several layers so one failure does not end the story.
Common mistakes
- Skipping written permission "just for a quick scan".
- Practising on hostel, office or public targets without authorisation.
- Collecting tool output without writing the fix.
- Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
- Publishing screenshots that contain secrets, cookies or internal hostnames.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Fix > spectacle.