← Back

LESSON 05

Cloud Security

Shared Responsibility Model

🏢 Provider (AWS/Azure/GCP)

Security OF the cloud:

  • Physical data centers
  • Hardware, networking
  • Hypervisor
  • Global infrastructure
+

👤 Customer (You)

Security IN the cloud:

  • Data encryption
  • IAM policies
  • Application security
  • Network configuration
Example: S3 bucket publicly exposed (Capital One breach 2019, 100M records):
AWS: Secured the hardware, data center ✓
Customer (Capital One): Failed to configure bucket permissions properly ✗

Shift Left Security

Shift Left = Move security testing earlier in the development lifecycle

  • Traditional: Security tested at deployment (too late, expensive to fix)
  • Shift Left: Security integrated during coding/building

Tools:

  • SCA (Static Code Analysis): Scans source code for vulnerabilities without running it
  • SAST: Security testing in development
  • DAST: Dynamic testing in staging
Example: Developer commits code with SQL injection vulnerability:
Without Shift Left: Vulnerability reaches production, hackers exploit it, data breach
With Shift Left: SCA tool flags it in the commit, developer fixes before merge

DDoS Protection

  • WAF (Web Application Firewall): Filters HTTP/HTTPS traffic, blocks SQL injection, XSS
  • Rate Limiting: Restricts requests per IP (e.g., 100 requests/minute)
  • CDN (CloudFlare, AWS CloudFront): Absorbs attack at edge locations
Example: E-commerce site during sale:
Normal: 1K requests/sec
DDoS Attack: 1M requests/sec (botnet)
Protection: WAF blocks malicious IPs, CDN caches content, rate limiting throttles bots

KMS (Key Management Service)

Centralized encryption key management:

  • Create: Generate encryption keys
  • Rotate: Automatic key rotation (reduces exposure)
  • Audit: Track who used which key when
Example: Database with customer credit cards:
Bad: Hardcoded encryption key in code (if code leaks, key leaks)
Good: KMS stores key, auto-rotates every 90 days, logs all access

Shared Responsibility Model

Cloud එකේ ආරක්ෂාව බෙදාගන්නවා provider එක (AWS) සහ customer (ඔබ) අතර:

Provider වගකීම (Security OF the cloud):

  • භෞතික data centers (ගොඩනැගිලි, ආරක්ෂකයින්)
  • Server hardware, networking උපකරණ
  • Virtualization ස්ථරය (hypervisor)

ඔබේ වගකීම (Security IN the cloud):

  • දත්ත encryption කරන්න
  • පරිශීලක අවසර නිවැරදිව configure කරන්න (IAM)
  • යෙදුම් කේතය ආරක්ෂිත කරන්න
  • Security groups, NACLs setup කරන්න

සැබෑ උදාහරණය: Capital One දත්ත කඩාවැටීම (2019) - වාර්තා 100M කාන්දු වුණා. AWS භෞතික ආරක්ෂාව නිවැරදියි, නමුත් Capital One S3 bucket එක ප්‍රසිද්ධියේ ප්‍රවේශ විය හැකි ලෙස තබලා තිබුණා (පාරිභෝගික දෝෂය).

Shift Left Security

සාම්ප්‍රදායික සංවර්ධනය වගේ: Code ලියන්න → Build → Test → Deploy → එවිට ආරක්ෂක පරීක්ෂාව. ගැටලුව: ආරක්ෂක ගැටලු production එකට ගියාම fix කරන්න විශාල වියදමක්.

Shift Left ප්‍රවේශය: ආරක්ෂක පරීක්ෂණ මුල් අවධීන්වල (සංවර්ධන කාලයෙන්) කරන්න.

SCA (Static Code Analysis): Code run කරන එකක් නැතිව, source code එක scan කරලා vulnerabilities බලනවා.

උදාහරණය: Developer කෙනෙක්ව SQL injection bug එකක් commit කරනවා code එකේ:
Shift Left නැතිව → Bug production එකට යනවා → Hackers exploit කරනවා → දත්ත කඩාවැටීම
Shift Left සමඟ → SCA tool එක commit කාලයේ flag කරනවා → Developer fix කරනවා merge කරන්න කලින්

DDoS ආරක්ෂාව

DDoS Attack කියන්නේ මොකක්ද? Attacker කෙනෙක්ව botnet එකක් (hijacked computers ලක්ෂ ගණන්) use කරලා website එකට එකම වේලාවේ requests ගොඩක් යවනවා. Server එක overwhelm වෙනවා, නීත්‍යානුකූල පරිශීලකයින්ට ප්‍රවේශය නැති වෙනවා.

ආරක්ෂණ ක්‍රම:

  • WAF (Web Application Firewall): HTTP traffic පෙරීම කරනවා, අනිෂ්ට requests අවහිර කරනවා (SQL injection, XSS ප්‍රහාර)
  • Rate Limiting: තනි IP එකකට requests 100/මිනිත්තුව විතර allow කරනවා. ඊට වඩා වැඩි නම් අවහිර.
  • CDN: CloudFlare වගේ සේවාව use කරලා traffic එක edge ස්ථාන වල බෙදා හරිනවා. ප්‍රහාරය අවශෝෂණය කරනවා ප්‍රධාන server එකට reach වෙන්න කලින්.

උදාහරණය: විකිණීමක් තියෙනවා, සාමාන්‍ය traffic 1000 requests/sec. DDoS ප්‍රහාරයකින් 1,000,000 requests/sec ඇවිත්. WAF + CDN use කරලා අනිෂ්ට traffic පෙරීම වෙනවා, නීත්‍යානුකූල පාරිභෝගිකයින්ට site එක ප්‍රවේශ විය හැකියි.

KMS (Key Management Service)

Encryption keys කළමනාකරණය කරන්න මධ්‍යම ස්ථානයක්:

  • Create Keys: ශක්තිමත් encryption keys උත්පාදනය කරනවා
  • Rotate Keys: ස්වයංක්‍රීයව keys වෙනස් කරනවා (මාස 3කට). Key එකක් සම්මුතියට ලක් උනත්, හානිය සීමිතයි.
  • Audit: කවුද, කවදාද, key එක use කළේ කියලා logs තියෙනවා

උදාහරණය: Database එකක credit card විස්තර තියෙනවා:
නරක පුරුද්ද → Encryption key එක code file එකේ hardcode (code කාන්දු උනාම key කාන්දුත් වෙනවා)
හොඳ පුරුද්ද → KMS use කරලා key එක ගබඩා, auto-rotation, ප්‍රවේශ logs