Skip to content

Commit

Permalink
Fix potential timing side channel in digest auth.
Browse files Browse the repository at this point in the history
This change reduces the potential ability to use digest authentication
as a side channel for user enumeration. Previously passwords would be
hashed for digest users that did not exist, but not hashed for users
that *did*. These changes ensure that if password===null no hashing is
done. This also means we can remove the string cast.

Thanks to Edgaras Janušauskas for raising this issue through our
responsible disclosure mailing list.
  • Loading branch information
markstory committed Aug 14, 2018
1 parent 2ec48ea commit 6e9b334
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Auth/BaseAuthenticate.php
Expand Up @@ -117,8 +117,15 @@ protected function _findUser($username, $password = null)
$result = $this->_query($username)->first();

if (empty($result)) {
$hasher = $this->passwordHasher();
$hasher->hash((string)$password);
// Waste time hashing the password, to prevent
// timing side-channels. However, don't hash
// null passwords as authentication systems
// like digest auth don't use passwords
// and hashing *could* create a timing side-channel.
if (strlen($password) > 0) {
$hasher = $this->passwordHasher();
$hasher->hash($password);
}

return false;
}
Expand Down

0 comments on commit 6e9b334

Please sign in to comment.