Fix non-constant-time credential comparisons

- account.php: replace !== CSRF token check with hash_equals
- ShareLink::setPassword(): also encrypt and store plain-text password
  alongside the hash, matching create() behavior so the decrypted_password
  decoration stays correct after password updates
This commit is contained in:
Pontoporeia
2026-05-31 17:49:39 +02:00
parent 6246174fc5
commit f398a0f1ff
3 changed files with 8 additions and 286 deletions

View File

@@ -211,9 +211,10 @@ class ShareLink
public function setPassword(int $id, ?string $password): void
{
$hash = $password !== null ? password_hash($password, PASSWORD_BCRYPT) : null;
$enc = $password !== null ? Crypto::encrypt($password) : null;
$this->db->getConnection()->prepare(
'UPDATE share_links SET password_hash = ? WHERE id = ?'
)->execute([$hash, $id]);
'UPDATE share_links SET password_hash = ?, encrypted_password = ? WHERE id = ?'
)->execute([$hash, $enc, $id]);
}
/**