Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plg_authentication_cookie] Fallback to integers #20338

Merged
merged 2 commits into from
May 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions plugins/authentication/cookie/cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public function onUserAuthenticate($credentials, $options, &$response)
if (!JUserHelper::verifyPassword($cookieArray[0], $results[0]->token))
{
/*
* This is a real attack! Either the series was guessed correctly or a cookie was stolen and used twice (once by attacker and once by victim).
* This is a real attack!
* Either the series was guessed correctly or a cookie was stolen and used twice (once by attacker and once by victim).
* Delete all tokens for this user!
*/
$query = $this->db->getQuery(true)
Expand Down Expand Up @@ -294,8 +295,8 @@ public function onUserAfterLogin($options)
}

// Get the parameter values
$lifetime = $this->params->get('cookie_lifetime', '60') * 24 * 60 * 60;
$length = $this->params->get('key_length', '16');
$lifetime = $this->params->get('cookie_lifetime', 60) * 24 * 60 * 60;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value will be a string if not fallback so it would be better to convert with (int).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be an integer because the field in manifest file has integer filter applied.

$length = $this->params->get('key_length', 16);

// Generate new cookie
$token = JUserHelper::genRandomPassword($length);
Expand Down Expand Up @@ -334,9 +335,9 @@ public function onUserAfterLogin($options)
->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName));
}

$hashed_token = JUserHelper::hashPassword($token);
$hashedToken = JUserHelper::hashPassword($token);

$query->set($this->db->quoteName('token') . ' = ' . $this->db->quote($hashed_token));
$query->set($this->db->quoteName('token') . ' = ' . $this->db->quote($hashedToken));

try
{
Expand Down