From 6945a8e19e5908eb4e41bbe858e26098b2f856d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 3 Dec 2026 12:06:27 +0100 Subject: [PATCH] fix: Do not bruteforce protect applications with bearer tokens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some applications manage their own bearer token so we cannot consider missing token as bruteforce. Signed-off-by: Côme Chilliet --- lib/private/User/Session.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 09354fa67cad6..d7cc03267eb9c 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -894,11 +894,8 @@ public function tryTokenLogin(IRequest $request, bool $allowOcmAccessToken = fal $throttler = $this->getThrottler(); $authHeader = $request->getHeader('Authorization'); $tokenFromCookie = false; - $remoteAddress = $request->getRemoteAddress(); - $currentDelay = 0; if (str_starts_with($authHeader, 'Bearer ')) { $token = substr($authHeader, 7); - $currentDelay = $throttler->sleepDelayOrThrowOnMax($remoteAddress, 'login'); } elseif ($request->getCookie($this->config->getSystemValueString('instanceid')) !== null) { // No auth header, let's try session id, but only if this is an existing // session and the request has a session cookie @@ -915,12 +912,12 @@ public function tryTokenLogin(IRequest $request, bool $allowOcmAccessToken = fal try { $dbToken = $this->tokenProvider->getToken($token); } catch (InvalidTokenException $e) { - if (!$tokenFromCookie) { - $this->handleLoginFailed($throttler, $currentDelay, $remoteAddress, '', $token); - } return false; } + $remoteAddress = $request->getRemoteAddress(); + $currentDelay = $throttler->sleepDelayOrThrowOnMax($remoteAddress, 'login'); + if ($dbToken instanceof PublicKeyToken && $dbToken->getType() === IToken::TEMPORARY_TOKEN && !$tokenFromCookie