mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
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>