Skip to content

Fix local DNS leak when fetching feeds through a proxy - #9451

Merged
Alkarex merged 5 commits into
FreshRSS:edgefrom
tomac4t:fix-9423-1
Oct 17, 2026
Merged

Alkarex merged 5 commits into
FreshRSS:edgefrom
tomac4t:fix-9423-1

Conversation

@tomac4t

@tomac4t tomac4t commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #9390: getRetryAfterFile() passed the full URL to Minz_Request::serverIsPublic(), which then resolved the target hostname with the local resolver (dns_get_record()), even when a proxy was configured. With a socks5h/socks4a proxy this leaks the target hostname to the local DNS and defeats remote name resolution.

  • Minz_Request::serverIsPublic(): add an $allowDnsResolve parameter, and forward it to the recursive call so the guard holds for the whole recursion.
  • FreshRSS_http_Util::getRetryAfterFile(): do not resolve the host name when a proxy is configured ($proxy === ''), since the proxy is responsible for DNS.

Also, SimplePie\File: for socks4a / socks5h, skip get_curl_resolve_info() and CURLOPT_RESOLVE, as those proxy types already resolve the host name at the proxy side. Pre-resolving locally would degrade socks5h to socks5, and leak the target hostname. Other proxy types keep the #8950 SSRF / DNS-rebinding protection.

Closes #9423

Pull request checklist:

  • clear commit messages
  • code manually tested
  • unit tests written (optional if too hard)
  • documentation updated

Additional information can be found in the documentation.

Follow-up to FreshRSS#9390: `getRetryAfterFile()` passed the full URL to
`Minz_Request::serverIsPublic()`, which then resolved the target hostname
with the local resolver (`dns_get_record()`), even when a proxy was
configured. With a socks5h/socks4a proxy this leaks the target hostname
to the local DNS and defeats remote name resolution.

- `Minz_Request::serverIsPublic()`: add an `$allowDnsResolve` parameter,
  and forward it to the recursive call so the guard holds for the whole
  recursion.
- `FreshRSS_http_Util::getRetryAfterFile()`: do not resolve the host name
  when a proxy is configured (`$proxy === ''`), since the proxy is
  responsible for DNS.

Also, `SimplePie\File`: for socks4a / socks5h, skip
`get_curl_resolve_info()` and `CURLOPT_RESOLVE`, as those proxy types
already resolve the host name at the proxy side. Pre-resolving locally
would degrade socks5h to socks5, and leak the target hostname. Other proxy
types keep the FreshRSS#8950 SSRF / DNS-rebinding protection.
@Alkarex

Alkarex commented Oct 16, 2026

Copy link
Copy Markdown
Member

Thanks! Could you please send the SimplePie part as a PR to https://github.com/FreshRSS/simplepie ?

Comment thread lib/simplepie/simplepie/src/File.php Resolved
@Alkarex

Alkarex commented Oct 17, 2026

Copy link
Copy Markdown
Member

Same fix applied to httpGet(). Double-check welcome

@Alkarex

Alkarex commented Oct 17, 2026

Copy link
Copy Markdown
Member

FreshRSS/simplepie#93

Alkarex added a commit to FreshRSS/simplepie that referenced this pull request Oct 17, 2026
@Alkarex

Alkarex commented Oct 17, 2026

Copy link
Copy Markdown
Member

Any comment from @Inverle , @Frenzie ? I would like to merge fast to avoid delaying 1.30.2 too much

@Frenzie

Frenzie commented Oct 17, 2026

Copy link
Copy Markdown
Member

Losing the allowlist check sounds worse to me than the issue.

Comment thread lib/Minz/Request.php Resolved
Comment thread lib/simplepie/simplepie/src/File.php Outdated
Comment on lines +163 to +168
if ($proxy_type === CURLPROXY_SOCKS4A || $proxy_type === CURLPROXY_SOCKS5_HOSTNAME) {
$resolve = [];
} else {
$resolve = $this->get_curl_resolve_info($proxy_url);
if ($resolve === null) {
$this->error = 'Failed to fetch this URL, because the proxy’s IP is not in the allowlist [' .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the allowlist check for socks4a/socks5h proxies (which introduces SSRF again).

Changes should be limited only to the serverIsPublic() function.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edits welcome, if you can

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done f76b42f

@Alkarex
Alkarex merged commit 859a2ad into FreshRSS:edge Oct 17, 2026
3 checks passed
@Alkarex

Alkarex commented Oct 17, 2026

Copy link
Copy Markdown
Member

@tomac4t Please check if it is sufficient for your use-case

@tomac4t

tomac4t commented Oct 17, 2026 via email

Copy link
Copy Markdown
Contributor Author

@tomac4t

tomac4t commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@Alkarex I’m glad to see this merged; it allows me to use a WireGuard/Socks5 proxy without worrying about information leaking to my ISP. Since I run FreshRSS on a Raspberry Pi at home, this perfectly addresses my use case.

$domainWide = self::$retry_after_domain_wide[$domain] ??= Minz_Request::serverIsPublic($url, allowDnsResolve: $proxy === '');

This check might be a bit too simplistic—strictly speaking, it should only apply to SOCKS4A and SOCKS5H—but since it’s not straightforward for me to modify, I’ve opted for the simplest implementation.

@Inverle

Inverle commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

it allows me to use a WireGuard/Socks5 proxy without worrying about information leaking to my ISP

Not completely, because #8976 is still unsolved for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Retry-After: serverIsPublic() resolves target hostname locally, leaking DNS when using a proxy

4 participants