Files
ruflo/v3/@claude-flow/cli/src
rUvandr 9b3e26d200 fix(security): pin http_fetch connections to DNS-checked addresses (SSRF via DNS) (#4605)
* fix(security): pin http_fetch connections to DNS-checked addresses (SSRF via DNS)

http_fetch refused loopback/RFC-1918/link-local hosts by looking only at the URL's hostname
text, then let fetch() resolve the name on its own. A name that resolves to (or rebinds to)
127.0.0.1, a private address or 169.254.169.254 passed the check and fetch() connected to it,
with CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE unset.

Requests now go through node:http/https with a lookup hook (http-fetch-pinned.ts): it resolves
every address of the host, refuses the host when any is private unless the opt-in is set, and
returns only the checked addresses to the socket, so the connection cannot land on an address
that was not checked (no TOCTOU between check and connect). Every redirect hop goes through the
same transport. Fresh connection per request (agent: false). IP literals are still checked by
text in validateUrl. The address check also covers ::, ::a.b.c.d, NAT64 64:ff9b::, 6to4
2002::/16, fe80::/10 and fec0::/10 in full, ff00::/8, 224.0.0.0/4 and up, 198.18.0.0/15 and
*.localhost.

Tests: a name resolving to loopback (localhost., no network) is refused and the internal server
sees no request, also as a redirect hop; the opt-in still reaches it; pinnedLookup refuses mixed
public+metadata answers, private IPv6 answers and empty answers, and passes public answers
through unchanged; address table. Redirect tests now inject the request function.

Co-Authored-By: RuFlo <ruv@ruv.net>

* ci: register CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE as an operator-only trust boundary

The env read moved into http-fetch-pinned.ts, outside the function the audit's param heuristic
had credited. It must stay env-only: a flag or tool argument would let the agent driving
http_fetch turn the SSRF guard off.

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>
2026-10-30 15:15:22 -04:00
..
…
…
…
…