Skip to content

Commit 6bdee05

Browse files
authored
Merge pull request #43192 from nextcloud/backport/42794/stable28
[stable28] fix(Request): Catch exceptions in `isTrustedProxy`
2 parents d501f2d + cfc12b8 commit 6bdee05

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/private/AppFramework/Http/Request.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,14 @@ public function getId(): string {
573573
* @return boolean true if $remoteAddress matches any entry in $trustedProxies, false otherwise
574574
*/
575575
protected function isTrustedProxy($trustedProxies, $remoteAddress) {
576-
return IpUtils::checkIp($remoteAddress, $trustedProxies);
576+
try {
577+
return IpUtils::checkIp($remoteAddress, $trustedProxies);
578+
} catch (\Throwable) {
579+
// 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
580+
// Reaching this line means `trustedProxies` is in invalid format.
581+
error_log('Nextcloud trustedProxies has malformed entries');
582+
return false;
583+
}
577584
}
578585

579586
/**

0 commit comments

Comments
 (0)