Most serious breaches don't stop at the first account an attacker gets into. They spread, because that account could read every database, deploy to production or assume an admin role. The principle of least privilege limits the spread. NIST defines it as restricting the access privileges of users, and of processes acting for them, to the minimum needed for their assigned tasks. Jerome Saltzer and Michael Schroeder described it in 1975, and it still underpins access-control frameworks such as NIST SP 800-53 (control AC-6) and the access-control controls in ISO 27001 and SOC 2. Least privilege applies to more than people. Service accounts, CI pipelines, containers, API tokens, third-party integrations and AI agents all hold permissions, and they usually hold far more than they use.
What it looks like in practice
- People: role-based access, no shared admin accounts, and production access granted just in time for a ticket and removed automatically afterwards.
- Services: one identity per service, scoped to the tables, queues and buckets it uses, instead of one database superuser for everything.
- Tokens: OAuth scopes and API keys limited to specific actions, with short lifetimes.
- Pipelines: CI jobs get read-only repository tokens unless the job must write, and deploy credentials only on protected branches.
- AI agents: tools limited to the task. An agent that drafts replies to support tickets shouldn't be able to issue refunds.
Example: an AWS IAM policy for one service
An invoice service needs to read and write PDFs in one S3 bucket folder. The quick version grants s3:* on *, which also lets it delete every bucket in the account. The least-privilege version:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::acme-billing-docs/invoices/*"
}]
}
If an attacker gets the service's credentials through a dependency vulnerability, they can read and overwrite invoices. They can't list other buckets, delete data elsewhere or touch IAM. AWS IAM Access Analyzer can generate a starting policy like this from the service's actual CloudTrail activity.
How to apply it without slowing teams down
- Start from deny. Grant permissions when a real need appears, not in advance.
- Use roles and groups, not permissions attached to individuals, so changes happen in one place.
- Replace standing admin access with time-limited elevation that is approved and logged.
- Review access regularly. Check who holds what and which permissions go unused. SOC 2 and ISO 27001 auditors expect periodic access reviews.
- Remove access on exit the same day, through SSO and automated deprovisioning.
- Keep credentials out of code. Use workload identity and a secrets manager, so each service only gets its own secrets.
Least privilege vs zero trust
They're related but not the same. Least privilege decides how much access an identity has. Zero trust decides whether to trust each request, by verifying identity, device and context every time rather than trusting the network. A zero trust architecture applies least privilege to every request.
Common mistakes
- Granting broad access "temporarily" and never removing it.
- Letting developers keep production database credentials on laptops.
- Giving vendor and contractor accounts the same rights as employees. See the security checklist for outsourced development. We design cloud accounts, IAM and CI permissions this way in our cloud and infrastructure work.