Skip to content

A free, self-hostable news aggregator…

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

tomac4t859a2ad0396a
diff --git a/app/Utils/httpUtil.php b/app/Utils/httpUtil.php
index 72eb54013..c29d07f2c 100644
--- a/app/Utils/httpUtil.php
+++ b/app/Utils/httpUtil.php
@@ -32,7 +32,7 @@ final class FreshRSS_http_Util {
return '';
}
// Once per host, as serverIsPublic() may resolve it
- $domainWide = self::$retry_after_domain_wide[$domain] ??= Minz_Request::serverIsPublic($url);
+ $domainWide = self::$retry_after_domain_wide[$domain] ??= Minz_Request::serverIsPublic($url, allowDnsResolve: $proxy === '');
$port = parse_url($url, PHP_URL_PORT);
if (is_int($port)) {
$domain .= ':' . $port;
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index 3344078f4..71052f5f6 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -430,7 +430,7 @@ class Minz_Request {
* @param string $address the address to test, which can be an URL with a DNS or an IP.
* @return bool true if server does not appear to be on some kind of local network, false otherwise (probably public).
*/
- public static function serverIsPublic(string $address): bool {
+ public static function serverIsPublic(string $address, bool $allowDnsResolve = true): bool {
if (strlen($address) < strlen('http://a.bc')) {
return false;
}
@@ -445,12 +445,12 @@ class Minz_Request {
&& !preg_match('/^(\\[)?(::1|f[c-d][0-9a-f]{2}:|fe80:)(\\])?/i', $host); // IPv6
// If $host looks public and is not an IP address, try to resolve it
- if ($is_public && filter_var($host, FILTER_VALIDATE_IP) === false) {
+ if ($allowDnsResolve && $is_public && filter_var($host, FILTER_VALIDATE_IP) === false) {
$resolvedIp = self::resolveHostname($host);
if ($resolvedIp !== null && $resolvedIp !== $host) {
$resolvedAddress = str_contains($resolvedIp, ':') ? "http://[{$resolvedIp}]/" : "http://{$resolvedIp}/";
if ($resolvedAddress !== $address) {
- $is_public &= self::serverIsPublic($resolvedAddress);
+ $is_public &= self::serverIsPublic($resolvedAddress, $allowDnsResolve);
}
}
}
diff --git a/lib/composer.json b/lib/composer.json
index 0807b5098..f2cdfb15a 100644
--- a/lib/composer.json
+++ b/lib/composer.json
@@ -18,7 +18,7 @@
"marienfressinaud/lib_opml": "dev-main#f0e850b6394af90b898daf0e65fcc7363457b844",
"phpgt/cssxpath": "v1.6.0",
"phpmailer/phpmailer": "7.1.1",
- "simplepie/simplepie": "dev-freshrss#fcfbf7769eb9b3725a1f07b609771b0d7a12b0c7"
+ "simplepie/simplepie": "dev-freshrss#042298d6550e74225cf0eedba1913cf68976d6bb"
},
"config": {
"sort-packages": true,