Skip to main content

Module netguard

Module netguard 

Source
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 ip must not be fetched, or None if 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 localhost names are refused. Returns the domain name to resolve.
resolve_public
Resolve host and return its addresses only if all of them are public.