Skip to content

Commit

Permalink
Merge pull request #32991 from nextcloud/backport/32988/stable23
Browse files Browse the repository at this point in the history
[stable23] Improve local domain detection
  • Loading branch information
blizzz authored Jun 24, 2022
2 parents 5e001f0 + 1f94d1b commit 2c8e1c3
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 @@ -67,8 +67,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 2c8e1c3

Please sign in to comment.