From 04f4fd46dab9677f8861b8483809d6e4d29c64dc Mon Sep 17 00:00:00 2001 From: S31ZUR3 <191032395+S31ZUR3@users.noreply.github.com> Date: Sun, 8 Nov 2026 15:39:28 +0530 Subject: [PATCH] Remove redundant CURLOPT_PROXY scheme-strip in File::curlInit() CURLOPT_PROXYTYPE is what tells cURL the proxy's scheme; CURLOPT_PROXY itself was never supposed to carry one. The greedy preg_replace('#^.*://#i', '', $proxy) used to strip a scheme before building $proxy_url for the allowlist/DNS-pinning check -- but if the value contained a second "://", the greedy strip reduced it to the text after the LAST occurrence (an attacker-chosen "decoy" host) for that check, while the original, unstripped value was still what ultimately reached cURL via $curl_options[CURLOPT_PROXY], letting the checked host and the contacted host differ. Companion fix: the FreshRSS caller (FreshRSS_http_Util::sanitizeCurlParams()) now validates CURLOPT_PROXY and rejects any value containing a scheme outright, so this file no longer needs to strip one -- see https://github.com/FreshRSS/FreshRSS/pull/9537 --- src/File.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/File.php b/src/File.php index 4796296b6..d84f79a53 100644 --- a/src/File.php +++ b/src/File.php @@ -158,8 +158,10 @@ public function __construct(string $url, int $timeout = 10, int $redirects = 5, $this->success = false; return; } - $proxy = preg_replace('#^.*://#i', '', $proxy); // Strip any scheme already present in CURLOPT_PROXY - $proxy_url = "$proxy_scheme://$proxy"; // CURLOPT_PROXY ($proxy) is formatted as user:pass@hostname:port, with the part before @ being optional + // CURLOPT_PROXY ($proxy) is expected to already be scheme-less: the scheme comes from + // CURLOPT_PROXYTYPE, and the caller (e.g. FreshRSS_http_Util::sanitizeCurlParams()) rejects + // any scheme-containing value before it's ever stored or used. + $proxy_url = "$proxy_scheme://$proxy"; // formatted as user:pass@hostname:port, with the part before @ being optional $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 [' .