Repository navigation
fix(feeds): route feed discovery through the SSRF-checked client - #290
Merged
Merged
Conversation
validateFeed only checked the input URL once, then let feedfinder fetch pages, follow redirects and probe <a>/.well-known links with its own unrestricted client, so discovery could reach internal hosts. Inject the httpc client via feedfinder v0.2.0's Options.HTTPClient and drop the post-hoc result filter, which could not stop requests already sent. Also close a DNS rebinding gap in httpc: the dialer resolved the host a second time after the pre-dial check. Validate the resolved ip:port in net.Dialer.ControlContext instead. Fixes #275 Co-Authored-By: Claude Opus 5.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
POST /api/feeds/validateonly validated the input URL once. After that,feedfinder.Findfetched the page, followed redirects, and probed<a>and.well-knownlinks through its own unrestricted client, so it could reach internal hosts. The post-hoc filter only hid results; the requests had already gone out.This also fixes a DNS rebinding gap in
httpc. The old pre-dial check resolved the host once, and then the dialer resolved it again:ValidateRequestURL,redirectValidator, and the client pool are unchanged.feedfinderis bumped to v0.2.0, which addsOptions.HTTPClient. That pulls in gofeed v1.5.0, and MVS requires thex/*bumps.Fixes #275
Evidence
None of these tests touch the external network.
TestValidateDialAddressBlocksPrivateHost: rejects127.0.0.1,::1,10.x,::ffff:127.0.0.1, and::ffff:10.x. Allows public v4/v6 addresses. WithallowPrivate=true, allows everything.TestNewClientBlocksPrivateDialTargets:http://localhost:…andhttp://127.0.0.1:…against an httptest server are rejected, with 0 hits.TestClientBlocksDNSRebinding: an in-process fake DNS answers with a public IP, then with127.0.0.1. The request never reaches the server.TestValidateFeedBlocksRedirectToInternalAddress: the internal server gets 0 requests.TestValidateFeedDoesNotProbeInternalLinks: an<a href=internal>rss feed</a>link gets 0 requests.TestValidateFeedDiscoversPrivateFeedWhenAllowed: withAllowPrivateFeeds, a loopback feed is still found.Mutation checks, run in a temp copy (before = mutated code, after = this PR):
TestClientBlocksDNSRebindingFAIL:rebound request reached the server 1 timesControlContext/ dial checkTestNewClientBlocksPrivateDialTargetsandDoesNotProbeInternalLinksFAILfeedfinder.Find(ctx, target, nil)go vet ./...,go test ./... -race, and./scripts.sh test-backendall pass.Merge Danger
Door: two-way
There are no data or schema changes, and a revert restores the old behavior.
Blast Radius: feed-validate
These behavior changes are visible to users:
proxynow returns400 invalid proxyinstead of200with no feeds. The add-feed dialog shows its generic "detect failed" toast for this.AllowPrivateFeeds=false, a private proxy such as127.0.0.1:7890is now rejected for validate, because the dial check applies to the proxy address. Feed pulling (pull/parser.go) already behaved this way.<link>pointing at an internal URL can show up as a candidate. That URL is never fetched, and creating the feed still rejects it throughValidateRequestURL.🤖 Generated with Claude Code