[Security] Refuse KDF downgrade; trim profile name and warn on silent credential drop

This commit is contained in:
Lukas Brübach 2026-09-02 20:12:45 +02:00 committed by BruebachL
parent 4252f69d2b
commit e20846a88d
3 changed files with 20 additions and 1 deletions

View file

@ -311,6 +311,17 @@ void RemoteClient::passwordSaltResponse(const Response &response)
doLogin();
} else if (serverSupportsChallengeResponse && resp.has_nonce()) {
const QByteArray nonce = QByteArray::fromStdString(resp.nonce());
// needs_migration is a server-controlled flag over an unauthenticated
// transport (plain TCP by default). If we already hold a scrypt
// verifier for this account, a server telling us to fall back to the
// 1000-round legacy hash is a downgrade of the KDF — refuse it rather
// than hand an attacker a weakly-keyed HMAC they can attack offline.
if (resp.needs_migration() && PasswordHasher::parsePasswordVerifier(storedVerifier).isValid) {
emit loginError(Response::RespClientUpdateRequired,
QStringLiteral("Server asked to downgrade authentication for a migrated account."), 0,
{});
return;
}
QByteArray key;
if (resp.needs_migration()) {
// The account still uses the legacy format; the legacy full hash