[BUG][5.12.1] security->checkHash aways return false
Describe the bug When move to the last version of Phalcon, i notice admins cant login in cms panel. After check i can confirm that security->checkHash is not working like before and never (at least for me) return true on Phalcon 5.12.1
To Reproduce Just save a password in db. After request try to use checkHash and... did not work.
Steps to reproduce the behavior:
$pass = '123456789';
$hash = $this->security->hash($pass);
var_dump($hash);exit; // Now save that string in db, or just in variable for test.
// After refresh - remove code before this and try:
$this->security->checkHash($this->request->getPost('password', 'string', ''), $hash)
Details
- Phalcon version: 5.12.1
- PHP Version: 8.4
- Operating System: Win
- Server: Apache
I checked the code and I do not see any recent changes to the checkHash. This could come from the POST or the session. The algorithm has been like this for a while now. If possible can you test with this script?
<?php
declare(strict_types=1);
$password = '123456789';
$cost = 10;
$algorithm = PASSWORD_BCRYPT;
$arguments = ['cost' => $cost];
$hash = password_hash($password, $algorithm, $arguments);
var_dump($hash);
// checkHash()
$maxPassLength = 0;
if ($maxPassLength > 0 && strlen($password) > $maxPassLength) {
$result = false;
} else {
$result = password_verify($password, $hash);
}
var_dump($result); // true
Let me know what you find.
The test for checkHash if of interest
https://github.com/phalcon/cphalcon/blob/master/tests/unit/Encryption/Security/CheckHashTest.php#L47
string(60) "$2y$10$V04U1l2jUklDDA/KJTvtu.HcJeCveKHZNyn5cfKRuu0LGwdP3Q2CW" bool(true)
PS: yes, coming from POST.
Will investigate to understand why this is happened for me. I was trying with any of my phalcon projects and same issue. But from previous versions is working. Anyway, its seems to be somehow my mistake, or something i did not know. Will figure out.
Thank you and... will close this task as soon i test and understand my problem.
<3 :)
I find it- its coming again from magic setters and getters i mentions before in other communication with u. Soo, it is fixed in 5.12.2 like u said :)
Thank u!
https://github.com/phalcon/cphalcon/issues/16956#event-25055803383