Skip to content

Least privilege examples: does the policy fit the job?

Least privilege means a job gets only the permissions it needs. In these examples you read what an identity is for and the policy it holds, then decide: fits the job, or too broad.

Identity 1 of 8 · 0 right

photo-resizer (a role)Job: Makes small copies of new product photos in the photos bucket.
Access
Policy{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": "*", "Resource": "*" } }

Does the policy fit the job?

The businesses, consoles, keys and numbers are made up. This is practice in reading settings, not a security review of your own account.

Now find the traps yourself

Cloud security game: A small shop's cloud console is lighting up. Find the setting that lets strangers in and close it without breaking the shop.

Play

What least privilege means

AWS puts it in one line: grant only the permissions required to perform a task. A policy names the actions, the resources and the conditions, so the same rule can be read in every policy: what does this identity do, and what may it do?

The answer depends on the job, not on the asterisk. Allow * on * is the whole account; it fits an administrator's own sign-in, which AWS recommends for everyday tasks instead of the root user. For a program that resizes photos it is a trap. An asterisk at the end of arn:aws:s3:::shop-photos/* only means every file in that one bucket.

Three ways a policy is too broad

  • Every action on everything: "Action": "*" with "Resource": "*". AWS Security Hub's control IAM.1 fails a customer managed policy that has it.
  • Every action of one service: s3:* or ec2:*. In a customer managed policy, Security Hub's control IAM.21 fails it.
  • The right action on too much, or one action too many: reading every bucket, or deleting where the job only reads.

Least privilege is also a habit: AWS suggests regularly reviewing and removing the users, roles, permissions and credentials that are no longer needed.

Questions people ask

What is the principle of least privilege?

Grant only the permissions required to perform a task. In AWS terms: name the actions a job takes, on the resources it works on, under the conditions it needs.

Is a wildcard in an IAM policy always wrong?

No. arn:aws:s3:::photos/* means every file in one bucket, which can be exactly what a job needs, and some AWS actions cannot name a resource at all, so they take a Resource of *. What makes a policy too broad is more than the job needs: * as the Action, a whole service such as s3:*, or every bucket where one would do.

Who should have full administrator rights?

An administrator who runs the account. AWS recommends an administrative user for everyday tasks instead of the root user, protected with MFA. Programs get roles with their own small policies.

Where this comes from

Last changed . Providers change their settings and their advice: check the source before you act on one. Found a mistake? How we check, and how to tell us.

More about cloud security alert