Skip to content

Commit

Permalink
Merge pull request #44483 from nextcloud/fix/setup-check-validate-tru…
Browse files Browse the repository at this point in the history
…sted-proxies

fix(settings): Also verify that `trusted_proxies` only contains IP addresses (with range)
  • Loading branch information
susnux authored Mar 26, 2024
2 parents f8d1487 + 14addf3 commit 5100c7e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/settings/lib/SetupChecks/ForwardedForHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ public function run(): SetupResult {
return SetupResult::error($this->l10n->t('Your "trusted_proxies" setting is not correctly set, it should be an array.'));
}

foreach ($trustedProxies as $proxy) {
$addressParts = explode('/', $proxy, 2);
if (filter_var($addressParts[0], FILTER_VALIDATE_IP) === false || !ctype_digit($addressParts[1] ?? '24')) {
return SetupResult::error(
$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.'),
$this->urlGenerator->linkToDocs('admin-reverse-proxy'),
);
}
}

if (($remoteAddress === '') && ($detectedRemoteAddress === '')) {
if (\OC::$CLI) {
/* We were called from CLI */
Expand Down

0 comments on commit 5100c7e

Please sign in to comment.