-
Notifications
You must be signed in to change notification settings - Fork 27
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
Bad Shift in Bcrypt cryptRaw #114
Comments
actually the maximum allowed is 30 and not 31.
|
@firaja that BadParametersException check is greater than 31, not greater or equals. |
@david-hawley sorry I completely misunderstood your point. I think that converting |
Converting to long would fix it. I have a draft PR for that. Given the possible issues below I wonder if changing the limit to 30 would be better. One of the tests in If anyone were currently using 31 rounds this fix is going to cause issues.
I am not sure how/if the PR should have any unit tests for this 31 case. |
In this case a unit test is not doable and just checking the parameters encoded in the hash wouldn't add any additional level of correctness that the other tests are already giving. Even if there may be cases of projects using 31, their hashes would be not correct. A migration approach would be to use version 1.7.0 and update the hash to 30 log rounds. After that install 1.7.1 and migrate back to 31 log rounds. But I think that using 31 log rounds is not usable for any system. |
Agreed that no one would legit be using 31 or even 30 rounds. The hypothetical situation would be they tried the max allowed and found it to be fast enough (because it was actually 0) and just went with that. Ignoring any conversion hints/help I think my PR fixes the main issue. I updated one unit test as well. |
#114 Fix negative `rounds` in cryptRaw when logRounds is 31
Should this be closed? |
@codylerum The fix was merged. I don't know the close policy for this project. It hasn't been released yet. I hope no one is unintentionally using 31 rounds. Mitigation is going to be tricky without something to assist. |
Hello @codylerum @david-hawley, this fix is now present in 1.7.1 |
password4j/src/main/java/com/password4j/BcryptFunction.java
Line 768 in bf3a601
When
logRounds
is 31 (the max allowed value), this shift results in a negative number. Effectively the rounds is set to 0.The text was updated successfully, but these errors were encountered: