Skip to content

Commit

Permalink
Limited decrypt to 256 characters in Mage_Core_Model_Encryption (#2685)
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab authored and fballiano committed Jan 13, 2023
1 parent 7acf971 commit 248abc5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/code/core/Mage/Core/Model/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ class Mage_Core_Model_Encryption
*/
public const HASH_VERSION_LATEST = 3;

/**
* Maximum Password Length
*/
public const MAXIMUM_PASSWORD_LENGTH = 256;

/**
* @var Varien_Crypt_Mcrypt
*/
protected $_crypt;

/**
* @var Mage_Core_Helper_Data
*/
Expand Down Expand Up @@ -126,6 +132,10 @@ public function hash($data, $version = self::HASH_VERSION_MD5)
*/
public function validateHash($password, $hash)
{
if (strlen($password) > self::MAXIMUM_PASSWORD_LENGTH) {
return false;
}

return $this->validateHashByVersion($password, $hash, self::HASH_VERSION_LATEST)
|| $this->validateHashByVersion($password, $hash, self::HASH_VERSION_SHA512)
|| $this->validateHashByVersion($password, $hash, self::HASH_VERSION_SHA256)
Expand Down

0 comments on commit 248abc5

Please sign in to comment.