Expand description
SSRF protection for the fetch tool.
The classification functions are pure (they take an already-resolved IP), so they are
unit-testable without DNS. resolve_public does the real lookup and returns the
vetted addresses, which the caller pins for the connection so a second DNS answer
(rebinding) cannot swap in an internal address.
Functionsยง
- blocked_
reason - Why
ipmust not be fetched, orNoneif it is a normal public address. - check_
resolved - Check every address a host name resolved to; one internal answer blocks the lot.
- check_
url_ host - Host-name part of the policy that needs no DNS: IP literals (including
IPv4-mapped IPv6 and the numeric forms the URL parser normalises) and
localhostnames are refused. Returns the domain name to resolve. - resolve_
public - Resolve
hostand return its addresses only if all of them are public.