Skip to content

Commit 294e539

Browse files
authored
Merge pull request #58975 from nextcloud/enh/42157/hid-warning
fix(initializeSession): only log HMAC problem to critical logs if indeed critical
2 parents b960838 + d3faa42 commit 294e539

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/private/Security/Crypto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private function decryptWithoutSecret(string $authenticatedCiphertext, string $p
159159
}
160160
} else {
161161
if (!hash_equals($this->calculateHMAC($parts[0] . $parts[1], $hmacKey), $hmac)) {
162-
throw new Exception('HMAC does not match.');
162+
throw new \RuntimeException('HMAC does not match.');
163163
}
164164
}
165165

lib/private/Session/CryptoSessionData.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ protected function initializeSession() {
5858
512,
5959
JSON_THROW_ON_ERROR,
6060
);
61+
} catch (\RuntimeException $e) {
62+
// Even though this might be critical in general, we are automatically trying again and will likely succeed.
63+
// We only log to info to not spam the logs with a well-known problem the admin cannot do anything about.
64+
// See https://github.com/nextcloud/server/issues/42157
65+
logger('core')->info('Could not decrypt or decode encrypted session data', [
66+
'exception' => $e,
67+
]);
68+
$this->sessionValues = [];
69+
$this->regenerateId(true, false);
6170
} catch (\Exception $e) {
6271
logger('core')->critical('Could not decrypt or decode encrypted session data', [
6372
'exception' => $e,

0 commit comments

Comments
 (0)