fix: harden LinkContentFetcher against SSRF - #12452
Conversation
Validate every request target before the request is made, including each redirect hop: redirects are now followed manually with per-hop re-validation and a max_redirects cap (default 5). Add an optional allowed_hosts domain suffix whitelist and always reject hosts resolving to private, loopback, link-local, multicast, reserved, unspecified, unique-local, or shared address space ranges. Stream response bodies with a max_response_bytes cap (default 50 MB) and raise a clear error when it is exceeded.
|
@simpleqt is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @simpleqt, thanks for your interest in contributing to Haystack! 🙏 This is an automated message to help us keep the review queue healthy. |
|
Understood — thank you for the pointer. The SECURITY.md position is clear: URL-fetching components intentionally do not gate hosts and SSRF prevention belongs to the application/network layer, so the opt-in allowlist approach in this PR was out of scope. Closing is the right call; no concerns from our side. (The |
Validate every request target before the request is made, including each
redirect hop: redirects are now followed manually with per-hop re-validation
and a max_redirects cap (default 5). Add an optional allowed_hosts domain
suffix whitelist and always reject hosts resolving to private, loopback,
link-local, multicast, reserved, unspecified, unique-local, or shared
address space ranges. Stream response bodies with a max_response_bytes cap
(default 50 MB) and raise a clear error when it is exceeded.
Security context: LinkContentFetcher performed no target validation on user-supplied URLs (private/link-local/cloud-metadata ranges reachable, cross-host redirects followed without re-validation, unbounded response bodies), which turns any pipeline that feeds it untrusted URLs into an internal HTTP client with the response body landing in
Document.content.