You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1854,7 +1883,15 @@ public static function sanitizeRemoteUrl($url, $throw_exception = false)
1854
1883
$hostname = gethostname();
1855
1884
$host_ip = gethostbyname($hostname);
1856
1885
1886
+
// Can also include IP masks.
1857
1887
$restricted_hosts = [
1888
+
'::1', // IPv6 loopback
1889
+
'::ffff:127.0.0.1', // IPv4-mapped IPv6
1890
+
'169.254.169.254', // AWS/GCP/Azure metadata
1891
+
'fd00::/8', // IPv6 ULA
1892
+
'10.0.0.0/8', // RFC1918
1893
+
'172.16.0.0/12', // RFC1918
1894
+
'fd00::/8', // RFC1918
1858
1895
'0.0.0.0',
1859
1896
'127.0.0.1',
1860
1897
'localhost',
@@ -1865,29 +1902,81 @@ public static function sanitizeRemoteUrl($url, $throw_exception = false)
1865
1902
$_SERVER['LOCAL_ADDR'] ?? '',
1866
1903
];
1867
1904
1868
-
if (in_array($parts['host'], $restricted_hosts) && !in_array($parts['host'], $host_white_list)) {
1869
-
if ($throw_exception) {
1870
-
thrownew \Exception(__('Domain or IP address is not allowed: :%host%. Whitelist it via APP_REMOTE_HOST_WHITE_LIST .env parameter.', ['%host%' => $parts['host']]), 1);
1871
-
} else {
1872
-
return'';
1905
+
if (!in_array($parts['host'], $host_white_list)) {
1906
+
if (in_array($parts['host'], $restricted_hosts) || self::checkIpByMask($parts['host'], $restricted_hosts)) {
1907
+
if ($throw_exception) {
1908
+
thrownew \Exception(__('Domain or IP address is not allowed: :%host%. Whitelist it via APP_REMOTE_HOST_WHITE_LIST .env parameter.', ['%host%' => $parts['host']]), 1);
if (!in_array($remote_host_ip, $host_white_list)) {
1918
+
if (in_array($remote_host_ip, $restricted_hosts) || self::checkIpByMask($remote_host_ip, $restricted_hosts)) {
1919
+
if ($throw_exception) {
1920
+
thrownew \Exception(__('Domain or IP address is not allowed: :%host%. Whitelist it via APP_REMOTE_HOST_WHITE_LIST .env parameter.', ['%host%' => $remote_host_ip]), 1);
thrownew \Exception(__('Domain or IP address is not allowed: :%host%. Whitelist it via APP_REMOTE_HOST_WHITE_LIST .env parameter.', ['%host%' => $remote_host_ip]), 1);
1950
+
thrownew \Exception('Could not check URL contents by following redirects: '.$curl_errno, 1);
0 commit comments