Skip to main content
Cloud IAM: Policies, Roles, Federation & Privilege Paths
Lesson 2 of 11

Cloud IAM: Policies, Roles, Federation & Privilege Paths

Evaluate cloud IAM policies, replace static access keys with federated roles, and detect privilege escalation paths such as wildcard iam:PassRole permissions.

Intermediate 28 min Cloud & DevSecOps

Learning objectives

  • Explain how cloud IAM evaluates explicit deny, explicit allow, and implicit deny rules
  • Configure short-lived IAM roles and OIDC or SAML federation instead of static credentials
  • Identify dangerous privilege escalation paths caused by wildcard iam:PassRole policies
  • Apply least-privilege scoping, condition keys, and IAM Access Analyzer checks

Recommended first: Cloud Fundamentals & Shared Responsibility (AWS, Azure, GCP)

#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:

  1. API RequestAuthenticated principal calls Action on Resource
  2. Default DenyStart with implicit deny
  3. Explicit Deny?Any matching Deny statement immediately blocks the call
  4. 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.

Short-lived role assumption via OIDC federationShort-lived role assumption via OIDC federationCI RunnerCloud STSCloud APIAssumeRoleWithWebIdentity (OIDC JWT)Verify issuer, audience, and sub claimTemporary credentials (15-60 min TTL)Call deploy action with SessionToken

#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:

json
{
  "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:

Checking role policies and Access Analyzer findings (lab account)
$ 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": "*" with iam:PassRole: Always restrict PassRole to specific role ARNs and add the iam:PassedToService condition key.
  • Overly open trust policies: Never set "Principal": "*" in a role trust policy, and require sts:ExternalId for third-party cross-account integrations or strict sub claims 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.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge