Bruteforce protection in password verification can be bypassed
Nextcloud's brute-force throttling keys on the client IP taken from the X-Forwarded-For header when a trusted proxy is configured. An attacker can send a different valid IP in that header on each login attempt, so the delay is never applied and passwords can be guessed without throttling.
- Disclosed after 3 months
Summary by the program
Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-5j2p-q736-hw98
The report
Summary:
nextcloud server have implemented IP address-based blocking as a measure to counter Bruteforce protection. The source IP address is obtained through the getRemoteAddress() function.
lib/public/IRequest.php
public function getRemoteAddress(): string {
$remoteAddress = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : '';
$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
if (\is_array($trustedProxies) && $this->isTrustedProxy($trustedProxies, $remoteAddress)) {
$forwardedForHeaders = $this->config->getSystemValue('forwarded_for_headers', [
'HTTP_X_FORWARDED_FOR'
// only have one default, so we cannot ship an insecure product out of the box
]);
foreach ($forwardedForHeaders as $header) {
if (isset($this->server[$header])) {
foreach (explode(',', $this->server[$header]) as $IP) {
$IP = trim($IP);
// remove brackets from IPv6 addresses
if (str_starts_with($IP, '[') && str_ends_with($IP, ']')) {
$IP = substr($IP, 1, -1);
}
if (filter_var($IP, FILTER_VALIDATE_IP) !== false) {
return $IP;
}
}
}
}
}
It is determined that the IP address is retrieved based on the value of the X-Forwarded-For header when trusted_proxy is configured.
By adding the X-Forwarded-For header with valid ip format it is possible to bypass Bruteforce protection.
Step to reproduce
- Setting up a nextcloud server using trusted_proxy.
- Attempts to log in multiple times with incorrect passwords. Confirm that the
Throttler\sleepDelayfunction causes a delay in response time. - Add
X-Forwarded-Forheader with valid ip format, the the delay is eliminated and Bruteforce protection is bypassed.
Impact
an attacker can bypass bruteforce protection and bruteforce the login.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server trusts the client-supplied X-Forwarded-For value for throttling decisions whenever a trusted proxy is configured, without ensuring the value comes from the proxy rather than the client.
Impact
An attacker could bypass brute-force protection and guess login passwords without the intended delay, though this only applies when a trusted proxy is configured.
What the attacker needed
Trusted_proxy configured; attacker can send custom headers
How it was found
- Set up a Nextcloud server that uses a trusted proxy.
- Try logging in several times with wrong passwords and confirm the throttler adds a delay.
- Send the same requests with a valid IP in the X-Forwarded-For header and observe the delay is gone.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you log in with the wrong password too many times, the server makes you wait longer each time to slow down guessing. The server decides who to slow down by looking at an address the client can supply itself when a proxy is in front. By changing that address on every try, the attacker looks like a new person each time and the waiting never happens.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.