Skip to main content

Module ssrf

Module ssrf 

Source
Expand description

SSRF protection — a single shared implementation, no copies allowed.

is_private_ip / url_points_to_private_ip / guarded_get are security-critical; the whole workspace must have exactly one implementation. Originally authored for lc-tools (review Q1) and lifted into lc-core (0.20.0 S4 P1) so provider crates that cannot depend on lc-tools (e.g. lc-providers) share the same rules. Any rule evolution (adding CGNAT 100.64.0.0/10, new IPv6 special ranges, etc.) must only change here, otherwise the entry points would diverge: “URLFetch blocks intranet, Whisper allows intranet”.

Constants§

DEFAULT_GUARDED_TIMEOUT
Default timeout for guarded requests when the caller does not supply one.

Functions§

guarded_get
GET request with per-hop SSRF checks and IP pinning, following redirects manually.
guarded_post_json
POST request with a JSON body, behind the same resolve-once / validate-all / pin-IP protection as guarded_get. POST intentionally does not follow redirects (the 3xx response is handed back as-is), so only the first hop is checked. (A3)
is_private_ip
Check if an IP address is private/internal or otherwise non-routable for SSRF purposes.
url_points_to_private_ip
Resolve a URL hostname and check if it points to a private IP (async).