feat(analyzer): detect SSRF (cloud metadata / internal-network / dynamic-host requests)
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, Alibaba100.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 E1–E4, 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/andruff format --check src/ tests/pass.pytest -m 'not integration'passes (606 passed, 11 skipped).static_patterns_ssrfat 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.
Rebased onto current main — conflict in tests/nodes/analyzers/test_static_patterns.py resolved by preserving both the upstream TestRunStaticPatternsAgentSnooping tests and this PR's TestRunStaticPatternsSSRF tests. Each class keeps its own test_node_runs_over_state. uv.lock regenerated. All 28 tests pass. Ready to merge.
I do see conflicts due to other PRs getting merged. Sorry, can you resolve these ?
Resolved merge conflicts with upstream/main (as of the anti-refusal analyzer merge, #65).
Three files had conflicts — in each case both sides added new entries to the same list/dict, so the resolution was to keep both:
-
src/skillspector/nodes/analyzers/__init__.py: keptstatic_patterns_ssrf(this branch) andstatic_patterns_anti_refusal(upstream) in bothANALYZER_NODE_IDSandANALYZER_NODES. -
src/skillspector/nodes/analyzers/pattern_defaults.py: kept SSRF entries (SSRF1–SSRF3) alongside the new AR entries (AR1–AR3) inRULE_ID_TO_CATEGORY,PATTERN_NAMES,DEFAULT_EXPLANATIONS, andDEFAULT_REMEDIATIONS. -
tests/nodes/analyzers/test_registry.py: kept both"static_patterns_ssrf"and"static_patterns_anti_refusal"inEXPECTED_ANALYZER_NODE_IDS.
No logic changes — purely additive resolution. Full unit test suite: 937 passed, 2 pre-existing
failures in test_meta_analyzer.py that exist on upstream/main itself (unrelated to this branch).