Skip to content

Regression with Bcrypt max password length #16802

Closed
@strehle

Description

@strehle

Describe the bug
There was a fix in bcrypt, e.g.
46f0dc6

To Reproduce
Create secret > 72.
Upgrade to newer spring security and validate the secret / credential

Expected behavior
Expect that existing scenarios work, but new created secrets can be rejected

Current behavior
Now we see http 500.

There are good descriptions about the issue and very often about solutions, like
https://security.stackexchange.com/questions/39849/does-bcrypt-have-a-maximum-password-length/184090#184090

You can use the salt in Bcrypt to generate a HMAC_256 from input > 72 and then use same salt for bcrypt call.

But now we have a regression and the problem, that because of the CVE we should upgrade but if we upgrade we break integrations.

Sample

Callstack from UAA
java.lang.IllegalArgumentException: password cannot be more than 72 bytes
at org.springframework.security.crypto.bcrypt.BCrypt.hashpw(BCrypt.java:615) ~[spring-security-crypto-5.7.16.jar:5.7.16]
at org.springframework.security.crypto.bcrypt.BCrypt.hashpwforcheck(BCrypt.java:579) ~[spring-security-crypto-5.7.16.jar:5.7.16]
at org.springframework.security.crypto.bcrypt.BCrypt.checkpw(BCrypt.java:767) ~[spring-security-crypto-5.7.16.jar:5.7.16]
at org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder.matches(BCryptPasswordEncoder.java:133) ~[spring-security-crypto-5.7.16.jar:5.7.16]
at org.cloudfoundry.identity.uaa.util.CachingPasswordEncoder.internalMatches(CachingPasswordEncoder.java:86) ~[cloudfoundry-identity-server-xxxx.jar:?]

Metadata

Metadata

Assignees

Labels

in: cryptoAn issue in spring-security-cryptotype: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions