ssrf
Guards against server-side request forgery via client-supplied URLs.
- class pipecat.utils.security.ssrf.UrlReachability(*values)[source]
Bases:
StrEnumWho can safely reach a URL’s host.
- PUBLIC = 'public'
Publicly routable — safe to hand to a third party to fetch itself.
- ALLOWED = 'allowed'
Within a trusted private network — safe for this server to fetch directly, but not to hand off to a third party that can’t reach it.
- BLOCKED = 'blocked'
Nobody should fetch it.
- pipecat.utils.security.ssrf.default_allowed_file_url_networks() list[str][source]
Return trusted networks from the
PIPECAT_ALLOWED_FILE_URL_NETWORKSenv var.Parses a comma-separated list of CIDR ranges (e.g.
10.0.0.0/8,192.168.0.0/16). Returns an empty list (trust only the public internet) when the variable is unset or empty.
- async pipecat.utils.security.ssrf.classify_url_reachability(url: str, allowed_networks: Sequence[IPv4Network | IPv6Network] = ()) UrlReachability[source]
Classify who can safely reach url’s host: the public internet, this server, or no one.
Resolution happens once, up front; it doesn’t defend against a target that resolves differently between this check and the actual connection (DNS rebinding).
- Parameters:
url – The URL to classify.
allowed_networks – Private networks this server is trusted to reach directly (e.g. where a deployment’s own file servers live), beyond the public internet.
- Returns:
PUBLICif every resolved address is publicly routable — safe tohand to a third party (e.g. an LLM provider) to fetch itself.
ALLOWEDif not publicly routable, but every address falls withinallowed_networks — safe for this server to fetch directly, but not to hand off to a third party that can’t reach it.
BLOCKEDotherwise: loopback, link-local (including the cloudmetadata range
169.254.0.0/16), private (RFC 1918), or unique-local (IPv6 ULA) addresses outside allowed_networks, or a host that fails to resolve.