Skip to content

Commit bbb88cc

Browse files
Use constant-time comparison for password reset tokens (#4698)
2 parents 345a182 + 8131020 commit bbb88cc

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/Model/Administrator/Administrator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ public function getResetPasswordHash()
676676
#[Override]
677677
public function isResetPasswordHashValid(?string $hash): bool
678678
{
679-
if ($hash === null || $this->resetPasswordHash !== $hash) {
679+
if ($hash === null || $this->resetPasswordHash === null || !hash_equals($this->resetPasswordHash, $hash)) {
680680
return false;
681681
}
682682

src/Model/Customer/User/CustomerUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public function setResetPasswordHash($resetPasswordHash): void
456456
#[Override]
457457
public function isResetPasswordHashValid(?string $hash): bool
458458
{
459-
if ($hash === null || $this->resetPasswordHash !== $hash) {
459+
if ($hash === null || $this->resetPasswordHash === null || !hash_equals($this->resetPasswordHash, $hash)) {
460460
return false;
461461
}
462462

0 commit comments

Comments
 (0)