Ravindra BagaleCourses & study guides मराठी Track your progress

30. Cloud and AWS Security

30.3 Network Security in AWS

Security groups are stateful firewalls on each instance (Chapter 12). NACLs are stateless firewalls on each subnet – a second layer.

Good design for the reels app:

Resource Inbound rule Why
web-sg (EC2) 80, 443 from 0.0.0.0/0 Public website
web-sg (EC2) 22 from your IP only (/32) SSH never open to the world
db-sg (RDS) 3306 from web-sg only Database reachable only by the web server

Rules to follow:

  • Never 0.0.0.0/0 on 22 (SSH), 3389 (RDP), 3306 (MySQL) or 5432 (PostgreSQL). Internet-wide scanners (Chapter 19) find open ports within minutes.
  • Put databases in private subnets with "Publicly accessible = No".
  • Better than SSH: AWS Systems Manager Session Manager gives a shell with no open port 22 at all, and every session is logged.
  • Use a VPC endpoint for S3 so private instances reach S3 without going over the internet.
# Find any security group that allows SSH from the whole internet
aws ec2 describe-security-groups \
  --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.cidr,Values=0.0.0.0/0 \
  --query "SecurityGroups[].[GroupId,GroupName]" --output table

Ravindra Bagale's Tip

"It wouldn't connect, so I opened all traffic to 0.0.0.0/0" – that works in a lab, but in production it is an accident waiting to happen. Once the problem is solved, close the rule immediately. Also, your laptop's IP changes, so select "My IP" again in the SSH rule, not 0.0.0.0/0.

Lab

Run the CLI command above in your account. For every group it lists, change the SSH source to "My IP". Then confirm your RDS instance has "Publicly accessible: No" and db-sg allows 3306 only from web-sg.

Extended teaching notes

Why this lesson matters

Cloud security is mostly IAM, network exposure, logging and secure defaults. The shared responsibility model means the provider patches the metal; you patch what you configure.

  • No public databases or public admin panels.
  • Roles / OIDC instead of long-lived access keys.
  • CloudTrail / Activity Logs / Audit Logs on and retained.
  • S3/Blob/GCS: Block Public Access; encrypt; least privilege.

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)

  1. Write the lesson title, date and the exact lab target you are allowed to use.
  2. List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
  3. Run one safe check from the lesson on a lab system only. Paste the command and output.
  4. Write a two-sentence fix you would give a teammate.
  5. 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.