#Why this matters
In the cloud, Identity and Access Management (IAM) replaces the office perimeter. Every API call passes through the provider's authorization engine, and one overly broad policy can let a compromised build runner or test account elevate itself to administrator.
Understanding policy evaluation and permission chaining is essential for defending cloud accounts and auditing them safely.
#Principals, policies, and evaluation logic
Cloud IAM separates authentication (proving who the principal is) from authorization (deciding what the principal may do). In AWS IAM, permissions are written as JSON statements containing four core fields: Effect (Allow or Deny), Action, Resource, and optional Condition.
When a principal issues an API request inside a single account, the authorization engine follows a strict order:
- API RequestAuthenticated principal calls Action on Resource
- Default DenyStart with implicit deny
- Explicit Deny?Any matching Deny statement immediately blocks the call
- Explicit Allow?At least one Allow statement permits the call
An explicit Deny always overrides any Allow, even if another policy grants Action: "*" on Resource: "*". If neither an explicit Deny nor an explicit Allow matches, the request falls back to implicit deny and fails. Across multi-account organisations, Service Control Policies (SCPs) and permission boundaries act as upper guardrails that must also allow the action.
#Roles, temporary credentials, and federation
Long-lived static access keys (AKIA...) are a frequent source of breaches because leaked keys remain valid until manually revoked. Modern cloud architectures replace static keys with IAM roles and federation:
| Identity pattern | Credential lifetime | Typical use case | Main risk if misconfigured |
|---|---|---|---|
| Static IAM user keys | Long-lived (until rotated) | Legacy scripts (avoid) | Keys leaked in Git repos or logs |
IAM role (sts:AssumeRole) |
Short-lived (minutes to hours) | EC2, Lambda, cross-account access | Overly broad trust policy |
| SAML 2.0 federation | Session-scoped | Workforce single sign-on (SSO) | Stale IdP group memberships |
| OIDC federation | Short-lived per job | CI/CD (GitHub Actions, GitLab) | Missing repository sub condition |
Every role has two distinct policies: a trust policy (sts:AssumeRole rules defining who may assume the role) and a permissions policy (defining what the assumed role can do). With OpenID Connect (OIDC) federation, a CI pipeline exchanges a signed identity token for temporary cloud credentials (AccessKeyId, SecretAccessKey, SessionToken) without storing any permanent secret in the repository.
#Privilege paths and iam:PassRole
Even when a policy omits iam:* or AdministratorAccess, combinations of permissions can form a privilege escalation path. One of the most common cloud escalation primitives pairs iam:PassRole with a service creation action.
iam:PassRole allows a principal to attach an existing IAM role to a cloud service (such as Lambda, EC2, or Glue). Look at this risky developer policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:PassRole",
"lambda:CreateFunction",
"lambda:InvokeFunction"
],
"Resource": "*"
}
]
}Because iam:PassRole uses "Resource": "*", the developer is not limited to a low-privilege application role. They can create a new Lambda function, pass an existing AdminRole to it, write code inside the function that calls iam:AttachUserPolicy or reads secrets, and invoke it. The developer never directly held admin permissions, yet they executed code as AdminRole.
Security teams inspect policies with the AWS CLI and IAM Access Analyzer to detect broad wildcards and external trust exposure before deployment:
$ aws iam list-attached-role-policies --role-name ci-deployer-role
{
"AttachedPolicies": [
{
"PolicyName": "DeployerLambdaPolicy",
"PolicyArn": "arn:aws:iam::123456789012:policy/DeployerLambdaPolicy"
}
]
}
$ aws accessanalyzer list-findings --analyzer-arn arn:aws:access-analyzer:us-east-1:123456789012:analyzer/lab-analyzer --filter '{"status":{"eq":["ACTIVE"]}}'
{
"findings": []
}#Defending and common mistakes
- Using
"Resource": "*"withiam:PassRole: Always restrictPassRoleto specific role ARNs and add theiam:PassedToServicecondition key. - Overly open trust policies: Never set
"Principal": "*"in a role trust policy, and requirests:ExternalIdfor third-party cross-account integrations or strictsubclaims for OIDC. - Leaving static keys in code or CI: Replace IAM user access keys with IAM roles and OIDC or SAML federation.
- Skipping guardrails: Use AWS Organizations SCPs, permission boundaries, and IAM Access Analyzer (including unused-access findings) to cap maximum privileges and prune stale permissions.
#Summary
Cloud IAM evaluates explicit Deny over explicit Allow, defaulting to implicit deny when no statement matches. Replacing static access keys with short-lived roles and OIDC or SAML federation sharply reduces the blast radius of leaked credentials. Finally, auditing combined permissions such as wildcard iam:PassRole plus compute creation ensures attackers cannot chain ordinary developer access into administrative control.