logger = $logger; $this->label = "🧪 curl version check"; $this->lazyCache = $lazyCache; } /** * @return DiagnosticResult[] */ public function execute() { if (!extension_loaded('curl')) { return [DiagnosticResult::singleResult( $this->label, DiagnosticResult::STATUS_INFORMATIONAL, "Your PHP setup doesn't use curl, so there is nothing to check" )]; } $version = curl_version()["version"]; $url = "https://curl.se/docs/vuln.pm"; $timeout = self::SOCKET_TIMEOUT; try { $response = $this->lazyCache->fetch(self::CACHEID); if (!$response) { $response = Http::sendHttpRequest($url, $timeout); $this->lazyCache->save(self::CACHEID, $response, 60 * 60 * 24 * 7); } $vulns = []; foreach (explode("\n", $response) as $line) { $line = trim($line); if (strpos($line, "#") === 0 || strpos($line, "@") === 0 || strpos($line, ")") === 0) { continue; } $line = str_replace('"', "", $line); $cols = explode("|", $line); $startVersion = $cols[1]; $endVersion = $cols[2]; $URL = htmlspecialchars($cols[0], ENT_QUOTES, 'UTF-8'); $CVE = htmlspecialchars($cols[4], ENT_QUOTES, 'UTF-8'); if ( version_compare($version, $startVersion, ">=") && version_compare($version, $endVersion, "<=") ) { $vulns[] = "$CVE"; } } if (count($vulns) > 0) { return [DiagnosticResult::singleResult( $this->label, DiagnosticResult::STATUS_ERROR, "Your curl version might be vulnerable against this vulnerabilities (unless the distributor of your curl binary is backporting security patches): " . join(", ", $vulns) )]; } else { return [DiagnosticResult::singleResult( $this->label, DiagnosticResult::STATUS_OK, "It seems like there are no known vulnerabilities in your curl version" )]; } } catch (\Exception $e) { return [DiagnosticResult::singleResult( $this->label, DiagnosticResult::STATUS_INFORMATIONAL, "Matomo could not check if your curl version has vulnerabilities" )]; } } }