Merge pull request #32990 from nextcloud/backport/32988/stable24

[stable24] Improve local domain detection
This commit is contained in:
blizzz 2022-06-24 11:29:13 +02:00 committed by GitHub
commit ce9dfc20d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,8 +66,10 @@ class LocalAddressChecker {
$host = substr($host, 1, -1);
}
// Disallow localhost and local network
if ($host === 'localhost' || substr($host, -6) === '.local' || substr($host, -10) === '.localhost') {
// Disallow local network top-level domains from RFC 6762
$localTopLevelDomains = ['local','localhost','intranet','internal','private','corp','home','lan'];
$topLevelDomain = substr((strrchr($host, '.') ?: ''), 1);
if (in_array($topLevelDomain, $localTopLevelDomains)) {
$this->logger->warning("Host $host was not connected to because it violates local access rules");
throw new LocalServerException('Host violates local access rules');
}