Skip to content

feat(analyzer): detect SSRF (cloud metadata / internal-network / dynamic-host requests)#63

Open
CharmingGroot wants to merge 1 commit into
NVIDIA:mainfrom
CharmingGroot:feat/ssrf-analyzer
Open

feat(analyzer): detect SSRF (cloud metadata / internal-network / dynamic-host requests)#63
CharmingGroot wants to merge 1 commit into
NVIDIA:mainfrom
CharmingGroot:feat/ssrf-analyzer

Conversation

@CharmingGroot

Copy link
Copy Markdown

Fixes #62.

What this adds

A skill that performs SSRF — fetching the cloud metadata endpoint (169.254.169.254) to steal IAM credentials, or making requests to internal hosts — was not flagged by any analyzer. Adds a static_patterns_ssrf analyzer under a new "Server-Side Request Forgery" category:

  • SSRF1 — cloud metadata endpoints (AWS/GCP/Azure 169.254.169.254, metadata.google.internal, Alibaba 100.100.100.200, IPv6 IMDS) — HIGH
  • SSRF2 — requests to loopback / link-local / private-range hosts (localhost, 127.0.0.1, 10., 192.168., 172.16–31., ::1) — MEDIUM
  • SSRF3 — request URL whose host is built from a dynamic/untrusted value (requests.get(f"http://{host}/...")) — MEDIUM

The reproduction from the issue (a metadata credential-theft script) went from LOW (score 13) to CRITICAL (score 84).

Scope / non-overlap

Verified the reproduction triggers none of E1E4, taint tracking, or behavioral_ast — this is a distinct sink (inbound-to-internal request) from E1 (outbound exfil). The metadata IP is reported by SSRF1 only (no same-line duplicate with SSRF2). First-pass coverage anchors on Python/JS request functions and can be extended.

Testing

  • ruff check src/ tests/ and ruff format --check src/ tests/ pass.
  • pytest -m 'not integration' passes (606 passed, 11 skipped).
  • static_patterns_ssrf at 100% coverage. Tests cover: metadata / internal-host / dynamic-host detection, metadata-IP de-duplication, a false-positive guard (normal public HTTPS request is not flagged), and the node entrypoint.

…c-host requests)

A skill that fetches the cloud metadata endpoint (169.254.169.254) to steal IAM
credentials, or makes requests to internal hosts, was not flagged by any
analyzer: existing analyzers match outbound data exfiltration or exec/subprocess
sinks, not inbound-to-internal requests.

Add a `static_patterns_ssrf` analyzer: SSRF1 (cloud metadata access), SSRF2
(requests to loopback/link-local/private hosts), SSRF3 (request target built
from a dynamic/untrusted value). Adds a "Server-Side Request Forgery" category.

Add tests for detection, same-line de-duplication, false-positive guard
(normal public requests), and the node entrypoint.

Signed-off-by: CharmingGroot <ohyes9711@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(analyzer): no detection for SSRF / cloud-metadata credential theft

1 participant