Least Privilege Design
Give exactly the access a job needs
Least privilege grants the minimum permissions a workload needs. It's implemented with resource scoping, condition keys, short-lived credentials, and aggressive use of deny-defaults — then enforced with monitoring.
What you will learn
- Scope permissions by resource, action and condition
- Use condition keys (MFA, IP, OIDC) to narrow further
- Maintain least privilege with tools and review
Least privilege = scoped actions on scoped resources with scoped conditions. Default-deny identity; add only the perimeter of a workload's real calls; use access analyzers and quarterly reviews to catch creep.
What is this?
Least privilege means each identity can do every action it legitimately needs and nothing more. Implementation: narrow Actions (deny wildcard admin), narrow Resources (ARN/tag/prefix), add Condition keys (MFA, source IP, OIDC subject, resource tags), use short-lived credentials, and default-deny. Tooling: AWS IAM Access Analyzer, Azure AD/AZTU unecessary permissions insights, GCP Recommender + access analysis. Policies are code; CI lints 'too broad' shapes.
Why do you need it?
- Blast radius: a stolen dev key can't touch prod if dev is scoped.
- Compliance (SOC 2, HIPAA) audits ask for evidence of least privilege.
- Broad permissions hide secrets: 'temporary admin' become permanent admin.
- Operational: narrow policies fail at the exact action, making debugging precise.
Mental model
A bank clerk with a limited drawer and a manager with the vault
Least privilege
The clerk can process deposits under $10k; the manager overrides with MFA and dual-control. You don't give the clerk the vault combination because one day they might need it — you give them a raised limit when justified.
How it works
- Start deny-all: enumerate a workload's actual API calls (or logs) and allow exactly those.
- Scope Resources to the ARNs/tags/prefixes the workload touches.
- Add Conditions: RequireMFA, SourceIp, ResourceTag, aws:PrincipalTag, oidc:sub.
- Prefer ephemeral: roles assumed with short TTL over long-lived keys.
- Review periodically: Access Analyzer/Insights flag unused roles, overly broad grants, unused keys.
Narrowing permissions down to actual use.
In production
- CI OIDC roles pinned to repo+branch so PRs can't assume deploy.
- Data engineers read one bucket prefix; a separate role writes to staging.
- Production keys are session-scoped with MFA and SourceIp conditions.
Best practices
- Think in verbs+objects: 'GetObject on acme-data/import/*' not 'S3 full'.
- Automate: Access Analyzer/Recommender feeding PR reviews.
- Prefer short-lived STS/sessions everywhere over static keys.
- Combine with break-glass: emergency admin requires approval and MFA.
Common mistakes
- Wildcards everywhere because it's 'simpler' (it's not — debugging != simple).
- Copying a full admin policy and trimming one action sometimes.
- Static access keys lying around for years.
- Grants by role-name without resource scoping, so anything in that ARN matches.
Common issues
App fails on an action you thought was allowedResource ARN or condition (tag/IP) mismatch
Enumerate the failing API's ARN and add a precise condition.
Principal uses wildcards and a demo turns into prod adminPolicy perpetuates breadth
Refactor to scoped policies via Access Analyzer suggestions and CI gates.
Debugging tips
- Audit effectively: list who can assume what and mark every wildcard action.
- When an app needs a permission, add exactly that permission, not 's3:*'.
- Use condition keys to explain 'why this party, why now'.
- Rotate and revalidate keys quarterly with an automated expired-key job.
Interview checkpoint
Hands-on lab
- Compare broad vs conditioned policies
- Use a condition (MFA/IP) to narrow
- Simulate allow/deny outcomes
Scope a Policy Down with Conditions
30 min · advanced
Quick quiz
Which makes a policy least-privileged?
Least privilege means every identity gets exactly the access its job needs.