Skip to content

fix(feeds): route feed discovery through the SSRF-checked client - #290

Merged
0x2E merged 1 commit into
mainfrom
fix/275-feed-validate-ssrf
Nov 23, 2026
Merged

0x2E merged 1 commit into
mainfrom
fix/275-feed-validate-ssrf

Conversation

@0x2E

@0x2E 0x2E commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Summary

POST /api/feeds/validate only validated the input URL once. After that, feedfinder.Find fetched the page, followed redirects, and probed <a> and .well-known links through its own unrestricted client, so it could reach internal hosts. The post-hoc filter only hid results; the requests had already gone out.

 validateFeed
   httpc.ValidateRequestURL(target)
-  feedfinder.Find(target, {RequestProxy})        # own client: no dial check, any redirect
-  drop results whose link is private             # requests already sent
+  client := httpc.NewClient(30s, proxy, allowPrivateFeeds)
+  feedfinder.Find(target, {HTTPClient: client})  # every request + redirect goes through httpc
   if no feeds
-    parseFeedTitle(target, proxy)                # built its own client
+    parseFeedTitle(client, target)

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:

 NewClient dialer
-  DialContext: validatePublicHost(host)  # lookup #1
-               dialer.DialContext(addr)  # lookup #2 → may be 127.0.0.1
+  ControlContext(ip:port): validateDialAddress  # checks the IP actually being connected
  • ValidateRequestURL, redirectValidator, and the client pool are unchanged.
  • feedfinder is bumped to v0.2.0, which adds Options.HTTPClient. That pulls in gofeed v1.5.0, and MVS requires the x/* bumps.

Fixes #275

Evidence

None of these tests touch the external network.

  • httpc
    • TestValidateDialAddressBlocksPrivateHost: rejects 127.0.0.1, ::1, 10.x, ::ffff:127.0.0.1, and ::ffff:10.x. Allows public v4/v6 addresses. With allowPrivate=true, allows everything.
    • TestNewClientBlocksPrivateDialTargets: http://localhost:… and http://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 with 127.0.0.1. The request never reaches the server.
  • validateFeed
    • TestValidateFeedBlocksRedirectToInternalAddress: the internal server gets 0 requests.
    • TestValidateFeedDoesNotProbeInternalLinks: an <a href=internal>rss feed</a> link gets 0 requests.
    • TestValidateFeedDiscoversPrivateFeedWhenAllowed: with AllowPrivateFeeds, a loopback feed is still found.

Mutation checks, run in a temp copy (before = mutated code, after = this PR):

Mutation Before After
Revert to resolve-then-dial (still compiles) TestClientBlocksDNSRebinding FAIL: rebound request reached the server 1 times PASS
Drop ControlContext / dial check TestNewClientBlocksPrivateDialTargets and DoesNotProbeInternalLinks FAIL PASS
feedfinder.Find(ctx, target, nil) redirect test FAIL (11 internal hits), link test FAIL (1 hit) PASS
Old post-hoc filter, no injection same failures as above PASS

go vet ./..., go test ./... -race, and ./scripts.sh test-backend all 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:

  • An unparsable proxy now returns 400 invalid proxy instead of 200 with no feeds. The add-feed dialog shows its generic "detect failed" toast for this.
  • With AllowPrivateFeeds=false, a private proxy such as 127.0.0.1:7890 is now rejected for validate, because the dial check applies to the proxy address. Feed pulling (pull/parser.go) already behaved this way.
  • With the post-hoc filter removed, a public page's <link> pointing at an internal URL can show up as a candidate. That URL is never fetched, and creating the feed still rejects it through ValidateRequestURL.

🤖 Generated with Claude Code

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>
@0x2E
0x2E merged commit 424fc44 into main Nov 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSRF protection bypass in POST /api/feeds/validate (feedfinder dependency)

1 participant