Skip to content

Commit 5100c7e

Browse files
authored
Merge pull request #44483 from nextcloud/fix/setup-check-validate-trusted-proxies
fix(settings): Also verify that `trusted_proxies` only contains IP addresses (with range)
2 parents f8d1487 + 14addf3 commit 5100c7e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

apps/settings/lib/SetupChecks/ForwardedForHeaders.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ public function run(): SetupResult {
5959
return SetupResult::error($this->l10n->t('Your "trusted_proxies" setting is not correctly set, it should be an array.'));
6060
}
6161

62+
foreach ($trustedProxies as $proxy) {
63+
$addressParts = explode('/', $proxy, 2);
64+
if (filter_var($addressParts[0], FILTER_VALIDATE_IP) === false || !ctype_digit($addressParts[1] ?? '24')) {
65+
return SetupResult::error(
66+
$this->l10n->t('Your "trusted_proxies" setting is not correctly set, it should be an array of IP addresses - optionally with range in CIDR notation.'),
67+
$this->urlGenerator->linkToDocs('admin-reverse-proxy'),
68+
);
69+
}
70+
}
71+
6272
if (($remoteAddress === '') && ($detectedRemoteAddress === '')) {
6373
if (\OC::$CLI) {
6474
/* We were called from CLI */

0 commit comments

Comments
 (0)