Skip to content

Commit

Permalink
Merge pull request #43193 from nextcloud/backport/42794/stable27
Browse files Browse the repository at this point in the history
[stable27] fix(Request): Catch exceptions in `isTrustedProxy`
  • Loading branch information
nickvergessen committed Jan 30, 2024
2 parents 4b35c5b + 36a658e commit 5147fcb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/private/AppFramework/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,14 @@ public function getId(): string {
* @return boolean true if $remoteAddress matches any entry in $trustedProxies, false otherwise
*/
protected function isTrustedProxy($trustedProxies, $remoteAddress) {
return IpUtils::checkIp($remoteAddress, $trustedProxies);
try {
return IpUtils::checkIp($remoteAddress, $trustedProxies);
} catch (\Throwable) {
// We can not log to our log here as the logger is using `getRemoteAddress` which uses the function, so we would have a cyclic dependency
// Reaching this line means `trustedProxies` is in invalid format.
error_log('Nextcloud trustedProxies has malformed entries');
return false;
}
}

/**
Expand Down

0 comments on commit 5147fcb

Please sign in to comment.