Cloud IAM Permission Audit and Privilege Escalation Methodology
IAM/CAM permissions are the attack surface — an over-permissive policy is more dangerous than an RCE vulnerability.
⛔ Further Reading (Must Read)
- Detailed commands for the 5 AWS escalation paths, high-value data searches, and CloudTrail stealth → references/aws-escalation.md
- Tencent Cloud CAM escalation paths, tccli/SDK commands, and CloudAudit stealth → references/tencent-cam-escalation.md
Phase 1: Credential Identification and Identity Confirmation
| Credential |
Format |
Source |
| AWS AK/SK |
AKIA... (20 characters) |
Configuration file, environment variable, metadata |
| AWS temporary credentials |
ASIA... + SessionToken |
IMDS, STS AssumeRole |
| Azure SPN |
client_id + client_secret + tenant_id |
Configuration file |
| GCP SA key |
JSON file containing private_key |
Service account key file |
| Tencent Cloud SecretId/SecretKey |
AKIDz... (36 characters) / xxx= (Base64) |
Configuration file, environment variable, metadata |
| Tencent Cloud temporary credentials |
SecretId/SecretKey + Token/ExpiredTime |
Metadata, STS AssumeRole |
# AWS: who am I
aws sts get-caller-identity
# Azure
az account show
# GCP
gcloud auth list
# Tencent Cloud: who am I (prefer tccli)
tccli sts GetCallerIdentity
# Or use the 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())
"
Tencent Cloud Credential Configuration
# Interactive tccli configuration (preferred)
tccli configure
# Enter: SecretId, SecretKey, Region (e.g. ap-guangzhou), Output (json)
# When using temporary credentials, set the Token additionally
tccli configure set token "TOKEN_VALUE"
# It can also be set through environment variables
export TENCENTCLOUD_SECRET_ID="AKIDz..."
export TENCENTCLOUD_SECRET_KEY="xxxx="
export TENCENTCLOUD_SESSION_TOKEN="TOKEN" # for temporary credentials
Phase 2: Permission Enumeration
AWS Permission Enumeration
aws iam list-attached-user-policies --user-name <user>
aws iam list-attached-role-policies --role-name <role>
# Brute-force enumeration
aws s3 ls 2>&1; aws ec2 describe-instances 2>&1; aws iam list-users 2>&1
Tencent Cloud CAM Permission Enumeration (prefer tccli)
# 1. Account overview
tccli cam GetAccountSummary
# 2. List sub-users
tccli cam ListUsers
# 3. List user groups
tccli cam ListGroups --Page 1 --Rp 50
# 4. List roles (critical — roles can be abused through AssumeRole)
tccli cam DescribeRoleList --Page 1 --Rp 50
# 5. List policies (custom policies are the key to privilege escalation)
tccli cam ListPolicies --Scope Local --Page 1 --Rp 100 # custom policies only
tccli cam ListPolicies --Scope All --Page 1 --Rp 100 # all policies
# 6. View the content of a specific policy
tccli cam GetPolicy --PolicyId <PolicyId> --PolicyVersion 1
# 7. View the policies attached to a user
tccli cam ListAttachedUserPolicies --TargetUin <UIN>
# 8. View the policies attached to a role
tccli cam ListAttachedRolePolicies --RoleId <RoleId>
# 9. View the policies attached to a user group
tccli cam ListAttachedGroupPolicies --GroupId <GroupId>
# 10. List a user's AccessKeys
tccli cam ListAccessKeys
# 11. View role details (includes the trust policy — key for cross-account attacks)
tccli cam GetRole --RoleId <RoleId>
# 12. View the groups a user belongs to
tccli cam ListGroupsForUser --Uin <UIN>
Tencent Cloud Brute-Force Enumeration (probe service by service)
# COS storage (tccli cos does not support GetService, use the SDK or coscli)
coscli ls 2>&1
# Or the 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 instances
tccli cvm DescribeInstances 2>&1
# SCF cloud functions (similar to the Lambda escalation path)
tccli scf ListFunctions --Namespace default --Limit 50 2>&1
# CBS cloud disks
tccli cbs DescribeDisks 2>&1
# SSL certificates (may contain private keys)
tccli ssl DescribeCertificates --Limit 50 2>&1
# TDSQL/MySQL
tccli cdb DescribeDBInstances 2>&1
# Key management (KMS)
tccli kms ListKeys --Limit 50 2>&1
Permission Level Quick Reference
| Achievable Operations |
Escalation Potential |
| GetCallerIdentity only |
Low |
| cos:GetObject / s3:GetObject |
Medium (may find more credentials) |
| cam:List*, cam:Get* / iam:List*, iam:Get* |
Medium (enables analysis of escalation paths) |
| cam:CreateUser/AttachUserPolicy |
High (direct privilege escalation) |
| cam:CreateRole/AttachRolePolicy |
High (create a high-privilege role) |
| cam:PassRole + scf:CreateFunction |
High (indirect privilege escalation — attach a high-privilege role to SCF) |
| sts:AssumeRole |
High (hop to a higher-privilege role) |
Phase 3: Privilege Escalation Decision Tree
Current privileges?
├─ Can manipulate IAM/CAM (CreatePolicy/AttachPolicy) → direct privilege escalation
├─ Has PassRole + Lambda/SCF → indirect privilege escalation (create a service bound to a high-privilege role)
├─ Has AssumeRole → role chain hopping
├─ Data read access only → find more credentials (COS/S3/Secrets/Lambda/SCF code/User-Data)
└─ Detailed commands
├─ AWS → [references/aws-escalation.md](references/aws-escalation.md)
└─ Tencent Cloud → [references/tencent-cam-escalation.md](references/tencent-cam-escalation.md)
Notes
- The core of cloud privilege escalation: you must be able to manipulate IAM/CAM itself to escalate
- Temporary credentials expire, so prefer long-lived AK/SK or create a backdoor Access Key
- The cross-account trust policy is a critical audit point
- The Tencent Cloud role trust policy uses the
qcs::cam::uin/ROOT_UIN:uin/ANY_UIN format
- Tencent Cloud policy syntax resembles AWS but uses the
qcs resource descriptor
- Operations generate CloudTrail/CloudAudit logs — watch your operational traces
Escalation Path Overview
- Direct privilege escalation: create a policy that grants yourself
*:* permissions
- Indirect privilege escalation: PassRole + SCF/Lambda creates a function bound to a high-privilege role
- Role chain: current identity → AssumeRole → higher-privilege role
- Permission enumeration tools: enumerate-iam, Pacu (AWS); custom scripts (Tencent Cloud)
1---2name: cloud-iam-audit3description: "Cloud IAM permission auditing and privilege escalation. Use when you have obtained cloud platform credentials (AWS AK/SK, Azure SPN, GCP SA, Tencent Cloud SecretId/SecretKey) and need to assess the permission scope and escalation paths. Covers IAM/CAM policy analysis for AWS/Azure/GCP/Tencent Cloud, common escalation paths (PassRole, AssumeRole, Lambda/SCF escalation), cross-account attacks, and CloudTrail/CloudAudit evasion. Use this skill whenever any cloud credential, AK/SK, SecretId/SecretKey is found"4zh-signals: "审计 AWS/Azure/GCP/腾讯云凭据的权限范围与提权路径。信号:云IAM,提权,AWS,Azure,腾讯云,PassRole"5when-to-use: "Use when you obtain cloud credentials such as AWS AK/SK, Azure SPN, GCP SA keys, or Tencent Cloud keys and must assess permissions and escalation paths."6metadata:7 source: https://skillmd.com/skills/dangeroussong/cloud-iam-audit8 tags: "cloud,iam,cam,audit,privilege,escalation,aws,azure,gcp,tencent,tencentcloud,escalation,permission,credential,PassRole,SecretId"9 category: "cloud"10---1112# Cloud IAM Permission Audit and Privilege Escalation Methodology13- 攻击大类:C27 本地凭证与浏览器窃取1415IAM/CAM permissions are the attack surface — an over-permissive policy is more dangerous than an RCE vulnerability.1617## ⛔ Further Reading (Must Read)1819- Detailed commands for the 5 AWS escalation paths, high-value data searches, and CloudTrail stealth → [references/aws-escalation.md](references/aws-escalation.md)20- Tencent Cloud CAM escalation paths, tccli/SDK commands, and CloudAudit stealth → [references/tencent-cam-escalation.md](references/tencent-cam-escalation.md)2122---2324## Phase 1: Credential Identification and Identity Confirmation2526| Credential | Format | Source |27|------|------|------|28| AWS AK/SK | `AKIA...` (20 characters) | Configuration file, environment variable, metadata |29| AWS temporary credentials | `ASIA...` + SessionToken | IMDS, STS AssumeRole |30| Azure SPN | client_id + client_secret + tenant_id | Configuration file |31| GCP SA key | JSON file containing `private_key` | Service account key file |32| Tencent Cloud SecretId/SecretKey | `AKIDz...` (36 characters) / `xxx=` (Base64) | Configuration file, environment variable, metadata |33| Tencent Cloud temporary credentials | SecretId/SecretKey + Token/ExpiredTime | Metadata, STS AssumeRole |3435```bash36# AWS: who am I37aws sts get-caller-identity3839# Azure40az account show4142# GCP43gcloud auth list4445# Tencent Cloud: who am I (prefer tccli)46tccli sts GetCallerIdentity47# Or use the SDK48python3 -c "49from tencentcloud.sts.v20180813 import sts_client, models50from tencentcloud.common import credential51cred = credential.Credential('SecretId', 'SecretKey')52client = sts_client.StsClient(cred, 'ap-guangzhou')53print(client.GetCallerIdentity(models.GetCallerIdentityRequest()).to_json_string())54"55```5657### Tencent Cloud Credential Configuration5859```bash60# Interactive tccli configuration (preferred)61tccli configure62# Enter: SecretId, SecretKey, Region (e.g. ap-guangzhou), Output (json)6364# When using temporary credentials, set the Token additionally65tccli configure set token "TOKEN_VALUE"6667# It can also be set through environment variables68export TENCENTCLOUD_SECRET_ID="AKIDz..."69export TENCENTCLOUD_SECRET_KEY="xxxx="70export TENCENTCLOUD_SESSION_TOKEN="TOKEN" # for temporary credentials71```7273---7475## Phase 2: Permission Enumeration7677### AWS Permission Enumeration78```bash79aws iam list-attached-user-policies --user-name <user>80aws iam list-attached-role-policies --role-name <role>81# Brute-force enumeration82aws s3 ls 2>&1; aws ec2 describe-instances 2>&1; aws iam list-users 2>&183```8485### Tencent Cloud CAM Permission Enumeration (prefer tccli)8687```bash88# 1. Account overview89tccli cam GetAccountSummary9091# 2. List sub-users92tccli cam ListUsers9394# 3. List user groups95tccli cam ListGroups --Page 1 --Rp 509697# 4. List roles (critical — roles can be abused through AssumeRole)98tccli cam DescribeRoleList --Page 1 --Rp 5099100# 5. List policies (custom policies are the key to privilege escalation)101tccli cam ListPolicies --Scope Local --Page 1 --Rp 100 # custom policies only102tccli cam ListPolicies --Scope All --Page 1 --Rp 100 # all policies103104# 6. View the content of a specific policy105tccli cam GetPolicy --PolicyId <PolicyId> --PolicyVersion 1106107# 7. View the policies attached to a user108tccli cam ListAttachedUserPolicies --TargetUin <UIN>109110# 8. View the policies attached to a role111tccli cam ListAttachedRolePolicies --RoleId <RoleId>112113# 9. View the policies attached to a user group114tccli cam ListAttachedGroupPolicies --GroupId <GroupId>115116# 10. List a user's AccessKeys117tccli cam ListAccessKeys118119# 11. View role details (includes the trust policy — key for cross-account attacks)120tccli cam GetRole --RoleId <RoleId>121122# 12. View the groups a user belongs to123tccli cam ListGroupsForUser --Uin <UIN>124```125126### Tencent Cloud Brute-Force Enumeration (probe service by service)127128```bash129# COS storage (tccli cos does not support GetService, use the SDK or coscli)130coscli ls 2>&1131# Or the Python SDK:132# pip install cos-python-sdk-v5133# from qcloud_cos import CosConfig, CosS3Client134# client = CosS3Client(CosConfig(Region='ap-guangzhou', SecretId='Sid', SecretKey='Skey'))135# print(client.list_buckets())136137# CVM instances138tccli cvm DescribeInstances 2>&1139140# SCF cloud functions (similar to the Lambda escalation path)141tccli scf ListFunctions --Namespace default --Limit 50 2>&1142143# CBS cloud disks144tccli cbs DescribeDisks 2>&1145146# SSL certificates (may contain private keys)147tccli ssl DescribeCertificates --Limit 50 2>&1148149# TDSQL/MySQL150tccli cdb DescribeDBInstances 2>&1151152# Key management (KMS)153tccli kms ListKeys --Limit 50 2>&1154```155156### Permission Level Quick Reference157| Achievable Operations | Escalation Potential |158|------------|----------|159| GetCallerIdentity only | Low |160| cos:GetObject / s3:GetObject | Medium (may find more credentials) |161| cam:List*, cam:Get* / iam:List*, iam:Get* | Medium (enables analysis of escalation paths) |162| cam:CreateUser/AttachUserPolicy | **High** (direct privilege escalation) |163| cam:CreateRole/AttachRolePolicy | **High** (create a high-privilege role) |164| cam:PassRole + scf:CreateFunction | **High** (indirect privilege escalation — attach a high-privilege role to SCF) |165| sts:AssumeRole | **High** (hop to a higher-privilege role) |166167---168169## Phase 3: Privilege Escalation Decision Tree170171```172Current privileges?173├─ Can manipulate IAM/CAM (CreatePolicy/AttachPolicy) → direct privilege escalation174├─ Has PassRole + Lambda/SCF → indirect privilege escalation (create a service bound to a high-privilege role)175├─ Has AssumeRole → role chain hopping176├─ Data read access only → find more credentials (COS/S3/Secrets/Lambda/SCF code/User-Data)177└─ Detailed commands178 ├─ AWS → [references/aws-escalation.md](references/aws-escalation.md)179 └─ Tencent Cloud → [references/tencent-cam-escalation.md](references/tencent-cam-escalation.md)180```181182## Notes183- The core of cloud privilege escalation: you must be able to manipulate **IAM/CAM itself** to escalate184- Temporary credentials expire, so prefer long-lived AK/SK or create a backdoor Access Key185- The cross-account trust policy is a critical audit point186- The Tencent Cloud role trust policy uses the `qcs::cam::uin/ROOT_UIN:uin/ANY_UIN` format187- Tencent Cloud policy syntax resembles AWS but uses the `qcs` resource descriptor188- Operations generate CloudTrail/CloudAudit logs — watch your operational traces189190## Escalation Path Overview191- **Direct privilege escalation**: create a policy that grants yourself `*:*` permissions192- **Indirect privilege escalation**: PassRole + SCF/Lambda creates a function bound to a high-privilege role193- **Role chain**: current identity → AssumeRole → higher-privilege role194- **Permission enumeration tools**: enumerate-iam, Pacu (AWS); custom scripts (Tencent Cloud)