
This post is for Spring developers who upgraded Spring Security and started seeing password cannot be more than 72 bytes, or who read the CVE-2025-22228 advisory and want to know what their own version actually does. The BCryptPasswordEncoder 72 bytes limit is old, but the way Spring enforces it changed three times in two months of 2025. Unfortunately, most CVE summaries describe the fix as “matches no longer returns true for long passwords”. That is not what the code does. So this post runs the same inputs through 16 releases of spring-security-crypto, from 5.8 to 7.2, and records what encode and matches return. Then it tests three ways out of the limit on 7.2.0. As a result, you get a version table you can check your pom.xml against, the raw output behind it, and a migration path with numbers.
The results in this post came from this environment:
Measured 2026-11-25
Windows 11 Pro 25H2 (build 26200), AMD Ryzen 5 8600G (6C/12T), 16 GB RAM
Oracle JDK 18.0.2.1, classes compiled with javac --release 17
spring-security-crypto 5.8.16, 6.2.8, 6.3.7, 6.3.8, 6.3.9, 6.3.10, 6.4.3, 6.4.4, 6.4.5,
6.4.6, 6.4.13, 6.5.0, 6.5.11, 7.0.9, 7.1.3, 7.2.0 (all from Maven Central)
commons-logging 1.3.5, bcprov-jdk18on 1.87 (Argon2 only)
Raw data: data/bcryptpasswordencoder-72-bytes-2026-11-25.tsv in the publisher repo
The true, false and throws results are deterministic, so one run per version is the whole result. The hashing timings at the end are the exception: those are medians of five rounds of 20 encodes each, and every round is shown.
BCryptPasswordEncoder 72 Bytes: The Short Answer
Spring Security releases fall into three groups. Find your version in the left column:
| spring-security-crypto | Spring Boot that ships it | encode with 73+ bytes | matches 73 bytes vs a 72-byte hash | matches on an old long-password hash |
|---|---|---|---|---|
| 5.8.16, 6.2.8, 6.3.7, 6.4.3 and older | 3.4.3, 3.3.9 and older | Hashes the first 72 bytes silently | true | true |
| 6.3.8, 6.4.4 | 3.3.10, 3.4.4 | Throws | Throws | Throws |
| 6.3.9+, 6.4.5+, 6.5.x, 7.0.x, 7.1.x, 7.2.0 | 3.3.11+, 3.4.5+, 3.5.x, 4.x | Throws | true | true |
In short, every current release refuses to create a hash from more than 72 bytes, and every current release still accepts a login whose first 72 bytes match. Only two releases, 6.3.8 and 6.4.4, rejected long input on both sides, and they lasted about five weeks. Note also that the limit counts UTF-8 bytes, not characters. A 72-character password with one é in it is 73 bytes, and it throws.
Why Does BCrypt Stop at 72 Bytes?
BCrypt feeds the password into the Blowfish key schedule, which takes at most 72 bytes of key material. Anything past byte 72 never reaches the hash. Consequently, two passwords that share their first 72 bytes produce the same hash for the same salt, and either one verifies against it. This is a property of the algorithm, not a Spring bug. The OWASP Password Storage Cheat Sheet calls it out for every bcrypt implementation.
For most users this never matters, because few people type 72-byte passwords. However, two groups hit it regularly. Password managers can generate long passphrases, and code that concatenates something in front of the password before hashing, such as a user ID or a username, eats into the 72 bytes before the password even starts. The second case is the dangerous one, and the real-world section below walks through a published incident caused by exactly that.
If you are choosing a password hash from scratch rather than living with bcrypt, the bcrypt vs Argon2 comparison covers that decision. This post assumes you already have bcrypt hashes in a database and need to know what your Spring version does with them.
What the Two 2025 Advisories Actually Say
Spring published two advisories about this, five weeks apart. Both are worth reading in full, because the second one undoes part of the first.
CVE-2025-22228 was published 2025-03-19 and rated High. Its description reads: “BCryptPasswordEncoder.matches(CharSequence,String) will incorrectly return true for passwords larger than 72 characters as long as the first 72 characters are the same.” It lists 6.4.4 and 6.3.8 as the open source fixes. The fixes for 6.2, 6.1, 6.0, 5.8 and 5.7 (6.2.10, 6.1.14, 6.0.16, 5.8.18, 5.7.16) are marked Enterprise Support Only.
CVE-2025-22234 followed on 2025-04-22, rated Medium: “The fix applied in CVE-2025-22228 inadvertently broke the timing attack mitigation implemented in DaoAuthenticationProvider.” Its affected versions are exactly the 22228 fixes, 6.4.4 and 6.3.8 among them, and its open source fixes are 6.4.5 and 6.3.9.
Two details in that text are easy to misread. First, the advisory says “characters”, while the code counts bytes. Second, the 22228 description suggests matches stops returning true after the fix. In fact, the current source of BCrypt.java (7.2.0) puts the check behind a flag that is only false when hashing a new password:
// spring-security-crypto 7.2.0, org/springframework/security/crypto/bcrypt/BCrypt.java
private static String hashpw(byte passwordb[], String salt, boolean for_check) {
// ...
// Enforce max length for new passwords only
if (!for_check && passwordb.length > 72) {
throw new IllegalArgumentException("password cannot be more than 72 bytes");
}
BCrypt.checkpw, which matches calls, passes for_check = true. So reading the source predicts that encode throws and matches keeps truncating. The harness below confirms it, and it also shows what 6.3.8 and 6.4.4 did differently.
The Test Harness: One Class, 16 Jars
The harness is one Java class compiled once against 7.2.0 and run with each version’s jar swapped onto the classpath. The BCryptPasswordEncoder and BCrypt APIs it calls exist unchanged in every version tested, so no recompilation is needed. Here is the full class:
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.Callable;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
// Usage: java -cp <jar>;commons-logging.jar;. Matrix <version-label> [gen <file>]
public class Matrix {
static final String A72 = "a".repeat(72);
static final String A73 = "a".repeat(73);
static final String A100 = "a".repeat(100);
static final String MB72 = "a".repeat(71) + "é"; // 72 chars, 73 UTF-8 bytes
static final String E37 = "é".repeat(37); // 37 chars, 74 UTF-8 bytes
public static void main(String[] args) throws Exception {
String label = args[0];
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
if (args.length == 3 && args[1].equals("gen")) {
// A hash of a 100-byte password, made on a version that still accepts it
Files.writeString(Path.of(args[2]), encoder.encode(A100));
return;
}
String legacyHash = Files.readString(Path.of("legacy-100.txt")).trim();
String hash72 = encoder.encode(A72);
row(label, "encode 72 ASCII bytes", () -> ok(encoder.encode(A72)));
row(label, "encode 73 ASCII bytes", () -> ok(encoder.encode(A73)));
row(label, "encode 100 ASCII bytes", () -> ok(encoder.encode(A100)));
row(label, "encode 72 chars / 73 bytes", () -> ok(encoder.encode(MB72)));
row(label, "encode 37 chars / 74 bytes", () -> ok(encoder.encode(E37)));
row(label, "BCrypt.hashpw 73 bytes", () -> ok(BCrypt.hashpw(A73, BCrypt.gensalt())));
row(label, "matches 72 vs hash(72)", () -> encoder.matches(A72, hash72));
row(label, "matches 73 vs hash(72)", () -> encoder.matches(A73, hash72));
row(label, "matches 72+'wrong' vs hash(72)", () -> encoder.matches(A72 + "wrong", hash72));
row(label, "matches 100 vs legacy hash(100)", () -> encoder.matches(A100, legacyHash));
row(label, "matches 72+28 'X' vs legacy hash(100)",
() -> encoder.matches(A72 + "X".repeat(28), legacyHash));
row(label, "byte length check", () -> MB72.getBytes(StandardCharsets.UTF_8).length);
}
static boolean ok(String hash) {
return hash.startsWith("$2");
}
static void row(String label, String test, Callable<Object> body) {
String result;
try {
result = String.valueOf(body.call());
} catch (Exception e) {
result = "THROWS " + e.getClass().getSimpleName() + ": " + e.getMessage();
}
System.out.println(label + "\t" + test + "\t" + result);
}
}
The “legacy hash” matters most. It is a bcrypt hash of a 100-byte password, created on 6.3.7, which still accepted long input. That is exactly what sits in the database of any app that let users pick long passwords before 2025. Each version then gets asked whether the same 100-byte password still logs in.
The jars come straight from Maven Central, so no Maven project is needed. The commands, run in Git Bash on Windows (use : instead of ; in the classpath on Linux or macOS):
# Fetch one jar per version
for v in 5.8.16 6.3.7 6.3.8 6.3.9 6.4.3 6.4.4 6.4.5 6.5.11 7.0.9 7.2.0; do
curl -sfO https://repo1.maven.org/maven2/org/springframework/security/spring-security-crypto/$v/spring-security-crypto-$v.jar
done
# Compile once, create the legacy hash on 6.3.7, then run every version
javac --release 17 -cp "spring-security-crypto-7.2.0.jar;commons-logging-1.3.5.jar" Matrix.java
java -cp "spring-security-crypto-6.3.7.jar;commons-logging-1.3.5.jar;." Matrix 6.3.7 gen legacy-100.txt
for v in 5.8.16 6.3.7 6.3.8 6.3.9 6.4.3 6.4.4 6.4.5 6.5.11 7.0.9 7.2.0; do
java -cp "spring-security-crypto-$v.jar;commons-logging-1.3.5.jar;." Matrix $v \
| grep -E "encode 73 ASCII|encode 72 chars|matches 73 vs|matches 100 vs"
done
Raw Output: What Each Version Returned
The filtered run above produced this output, pasted unedited:
5.8.16 encode 73 ASCII bytes true
5.8.16 encode 72 chars / 73 bytes true
5.8.16 matches 73 vs hash(72) true
5.8.16 matches 100 vs legacy hash(100) true
6.3.7 encode 73 ASCII bytes true
6.3.7 encode 72 chars / 73 bytes true
6.3.7 matches 73 vs hash(72) true
6.3.7 matches 100 vs legacy hash(100) true
6.3.8 encode 73 ASCII bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.3.8 encode 72 chars / 73 bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.3.8 matches 73 vs hash(72) THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.3.8 matches 100 vs legacy hash(100) THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.3.9 encode 73 ASCII bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.3.9 encode 72 chars / 73 bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.3.9 matches 73 vs hash(72) true
6.3.9 matches 100 vs legacy hash(100) true
6.4.3 encode 73 ASCII bytes true
6.4.3 encode 72 chars / 73 bytes true
6.4.3 matches 73 vs hash(72) true
6.4.3 matches 100 vs legacy hash(100) true
6.4.4 encode 73 ASCII bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.4.4 encode 72 chars / 73 bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.4.4 matches 73 vs hash(72) THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.4.4 matches 100 vs legacy hash(100) THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.4.5 encode 73 ASCII bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.4.5 encode 72 chars / 73 bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.4.5 matches 73 vs hash(72) true
6.4.5 matches 100 vs legacy hash(100) true
6.5.11 encode 73 ASCII bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.5.11 encode 72 chars / 73 bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
6.5.11 matches 73 vs hash(72) true
6.5.11 matches 100 vs legacy hash(100) true
7.0.9 encode 73 ASCII bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
7.0.9 encode 72 chars / 73 bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
7.0.9 matches 73 vs hash(72) true
7.0.9 matches 100 vs legacy hash(100) true
7.2.0 encode 73 ASCII bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
7.2.0 encode 72 chars / 73 bytes THROWS IllegalArgumentException: password cannot be more than 72 bytes
7.2.0 matches 73 vs hash(72) true
7.2.0 matches 100 vs legacy hash(100) true
The full run, every case on twelve versions plus the two key rows for 6.3.9, 6.4.5, 6.4.6 and 6.5.0, is in the data file named in the environment block. The cases left out above follow the same pattern. For example, BCrypt.hashpw called directly behaves like encode, and the 37-character all-é password (74 bytes) throws wherever the 73-byte one does.
What the BCryptPasswordEncoder 72 Bytes Results Mean
Three findings stand out, and the first one contradicts most write-ups of the CVE.
Current Versions Still Return True Past Byte 72
On 7.2.0, matches("a" x 72 + "wrong", hash) returns true against a hash of 72 as. Likewise, the 100-byte legacy password and a different 100-byte string that shares its first 72 bytes both verify. In other words, the fix stops new truncated hashes from being created. It does not make old ones safer. A legacy hash from a long password still only protects the first 72 bytes, on every version.
That is a deliberate trade, and arguably the right one. Throwing in matches would lock every long-password user out at once, which is exactly what happened next.
6.3.8 and 6.4.4 Locked Out Long-Password Users
On 6.3.8 and 6.4.4, matches throws for any presented password over 72 bytes. A user who registered with a 100-byte passphrase on 6.3.7 gets an IllegalArgumentException at login, not a false, and so the request most likely surfaces as a server error unless something catches it. Spring Boot 3.4.4 and 3.3.10 pulled these versions in. Maven Central dates both jars 2025-03-17, and their replacements, 6.4.5 and 6.3.9, 2025-04-21. So any app that sat on Boot 3.4.4 or 3.3.10 during that window had this behavior. Its official framing, per CVE-2025-22234, is a broken timing-attack mitigation in DaoAuthenticationProvider. The advisory does not spell out the mechanism, and this harness did not test timing.
Multi-Byte Characters Hit the Limit Early
Every version that throws counts UTF-8 bytes. A 72-character password containing one é failed with the same message as a 73-character ASCII one. As a result, an HTML maxlength="72" on the form does not prevent the exception. Any validation has to measure bytes. A password of 18 emoji, for instance, already sits exactly at 72 bytes.
How to Handle the 72-Byte Limit: Three Options Tested
Upgrading past 6.4.4 removes the lockout, but it leaves two jobs: stop the IllegalArgumentException from reaching users at registration and password change, and decide whether long passwords should work at all. Three common answers were run against the same four inputs on 7.2.0, wired through DelegatingPasswordEncoder as a real app would wire them. The migration harness is in the same data folder; this is its raw output for the 100-byte input and the legacy row:
reject-at-form 100 ASCII validate THROWS IllegalArgumentException: Password is 100 bytes, the limit is 72
bcrypt-sha256 100 ASCII encode {bcrypt-sha256}$
bcrypt-sha256 100 ASCII matches same true
bcrypt-sha256 100 ASCII matches first 72 only false
argon2id 100 ASCII encode {argon2}$argon2i
argon2id 100 ASCII matches same true
argon2id 100 ASCII matches first 72 only false
legacy {bcrypt} row 72 ASCII matches via argon2 default true
legacy {bcrypt} row 72 ASCII upgradeEncoding true
The encode column prints only the first 16 characters of the stored value, which is why the Argon2 prefix is cut at argon2i. A full stored hash reads $argon2id$v=19$m=16384,t=2,p=1$.... “Matches first 72 only” checks the first 72 bytes plus an x: true there would mean truncation, so false is the correct answer.
Option 1: Reject Over 72 Bytes at the Form
The cheapest fix keeps bcrypt and refuses long input before it reaches the encoder. Count bytes, not characters:
import java.nio.charset.StandardCharsets;
public final class PasswordLengthPolicy {
public static final int BCRYPT_MAX_BYTES = 72;
private PasswordLengthPolicy() {
}
// Call from registration and password-change handlers, before encode()
public static void requireBcryptSafe(String password) {
int bytes = password.getBytes(StandardCharsets.UTF_8).length;
if (bytes > BCRYPT_MAX_BYTES) {
throw new IllegalArgumentException(
"Password is " + bytes + " bytes, the limit is " + BCRYPT_MAX_BYTES);
}
}
}
In the run, 72 ASCII bytes passed, and 73 bytes, 100 bytes and the 72-character é password were all rejected with their byte counts. Map this exception to a 400 with a clear message, for instance through a @ControllerAdvice as shown in the Spring Boot global exception handling guide. Otherwise, the encoder’s own exception surfaces as a 500. Note that this option does nothing for legacy hashes, which still verify on their first 72 bytes.
Option 2: SHA-256 Pre-Hash Before Bcrypt
The second option shrinks any password to a fixed 44 bytes before bcrypt sees it. It does that by hashing with SHA-256 and Base64-encoding the digest:
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
public final class Sha256BcryptPasswordEncoder implements PasswordEncoder {
private final BCryptPasswordEncoder bcrypt = new BCryptPasswordEncoder();
private static String prehash(CharSequence raw) {
try {
MessageDigest sha = MessageDigest.getInstance("SHA-256");
byte[] digest = sha.digest(raw.toString().getBytes(StandardCharsets.UTF_8));
// Base64 keeps it printable: raw digest bytes can contain zeros
return Base64.getEncoder().encodeToString(digest);
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("SHA-256 missing from the JDK", e);
}
}
@Override
public String encode(CharSequence raw) {
return bcrypt.encode(prehash(raw));
}
@Override
public boolean matches(CharSequence raw, String encoded) {
return bcrypt.matches(prehash(raw), encoded);
}
}
All four inputs encoded, verified with the full password, and failed with only the first 72 bytes. Furthermore, the pre-hash cost nothing measurable: a median of 46.7 ms per encode against 46.6 ms for plain bcrypt at strength 10. The OWASP cheat sheet cautions that pre-hashing can open “password shucking”, where an unsalted SHA-256 of the same password leaked from another system can be tested directly against your bcrypt hashes. It recommends an HMAC with a secret pepper instead of a plain hash if you go this way. Either way, register it under its own id, bcrypt-sha256, so you never mix it up with plain bcrypt rows.
Option 3: Move New Hashes to Argon2id
The third option drops the limit entirely. Argon2 has no 72-byte cutoff, and Spring ships an encoder for it. It needs the Bouncy Castle provider (org.bouncycastle:bcprov-jdk18on) on the classpath. With DelegatingPasswordEncoder, old {bcrypt} rows keep working while new ones get {argon2}:
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@Configuration
public class PasswordEncoderConfig {
@Bean
public PasswordEncoder passwordEncoder() {
BCryptPasswordEncoder bcrypt = new BCryptPasswordEncoder();
Map<String, PasswordEncoder> encoders = new HashMap<>();
encoders.put("bcrypt", bcrypt);
// saltLength 16, hashLength 32, parallelism 1, memory 19456 KiB, iterations 2
encoders.put("argon2", new Argon2PasswordEncoder(16, 32, 1, 19456, 2));
DelegatingPasswordEncoder delegating = new DelegatingPasswordEncoder("argon2", encoders);
// Rows stored by a bare BCryptPasswordEncoder have no {id} prefix
delegating.setDefaultPasswordEncoderForMatches(bcrypt);
return delegating;
}
}
The encoder objects in this bean are the ones the harness ran; the @Configuration wrapper is standard wiring and was not started in a Spring context. In the run, the legacy {bcrypt} row still matched, and upgradeEncoding returned true for it. That flag is what DaoAuthenticationProvider checks to re-hash a password on successful login when a UserDetailsPasswordService bean is present. Consequently, active users migrate themselves to Argon2id one login at a time. Even legacy long-password users migrate correctly: their full password still verifies against the truncated bcrypt hash, and then the whole password, every byte of it, goes into the new Argon2id hash.
The memory setting matters. Spring’s defaultsForSpringSecurity_v5_8() uses 16,384 KiB, slightly under the OWASP minimum of 19 MiB, which is why the bean above sets 19,456 KiB explicitly.
Hashing Cost Per Option, Measured
Each encoder was timed for five rounds of 20 encodes after five warm-up calls, on 7.2.0. Raw lines from the harness:
timing bcrypt strength 10 ms/encode rounds=[46.57163, 46.368755, 47.10934, 46.51386, 46.57901] median=46.6
timing sha256 + bcrypt 10 ms/encode rounds=[46.70236, 46.6398, 46.59508, 46.68288, 46.94617] median=46.7
timing argon2id v5_8 defaults ms/encode rounds=[15.88687, 15.968805, 15.431905, 15.36016, 15.376555] median=15.4
timing argon2id m=19456 t=2 p=1 ms/encode rounds=[23.77969, 21.92489, 21.07476, 21.48021, 20.843225] median=21.5
| Encoder | Median ms per encode | Length limit |
|---|---|---|
| bcrypt, strength 10 | 46.6 | 72 bytes |
| SHA-256 + bcrypt 10 | 46.7 | None |
| Argon2id, Spring 5.8 defaults (16 MiB) | 15.4 | None |
| Argon2id, OWASP minimum (19 MiB) | 21.5 | None |
Argon2id came out faster per hash here, which surprises people. However, wall time is not the whole cost. Argon2id also holds 16 to 19 MiB of memory per hash while it runs, so 50 concurrent logins need roughly a gigabyte of short-lived heap. Bcrypt needs almost none. Size your login throughput against memory, not only CPU. These numbers come from one desktop JVM on Windows, so they will differ on a Linux server, but the ratios are the transferable part.
Real-World Scenario: When a Prefix Eats the Password
The 72-byte limit caused a real authentication bypass in 2024, and none of it involved users typing long passwords. According to Okta’s advisory, its AD/LDAP delegated authentication built a cache key by running bcrypt over userId + username + password. With a username of 52 characters or more, the user ID and username together filled the 72 bytes, so the password never reached the hash. As a result, a cached login could succeed with any password. The preconditions were narrow: no MFA, delegated authentication, a cached earlier login. Even so, Okta replaced bcrypt with PBKDF2 for that key.
The same pattern turns up in smaller Spring codebases. A typical case is a small team building a multi-tenant SaaS with a few dozen tables, where someone salts the password with the tenant slug or email “for extra safety” before calling encode. On 6.4.3 and older, a long email silently truncates the password away, exactly as in Okta’s case. On 6.4.5 and newer, the same code instead throws at registration for long emails, which is far easier to notice. Either way, the fix is the same: never concatenate anything in front of a password before bcrypt. If you need a pepper, use an HMAC of the password, as in Option 2, so the result stays a fixed length.
When to Use BCryptPasswordEncoder With a 72-Byte Cap
- Your existing user table is bcrypt and a migration is not scheduled this quarter
- Your login form already caps length, and you can add a byte-count check in one place
- You run many concurrent logins on small containers and Argon2id’s per-hash memory would hurt
- You need hashes that every library and language in your stack can verify
When NOT to Rely on BCrypt Alone
- Users sign in with password-manager passphrases that may exceed 72 bytes
- Anything is concatenated in front of the password before hashing
- Your app still runs Spring Security 6.3.8 or 6.4.4, where long-password users cannot log in at all
- Compliance asks for a memory-hard algorithm, since Argon2id is the OWASP first choice
Common Mistakes With the 72-Byte Limit
- Validating length in characters with
maxlengthor@Size(max = 72), which lets a multi-byte 72-character password through to the exception - Reading CVE-2025-22228 as “matches is now safe” when every release still verifies on the first 72 bytes of legacy hashes
- Letting
IllegalArgumentExceptionfromencodebubble up as a 500 on the password-change endpoint - Pre-hashing with raw SHA-256 bytes instead of an encoded string, which can feed zero bytes into bcrypt
- Switching the default encoder to Argon2id without
setDefaultPasswordEncoderForMatches, so old prefix-less bcrypt rows stop matching - Assuming the 5.8 or 6.2 line is patched because a fix version exists, when 5.8.18 and 6.2.10 are Enterprise Support only and Maven Central stops at 5.8.16 and 6.2.8
What This Test Did Not Cover
The harness called the encoder directly, so it did not exercise DaoAuthenticationProvider, the login filter chain or the timing behavior that CVE-2025-22234 describes. It also did not test the Enterprise Support builds (5.8.18, 6.2.10 and their 22234 follow-ups), because they are not on Maven Central. The $2y$ and $2b$ bcrypt variants were not tested separately; every hash used the default $2a$ at strength 10. Finally, the timings come from one Windows desktop JVM and should not be read as server numbers.
Conclusion
The BCryptPasswordEncoder 72 bytes limit now behaves the same on every current Spring Security release: encode throws past 72 UTF-8 bytes, and matches still verifies anything whose first 72 bytes match a stored hash. Only 6.3.8 and 6.4.4 threw on login too, so if your lockfile still shows either one, upgrade first. After that, pick one of the three options: a byte-count check if bcrypt stays, or Argon2id through DelegatingPasswordEncoder if you want the limit gone and old users migrated on their next login.
As a next step, run mvn dependency:tree | grep spring-security-crypto against your service today and compare it to the table at the top. Then, if you are wiring the encoder into a token-based login, the Spring Security JWT REST API guide shows where it sits in the filter chain, and the API security checklist covers the rest of the login surface.