Ravindra BagaleCourses & study guides Track your progress

Guides

Cloud IAM Least Privilege

Cloud IAM least privilege means every human and workload identity gets only the actions and resources required for its job — nothing more — with MFA for humans, short-lived credentials for machines, and audit logs that prove who did what. Wide *:* admin policies are convenient until one key leaks; Capital One–era lessons still apply.

Friends! Clicking AdministratorAccess in the cloud console and saying "done" — OK for a temporary lab, not a production habit. Least privilege = needed actions + scoped resources + MFA + CloudTrail/activity logs. Today: AWS-style examples for defence; do not experiment in someone else's account. Own account / written authorisation only.

Quick answer

Cloud IAM least privilege checklist:

  1. Separate human users from workload roles (EC2 / Lambda / Kubernetes service accounts).
  2. Prefer roles + temporary credentials over long-lived access keys.
  3. Start deny-by-default; add only needed Action and Resource ARNs.
  4. Enforce MFA on humans; block root for daily work.
  5. Turn on cloud audit logs (CloudTrail / equivalent) and alert on IAM changes.
  6. Review unused permissions and stale keys quarterly.
  7. Break-glass admin account: monitored, MFA, rare use, ticketed.

Tiny mental model:

Identity → Authentication (MFA) → Authorisation (least privilege) → Audit
*:* admin = blast radius = entire account
Keys in git = incident waiting

What do I need before this guide?

What does least privilege look like?

Cloud IAM least privilege Admin-wide access is risky. Least privilege grants only the actions a role needs, with MFA and audit logs. Too wide * : * Admin everywhere Blast radius huge Least privilege Only needed actions Scoped resources MFA + audit logs Review quarterly shrink

Wide admin access is risky. Least privilege grants only needed actions, with MFA and cloud audit logs.

  1. Identity — who (user, role, service principal).
  2. Authentication — prove it (password + MFA, federation, workload identity).
  3. Authorisation — allowlist of actions on specific resources.
  4. Boundary / SCP / org policy — guardrails even administrators struggle to bypass casually.
  5. Audit — immutable-ish logs of API calls and console sign-ins.

Educational warning: practise IAM tightens in accounts you own. Do not “test deny policies” on a shared company prod account without change control — you can lock teams out.

Real incident: Capital One (2019) — cloud identity and misconfiguration themes

Public reporting on the Capital One 2019 breach described a misconfigured web application firewall / SSRF-style path leading to abuse of cloud metadata credentials and broad data access themes. The lasting blue-team lesson: instance roles and metadata, over-permissive IAM, and detection of unusual cloud API usage must be first-class controls — not afterthoughts.

Takeaways (vertical):

  1. What happened — cloud-hosted data exposure with identity/credential pathways in public analyses.
  2. What went wrong (theme) — excessive role permissions and insufficient guardrails around metadata / SSRF classes of bugs.
  3. Care-take — scope instance roles to exact S3 prefixes / APIs needed.
  4. Care-take — monitor CloudTrail for strange s3:List / credential-like patterns from web tiers.
  5. Care-take — IMDSv2-style hardening themes reduce casual metadata theft (follow current AWS guidance).
  6. Bonus parallel — countless breaches start with a leaked AKIA… key pushed to a public repo.

Humans vs workloads (do not mix)

  1. Humans: SSO + MFA + time-bound elevation for admin tasks.
  2. Workloads: roles assumed by compute — no shared “deploy user” password.
  3. Contractors: separate accounts or permission sets; expiry dates on access.
  4. Automation: prefer OIDC from GitHub Actions / GitLab to cloud roles over static keys.
  5. If you must use keys: minimum actions, short rotation, never on developer laptops long-term.

Red Team vs Blue Team (awareness only)

Red Team — what attackers try

  • Phish console passwords; bypass MFA fatigue where possible.
  • Steal long-lived keys from CI logs, images, chat pastes.
  • Abuse over-broad roles reachable from a single web foothold (high-level).

Blue Team — defend, detect, respond

  • MFA everywhere humans exist; passkeys where supported.
  • Short-lived federation (SSO) over permanent IAM users when possible.
  • Permission boundaries; remove unused actions with access analyser-style tools.
  • Alert: root login, Disable CloudTrail, AttachUserPolicy of Admin, CreateAccessKey surprises.
  • Rotate and delete unused keys; never embed keys in AMIs.

How do I apply least privilege step by step?

Step 1 — Inventory identities

  1. List human users, groups, roles, service accounts.
  2. Flag anything with Administrator / Owner equivalents.
  3. Flag access keys older than your policy (for example 90 days).

Step 2 — Split duties

  1. Billing ≠ security admin ≠ app deploy roles when the org is large enough.
  2. Developers get deploy roles to their namespaces / accounts — not org-wide IAM full control.
  3. CI systems get OIDC federation to cloud roles — not a static key in a variable if you can avoid it.

Step 3 — Write a narrow policy (AWS-shaped example)

Illustrative deny-by-omission idea (not a paste-blind into prod):

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["s3:GetObject", "s3:PutObject"],
    "Resource": ["arn:aws:s3:::learnfast-app-uploads/*"]
  }]
}

Contrast with "Action":"*","Resource":"*" — that second shape is a lab convenience, not a production lifestyle.

Step 4 — Attach to roles, not forever-users

  1. EC2 / ECS / Lambda assume a role.
  2. Humans assume roles via SSO permission sets.
  3. Document why each Action exists in a one-line comment in the repo that stores IaC.

Step 5 — Detect misuse

  1. CloudTrail (or Azure Activity / GCP Audit) on and centralised.
  2. Alerts for policy changes, root usage, unusual regions, mass ListBuckets.
  3. Correlate with identity provider sign-in risks.

Step 6 — Review cadence

  1. Quarterly: unused roles, unused actions, stale keys.
  2. After every incident: shrink the role that hurt you.
  3. Tabletop: “CI key leaked on GitHub — revoke path in 15 minutes?”

Ravindra Bagale's Tip

💡 Students give EC2 AdministratorAccess because an S3 test failed. Then they learn theory about blank-password apps stealing credentials via metadata. Write the exact Action first, then expand. Access Denied is the teacher; AdministratorAccess is a shortcut. In interviews state a least-privilege example clearly. Never forget!

Care-take — habits that shrink blast radius

  1. No root API keys; root MFA; root in a sealed process.
  2. SCP / org policies block leaving org, disabling security services (where available).
  3. Secrets in a manager — not in userdata plaintext.
  4. Separate prod / non-prod accounts.
  5. Break-glass with alarms.
  6. When an employee leaves: SSO disable first, then cloud keys.

How do I fix common IAM mistakes?

Ghabru naka 😅 — these are the usual ones:

Symptom Likely cause Fix
“AccessDenied” loops Missing Action or wrong Resource ARN Read the error’s needed action; scope narrowly
Keys in GitHub alert Long-lived key committed Rotate/delete immediately; switch to roles
Everyone is Admin Convenience culture Permission sets by job; time-bound elevation
Orphan roles Leavers / old projects Quarterly cleanup job
No idea who changed IAM Logging off / not watched CloudTrail + alerts + ticket link
Locked out of account Over-tight without break-glass Maintain monitored emergency path

Try it at home

In an AWS free-tier practice account you own (or local IaC plan):

  1. Create a role that can read one bucket prefix only; prove AccessDenied on another.
  2. Enable MFA on your IAM user (guide).
  3. List access keys; delete any you do not need.
  4. Write three CloudTrail alert ideas (root login, PutBucketPolicy, CreateAccessKey).
  5. Never paste real secret keys into chat or tickets.

Got it? Least privilege = only needed actions + scoped resources + MFA + audit. Admin convenience in production is costly. Capital One-era lesson: take role scope and metadata paths seriously. No keys in git. Next: learn AI security — prompt injection / data leakage defence.

Frequently asked questions

What is least privilege?

Granting only the permissions required for a job — nothing more — and reviewing them over time.

Why avoid long-lived access keys?

They leak via git, images and chat; roles with temporary credentials shrink that risk.

Is AdministratorAccess OK in a lab?

For short personal learning maybe; never as a production lifestyle.

What should I alert on first?

Root logins, disabling audit logging, attaching admin policies and surprise access-key creation.

How does Capital One relate?

Public analyses emphasised cloud identity, metadata and over-broad permissions themes — least privilege and monitoring matter.

Where are deeper lessons?

Cyber Part 11 cloud and AWS security — IAM done right and related detection lessons.