The vulnerability, CVE-2025-22234, is a timing attack in Spring Security's DaoAuthenticationProvider. It was inadvertently introduced by the fix for a previous CVE. The root cause lies in the BCrypt.hashpw method, which is used by BCryptPasswordEncoder. In the vulnerable state, this method enforced a maximum password length of 72 bytes for both encoding new passwords and, crucially, for verifying existing passwords.
When an attacker attempted to authenticate with a password longer than 72 bytes, the hashpw method would immediately throw an IllegalArgumentException. This is significantly faster than performing the computationally expensive BCrypt hashing algorithm. This timing discrepancy created a side-channel: a quick response indicated an invalid username or a long password attempt, while a slow response indicated that a valid username was found and a full hash comparison was being performed.
The patch, identified in commit c1aa99fdd2113a232986e9c3a44673ae752de840, rectifies this by making the length check conditional. The check is now skipped during password verification (for_check is true), ensuring that the execution time is consistent regardless of the provided password's length, thus closing the timing leak. The vulnerable functions identified are the private method BCrypt.hashpw where the flaw resided, the public BCryptPasswordEncoder.matches method that exposes it, and the AbstractUserDetailsAuthenticationProvider.additionalAuthenticationChecks method which uses the password encoder as part of the authentication flow.