Skip to content

Commit 0793a9d

Browse files
authored
Merge pull request #107 from Saeven/feature/strpos-defense
Patches an in-the-wild attack vector that doesn't yield a vulnerabili…
2 parents 87255d8 + f7f7145 commit 0793a9d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Service/AuthenticationService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use function hash_equals;
4444
use function hash_hmac;
4545
use function is_numeric;
46+
use function is_scalar;
4647
use function password_hash;
4748
use function password_needs_rehash;
4849
use function password_verify;
@@ -498,14 +499,15 @@ private function purgeHashCookies(?string $skipCookie = null)
498499
$sp = session_get_cookie_params();
499500
$killTime = time() - 3600;
500501
foreach ($_COOKIE as $cookieName => $value) {
501-
if ($cookieName !== $skipCookie && strpos($cookieName, self::COOKIE_HASH_PREFIX) !== false) {
502+
if ($cookieName !== $skipCookie && is_scalar($cookieName) && strpos((string) $cookieName, self::COOKIE_HASH_PREFIX) !== false) {
502503
setcookie($cookieName, '', $killTime, '/', $sp['domain'], false, true);
503504
}
504505
}
505506
}
506507

507508
/**
508509
* @param User $user Used by some password checkers to provide better checking
510+
*
509511
* @throws WeakPasswordException
510512
*/
511513
private function enforcePasswordStrength(string $password, User $user)
@@ -521,6 +523,7 @@ private function enforcePasswordStrength(string $password, User $user)
521523
*
522524
* @param User $user The user to whom this password gets assigned
523525
* @param string $newPassword Cleartext password that's being hashed
526+
*
524527
* @throws NoSuchUserException
525528
* @throws WeakPasswordException
526529
*/
@@ -544,6 +547,7 @@ public function resetPassword(User $user, string $newPassword)
544547
*
545548
* @param User $user The user to validate password for
546549
* @param string $password Cleartext password that'w will be verified
550+
*
547551
* @throws PersistedUserRequiredException
548552
* @throws UserWithoutAuthenticationRecordException
549553
*/

0 commit comments

Comments
 (0)