Skip to content

Commit

Permalink
Merge pull request #32990 from nextcloud/backport/32988/stable24
Browse files Browse the repository at this point in the history
[stable24] Improve local domain detection
  • Loading branch information
blizzz authored Jun 24, 2022
2 parents 39b8ea2 + fc1258c commit ce9dfc2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/private/Http/Client/LocalAddressChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public function ThrowIfLocalAddress(string $uri) : void {
$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');
}
Expand Down

0 comments on commit ce9dfc2

Please sign in to comment.