-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Hash::check not applying options before verifying Algorithm #55759
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
Comments
@GeNyaa If you set it to
As you can see above, first check is passed, second check is the
If this the result is not But I found out that if you pass option when using
I think it should be like this public function check(#[\SensitiveParameter] $value, $hashedValue, array $options = [])
{
if (is_null($hashedValue) || strlen($hashedValue) === 0) {
return false;
}
if (! empty($options)) {
$this->verifyAlgorithm = $options['verify'] ?? $this->verifyAlgorithm;
}
if ($this->verifyAlgorithm && ! $this->isUsingCorrectAlgorithm($hashedValue)) {
throw new RuntimeException('This password does not use the Bcrypt algorithm.');
}
return parent::check($value, $hashedValue, $options);
} |
The hash above is a different bcrypt version 2a instead of 2y, the hash itself should be the same though. |
Is the step to reproduce used in any of Laravel documentation? If not, feel free to submit a PR to suggest the new usage. |
I used verify false as an option to ignore the amount of rounds when checking the password. So it would allow me to check 8, 10 and 12 rounds without turning verify off inside the config/env vars. This doesn't seem documented in the documentation, but is working as expected. However when using 2a version hashes it errors out, which is why I thought this was a bug as it's suppose to just check the hash without verifying version or rounds. I'll create a pr to address this later, when I have more time on my hands. |
Uh oh!
There was an error while loading. Please reload this page.
Laravel Version
12.x, 11.x
PHP Version
8.2, 8.1
Database Driver & Version
No response
Description
When using;
it'll still verify the algorithm before running the rest of the function and will throw a bcrypt error, if the incorrect value is used.
Steps To Reproduce
make sure bcrypt verify is set to true in config.
results in an error thrown instead of a true or false.
The text was updated successfully, but these errors were encountered: