Security Playbook
03 · FundamentalsOWASP A01:20256 min read

Least privilege: limit the blast radius

Every user, service and key should have only the permissions its job needs, and nothing more. You can't prevent every compromise, but you decide how far a compromise can spread.

In one sentence

Assume something will get hacked. Least privilege makes sure that when it does, the attacker gets the keys to one room, not the whole building.

The idea

A small image-resizing service gets a vulnerability in a library it uses. How bad is that? It depends entirely on what that service is allowed to touch. If it runs with the same admin cloud key as everything else, the answer is: your database backups, your customers, everything.

Blast radius: what can a hacked service reach?
Permissions
Web appImage resizer☠ compromisedEmail senderBilling workerUsers tableOrdersCard tokensImages bucketEmail templatesDB backups
Hacked service
Image resizer
Reachable data
6/6
Data exposed
100%
Permissions
One admin key
Every service uses the same all-powerful key, so one bug in a tiny image resizer exposes everything, backups included.
Pick the hacked service and compare one shared admin key with scoped roles.

Where to apply it

LayerToo muchLeast privilege
Cloud IAMOne key with AdministratorAccess in every serviceOne role per service with only the actions and resources it uses
DatabaseApp connects as the owner/superuserApp user can SELECT/INSERT/UPDATE its tables; migrations use another user
PeopleEvery engineer is admin in productionRead-only by default, elevated access on request and time-limited
API tokensPersonal token with full account scope in CIFine-grained token for one repo, expires in 30 days
ContainersRuns as root with the host's networkNon-root user, read-only filesystem, no extra capabilities
{
  "Effect": "Allow",
  "Action": ["s3:GetObject", "s3:PutObject"],
  "Resource": "arn:aws:s3:::shop-images/*"
}

Making it practical

  • Start from zero and add permissions when something fails, instead of starting from admin and removing.
  • Separate identities per service and per environment: staging keys can't touch production.
  • Short-lived credentials (cloud roles, OIDC in CI) instead of long-lived keys in env files.
  • Review regularly: cloud providers show which permissions were actually used in the last 90 days.

Key takeaways

  • 01Give every identity the minimum permissions its job needs.
  • 02Design for compromise: limit what a hacked component can reach.
  • 03Prefer short-lived, scoped credentials over shared long-lived keys.
  • 04Separate environments and services so one leak doesn't become all leaks.

Check your understanding

1 of 3

What is the principle of least privilege?

Related concepts