AWS IAM: Understanding Least Privilege Beyond Basic Permissions
A practical guide to AWS identities, policy evaluation, role trust, and limiting the impact of compromised credentials.
Least privilege in AWS is often reduced to replacing AdministratorAccess with a smaller managed policy. That is a useful start, but it does not answer who can assume an identity, what resources it can reach, how other policies affect the decision, or whether the permissions allow the principal to create a more powerful path. Cloud identity security depends on the full authorization chain.
This article uses small policy examples to explain that chain. The examples are conceptual and should be validated in a non-production account before adaptation.
IAM building blocks
IAM users represent long-lived identities in an account. Groups collect users so common identity-based policies can be managed together. Roles are assumed to obtain temporary credentials and are commonly used by AWS services, federated workforce identities, and cross-account access. Avoid creating access keys for human users when federation or IAM Identity Center can provide temporary access.
Identity-based policies attach to users, groups, or roles and describe allowed actions on resources. Resource-based policies attach to resources such as S3 buckets or KMS keys and name the principals that may access them. A role has two distinct policy concerns: its trust policy states who may assume it; its permissions policies state what an assumed session may do.
How AWS reaches an authorization decision
Requests start with implicit deny. An applicable Allow can grant an action, while any applicable explicit Deny overrides allows. Effective access may also be limited by AWS Organizations service control policies, resource control policies, permissions boundaries, session policies, and resource policies. These are not interchangeable: policies can combine as unions or intersections depending on the policy types and the principal/resource context. Cross-account access normally requires authorization on both sides: the caller must be allowed to call sts:AssumeRole, and the target role's trust policy must trust that caller. AWS documents the evaluation rules and their important principal-specific exceptions.
A permissions boundary sets the maximum permissions an identity-based policy can grant to a user or role. It does not grant permissions by itself. A session policy further narrows a role session when supplied during role assumption. Neither should be treated as a universal safety net: resource policies that grant directly to certain session principals have nuanced behavior, and explicit denies remain decisive. Review the exact principal type and policy path.
Broad access versus a task-scoped policy
Suppose an application task only needs to read a set of reports. A broad policy such as this turns a read-only requirement into control over every S3 action and every bucket:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
The alternative names the required operation and resource prefix. Bucket listing is a bucket-level action, while reading an object is an object-level action, so their ARNs differ:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListReportsPrefix",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::acme-reports",
"Condition": { "StringLike": { "s3:prefix": ["quarterly/*"] } }
},
{
"Sid": "ReadQuarterlyReports",
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::acme-reports/quarterly/*"
}
]
}
The restrictive version still needs context. If the bucket uses a customer-managed KMS key, the workload may require narrowly scoped decrypt permission and the key policy must permit the path. If the application only reads known object keys, it may not need ListBucket at all. Start from observed task requirements, then test both expected success and forbidden actions.
Trust relationships and escalation paths
Trust policies should name the intended principal and constrain assumption with conditions where practical. For cross-account roles, use the specific source account or role rather than a broad principal. For AWS services, use the service principal and the confused-deputy conditions recommended for that service, such as aws:SourceArn and aws:SourceAccount where supported. External IDs can help protect third-party access patterns, but do not substitute for reviewing the third party's identity controls.
Overly broad permissions can enable escalation. Examples include changing one's own policies, creating access keys for a more privileged user, passing a powerful role to a service, modifying a trust policy, or changing a resource policy to expose sensitive data. The risk depends on the actions, resource scope, conditions, and other guardrails. Review permissions as paths an attacker could compose, not merely as isolated action names.
Finding and validating access
IAM Access Analyzer can identify external access paths for supported resources and can help generate policies from CloudTrail activity. Its findings are evidence to investigate, not a certification that the remaining access is safe. Policy validation and the IAM policy simulator can catch syntax or authorization problems, but simulation can differ from a live request when service context, resource policies, or organization controls are involved. AWS describes Access Analyzer and policy validation.
In a review, inventory identities, attached and inline policies, trust relationships, access keys, last-used information, and resource policies. Identify unused actions and risky policy-management permissions. Test changes in a staging account, observe denied requests, and monitor CloudTrail for actual use. A permission removed because it appears unused can still support an infrequent recovery or compliance task; confirm with the owning team before removing it.
Common mistakes and practical recommendations
Do not assume a role is safe because it uses temporary credentials; a temporary session with broad permissions still has broad power. Avoid wildcard actions and resources where the service supports resource-level restrictions. Do not use a permissions boundary as a substitute for reviewing identity policies. Keep human access, application roles, and deployment roles separate. Require MFA or federation controls for privileged human paths, and rotate or remove credentials that are no longer needed.
For a learning exercise, create a read-only role in a disposable account, attach the task-scoped policy, and test permitted and denied S3 requests with the simulator and actual test objects. This is a lab design, not a claim of a deployed environment. Record which policy explains each result. Then add a boundary or session policy and compare the effective permissions.
Conclusion
Least privilege is a property of the whole identity path: principal, trust, action, resource, conditions, boundaries, and resource-side controls. Small policies are easier to reason about, but only testing and ongoing review show whether they match the real workload. This identity discipline also prepares teams to secure the network paths and automated infrastructure that those identities control.