Live lesson · progress saved to your account

Cloud & Container Security

Most cloud breaches are misconfigurations, not clever exploits. Learn the shared responsibility model, cloud IAM and the metadata service, CSPM, container images and Kubernetes, then investigate a public-bucket leak with a simulated cloud CLI and harden a Docker image.

advanced130 minwalkthrough

Anyone can read this lesson. To submit answers and earn XP, create a free account.

TASK 01Mission briefing: 2.1 lakh subscribers in a public bucket

EMAIL · from a security researcher · to security@lekhnimedia.example "Hi, while scanning for open storage I found a bucket named lekhni-subscriber-exports that anyone can list and download. It holds CSV files with names, emails, phone numbers and plan details of roughly 2.1 lakh subscribers. I have not shared it. Please fix it fast."

Lekhni Media (fictional) runs a Mumbai news site and an OTT subscription app, all on a public cloud. Nobody hacked a server. Nobody used a zero-day. Someone changed one setting, and the internet did the rest:

Public bucket leak: one setting, then the bots T+0 h

s3://lekhni-subscriber-exports

{
  "Effect": "Allow",
  "Principal": {"AWS": "arn:…:role/vendor"},
  "Action": ["s3:GetObject", "s3:ListBucket"],
  "Resource": "arn:aws:s3:::lekhni-subscriber-exports/*"
}

subscribers_2026_10.csv

subscribers_2026_09.csv

renewals_q3.csv

payment_fail_list.csv

Who shows up

scanner-a (bucket name brute force)…
scanner-b (open-storage search engine)…
researcher (responsible disclosure)…
unknown (bulk download)…

objects downloaded: 0

Block Public Access overrides any policy or ACL that would make the bucket public, so a single careless policy edit can't leak data. Set it at the account level too.

Automated scanners sweep cloud storage name spaces around the clock. A bucket that turns public is usually found in hours, not weeks. That's why the most common cloud breach isn't an exploit at all: it's a misconfiguration.

In this room you'll learn who is responsible for what in the cloud, how cloud identity really works, how to find misconfigurations at scale, and how to secure containers and Kubernetes. Then you'll investigate Lekhni's account with a simulated cloud CLI, fix it, and write the post-incident summary.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 02Cloud models and shared responsibility

In the cloud you rent someone else's computers, but you don't hand over all of security. The shared responsibility model splits the stack between the provider and the customer. AWS phrases it neatly: the provider is responsible for security of the cloud, the customer for security in the cloud.

Shared responsibility: who secures each layer? IaaS
Datacustomer · always
Identity & accesscustomer · always
Applicationcustomer
Runtime & middlewarecustomer
Guest OScustomer
Virtualisationprovider
Physical hosts & networkprovider
Data centreprovider

IaaS: the provider stops at the hypervisor. Patching the guest OS and configuring firewalls are yours.

  • IaaS (Infrastructure as a Service): virtual machines, networks, storage. The provider runs the data centre, hardware and hypervisor; you patch the guest OS, configure the network and firewall rules, and secure everything above.
  • PaaS (Platform as a Service): managed databases, app platforms, serverless functions. The provider also patches the OS and runtime; you own your code, configuration and access.
  • SaaS (Software as a Service): email, CRM, office suites. The provider runs nearly everything; you still own your data, your users and their access.

Two layers never move to the provider: data and identity & access. Lekhni's bucket was perfectly secure of the cloud. The policy that opened it was in the cloud, Lekhni's side of the line.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 03Cloud IAM: policies, keys and the metadata service

In the cloud, identity is the new perimeter. Every API call (create a VM, read a bucket, stop logging) is authorised by IAM (Identity and Access Management) policies: JSON documents of Effect, Action, Resource and optional Condition.

IAM policy evaluation: deny always wins ALLOW

GetObject · s3://lekhni-subscriber-exports/subscribers.csv · user analyst.meera

Request arrives
Default: implicit deny
Any explicit deny?

no

Any explicit allow?

yes

Decision

ALLOW

Remove every policy and the answer is still deny: nothing is allowed unless something explicitly allows it. Add a deny anywhere and no allow can override it.

The evaluation logic is the same idea across clouds:

  1. Everything starts as an implicit deny.
  2. An explicit deny in any applicable policy always wins.
  3. Otherwise, access needs an explicit allow, and organisation guardrails (like AWS Service Control Policies) and permission boundaries can only narrow it.

Good practice: humans sign in through SSO with MFA and assume roles with short-lived credentials; workloads use roles attached to the instance or function, never long-lived access keys pasted into code. Grant least privilege and review unused permissions.

The metadata service. A cloud VM can ask a special link-local address, 169.254.169.254, for details about itself, including the temporary credentials of its attached role. If the app has a Server-Side Request Forgery (SSRF) bug (Room 15), an attacker can make the server fetch that address for them. This pattern was central to the widely reported 2019 Capital One breach.

SSRF to the metadata service IMDSv1 allowed
attackerGET /fetch?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/
appServer fetches the URL for the attacker (SSRF)
imds200 OK → role name: lekhni-cms-role
attackerGET …/security-credentials/lekhni-cms-role
imds200 OK → {"AccessKeyId": "ASIA…", "SecretAccessKey": "…", "Token": "…"}
attackeraws s3 sync s3://lekhni-subscriber-exports . → using the role's own permissions

Defence in depth: fix the SSRF, require IMDSv2, and give the role only the permissions the CMS needs, so stolen credentials can't read subscriber exports anyway.

IMDSv2 defends against this: a client must first send a PUT request to get a session token, then present it in a header. Typical SSRF bugs can only send GETs, and a hop limit of 1 stops the token from travelling beyond the instance.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 04Misconfigurations and CSPM

Cloud accounts change hundreds of times a day, through consoles, scripts and infrastructure-as-code. The same handful of mistakes cause most incidents:

  • Public storage: bucket policies or ACLs granting "Principal": "*". AWS now enables Block Public Access and disables ACLs on new buckets by default (since April 2023), but older buckets and explicit overrides remain.
  • Open security groups: SSH (22) or RDP (3389) allowed from 0.0.0.0/0, the whole internet.
  • Logging disabled: no CloudTrail (or equivalent audit log), so nobody can answer "who did this?"
  • Over-privileged identities: AdministratorAccess on everyday users, old access keys, no MFA.
  • Unencrypted data and public snapshots of disks and databases.
CSPM: checking every resource against the benchmark 0/9 scanned
critical 0high 0passed 0

s3 · lekhni-subscriber-exports

scanning…

s3 · lekhni-web-assets

ec2 · sg bastion-sg

ec2 · sg web-sg

iam · dev.kunal

cloudtrail · lekhni-org-trail

rds · cms-db

ebs · snap-cms-backup

kms · cms-key

The scan doesn't need an exploit: it reads configuration through the cloud's own APIs. Attackers' scanners do the same from the outside.

Cloud Security Posture Management (CSPM) tools continuously compare every resource against benchmarks like the CIS Foundations Benchmarks and raise findings ranked by severity. Open-source options include Prowler and ScoutSuite; every major cloud ships its own as well. The best teams also scan infrastructure-as-code (Terraform, CloudFormation) before it deploys, so the misconfiguration never reaches production.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 05Containers: images, layers, registries and runtime

A container packages an app with its libraries, but shares the host's kernel. It's isolation by Linux features (namespaces, cgroups, capabilities), not a separate machine like a VM.

An image is a stack of read-only layers, one for each RUN, COPY or ADD instruction in the Dockerfile. Images live in registries and are pulled by tag or, more safely, by immutable digest.

An image is a stack of layers click a layer

lekhni/cms:1.4 (top layer last)

The scanner walks every layer and matches installed packages against vulnerability databases. Click a layer to see what it adds.

registry→pull by digest sha256:…

Image security:

  • Start from a small, maintained base image (slim, alpine or distroless) and pin its version. Fewer packages means fewer vulnerabilities.
  • Scan images in CI and in the registry with tools like Trivy or Grype, and fail builds on critical findings.
  • Never bake secrets into images. Deleting a file in a later layer doesn't remove it from the earlier layer: anyone who pulls the image can extract it.
  • Use multi-stage builds so compilers and dev dependencies don't ship.

Runtime security: a container runs as root unless the image sets USER. Root in a container plus --privileged or a mounted host filesystem is one step from the host:

Container escape (concept) host at risk

Host (shared kernel)

container: lekhni/cms

Attacker gets a shell in the CMS container via a vulnerable plugin

whoami → root

Writes a backdoor into /usr/local/bin

Uses kernel capabilities from --privileged to mount the host disk

chroot /host → now editing the host's crontab

Each control breaks the chain at a different step. Use all of them: the first one an attacker meets is the one that matters.

Run as non-root, with a read-only root filesystem, drop all capabilities you don't need, and never use --privileged or mount the Docker socket into an app container.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 06Kubernetes security basics

Kubernetes (K8s) schedules containers across a cluster. The pieces you must know:

  • Pods: one or more containers scheduled together; the smallest unit.
  • Namespaces: logical partitions (frontend, payments); RBAC and policies are scoped to them.
  • RBAC: Roles (namespace) and ClusterRoles (cluster-wide) list allowed verbs on resources; RoleBindings and ClusterRoleBindings grant them to users and service accounts.
  • NetworkPolicies: by default every pod can talk to every pod. A default-deny policy plus explicit allows turns the flat network into a segmented one (it needs a CNI plugin that enforces policies).
  • Secrets: stored base64-encoded, which is encoding, not encryption. Enable encryption at rest for etcd, restrict who can get secrets, or use an external secrets manager.
  • Pod Security Standards: Privileged, Baseline and Restricted profiles, enforced per namespace by Pod Security Admission.
Kubernetes: flat by default, segmented by policy compromised: frontend
namespace: webnamespace: datanamespace: payfrontendapipostgrespayments

$ kubectl get secrets -A (from inside frontend)

NAME TYPE DATA cms-db-creds Opaque 2 pay-gateway Opaque 1

data.password: TGVraG5pQENtczIwMjY=

Base64 is encoding, not encryption. Turn on etcd encryption at rest and restrict get secrets.

The OWASP Kubernetes Top Ten lists the usual failures: insecure workload configurations, overly permissive RBAC, missing network segmentation, secrets mismanagement, and an exposed API server or dashboard.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 07Hands-on: investigate and fix Lekhni's cloud account

You have read-write access to Lekhni Media's account through a simulated cloud CLI (AWS-style commands). Find out how the bucket became public and who did it, then fix the bucket, the identity, the network and the logging.

Lab · Investigate and fix the cloud account 0/5 goals
cloudshell · ap-south-1
ir.responder@lekhni-cloudshell:~$ AWS-style CLI (simulated) · account 441722901186 · ap-south-1 · type 'help'
$

Goals

Find who made the bucket public (CloudTrail)

Make the bucket private again

Disable the over-privileged user's old access key

Close SSH to the internet

Turn the organisation trail back on

Hints: start with aws s3 ls and aws s3api get-bucket-policy --bucket NAME. CloudTrail's event history keeps 90 days of management events even when no trail is logging: aws cloudtrail lookup-events --lookup-attributes AttributeName=EventName,AttributeValue=PutBucketPolicy. Then look at aws iam list-access-keys --user-name USER, aws ec2 describe-security-groups and aws cloudtrail get-trail-status --name TRAIL. Type help for the fix commands.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

TASK 08Hands-on: scan and harden the CMS image

The same team ships Lekhni's CMS as a Docker image. Before it goes back to production, harden the Dockerfile and the way it runs. Click each risky line to fix it, then run the scanner.

Lab · Scan and harden the CMS image 0/6 fixes
Dockerfile + run command · click a line to fix it

WORKDIR /app

EXPOSE 3000

CMD ["node", "server.js"]

Counts are illustrative. Real scanners match each installed package version against vulnerability databases.

The scan counts are illustrative, but the pattern is real: a full latest base image drags in hundreds of packages you never use, and each can carry known vulnerabilities.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

TASK 09Final mission: the post-incident summary

The bucket is locked, the key is dead, logging is back. Now Lekhni's leadership, the regulators and the subscribers need answers.

In India, CERT-In's April 2022 directions require reporting cyber incidents, including data leaks, to CERT-In within 6 hours of noticing them. The Digital Personal Data Protection Act, 2023 requires a data fiduciary to notify the Data Protection Board of India and each affected Data Principal of a personal data breach.

Final mission · Post-incident summary blameless + precise

1. Root cause

2. Exposure started (closed 2026-11-29)

3. Who must be notified

4. Structural fixes (choose every right control, nothing else)

A good post-incident summary is blameless but precise: what happened, when it started and ended, what data was exposed, the root cause, and the controls that make it structurally impossible to repeat, not just a promise to be careful.

Complete the mission for the Cloud Guard badge and the room's XP.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP