Skip to content

Commit 390441d

Browse files
committed
Accept older blowfish hashes.
Both `2a` and `2x` are valid types of blowfish hashes, that while being older should be accepted. Backport 00c94bd from 3.x to 2.5.x, I see this as a bug fix as it fixes incompatibilities with hashes created by hash_password(). Refs #3575
1 parent bf9b8e1 commit 390441d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Cake/Utility/Security.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,12 @@ protected static function _crypt($password, $salt = false) {
277277
$salt = vsprintf('$2a$%02d$%s', array(self::$hashCost, $salt));
278278
}
279279

280-
if ($salt === true || strpos($salt, '$2a$') !== 0 || strlen($salt) < 29) {
280+
$invalidCipher = (
281+
strpos($salt, '$2y$') !== 0 &&
282+
strpos($salt, '$2x$') !== 0 &&
283+
strpos($salt, '$2a$') !== 0
284+
);
285+
if ($salt === true || $invalidCipher || strlen($salt) < 29) {
281286
trigger_error(__d(
282287
'cake_dev',
283288
'Invalid salt: %s for %s Please visit http://www.php.net/crypt and read the appropriate section for building %s salts.',

0 commit comments

Comments
 (0)