Prevent SSRF via user-supplied feed URLs#1548
Merged
Merged
Conversation
Feed URLs were fetched with no scheme or host validation and with redirects followed, letting any authenticated user make the server issue requests to loopback, private/link-local ranges, and cloud metadata endpoints (GHSA-496x-437q-h35q, CWE-918). The sink was reachable from feed creation, feed update (via the next poll), and scheduled polling. Route all outbound feed fetches through a new SafeFetch helper that restricts the scheme to http/https and runs the request inside private_address_check's only_public_connections, which validates the actual connected IP on every redirect hop. This covers the direct HTTParty fetches in FeedDiscovery and Feed::FetchOne as well as the Feedbag discovery request, while still following legitimate redirects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an authenticated Server-Side Request Forgery (SSRF) in feed fetching — advisory GHSA-496x-437q-h35q (CWE-918). User-supplied feed URLs were fetched with no scheme or host/IP validation and with redirects followed, allowing any authenticated user to make the server issue requests to loopback, private/link-local ranges (e.g.
169.254.169.254), and other internal hosts. The sink was reachable fromPOST /feeds,PUT /feeds/:id(via the next poll), and scheduled polling.Fix
app/utils/safe_fetch.rbchokepoint that restricts the URL scheme tohttp/httpsand runs every outbound request insideprivate_address_check'sonly_public_connections, which validates the actual connected IP on each redirect hop (so legitimatehttp→httpsand other redirects still work).Feedbag.finddiscovery request inFeedDiscovery, and the scheduled fetch inFeed::FetchOne(which also covers thefeed_urlupdate path at poll time).file://local-read reachable through Feedbag'sopen-uri.Tests
spec/utils/safe_fetch_spec.rb; added an unsafe-URL case tospec/utils/feed_discovery_spec.rb.spec/integration/feed_importing_spec.rbto permit its local (loopback) test server, which the new guard correctly blocks by default.Notes
private_address_check.🤖 Generated with Claude Code