Back to Blog
PHP Backs Off Rejecting Long bcrypt Passwords. What Laravel Apps Should Still Check
PHP's plan to reject long bcrypt passwords is on hold after criticism. A gentler replacement RFC proposes opt-in PASSWORD_BCRYPT_SHA256. Here is what that means for Laravel's default hasher and what to check today.
Back
Engineering
Table of contents
bcrypt only reads the first 72 bytes of its input. Today, when you pass password_hash() something longer with PASSWORD_BCRYPT, PHP hashes the first 72 bytes and quietly drops the rest. The manual warns about this, but nothing in your code does.
PHP internals tried to make that loud with a deprecation notice and eventual error, but that plan is now on hold. A gentler replacement is coming instead. Because Laravel uses bcrypt by default, it is still worth checking your app now.
Quick Answer
- An earlier RFC that proposed throwing errors for passwords over 72 bytes in bcrypt is on hold. The author announced on October 5, 2026 that the reject approach received too much criticism for backwards incompatibility and is not being pursued further at the moment.
- The replacement path is opt-in. A new draft RFC proposes
PASSWORD_BCRYPT_SHA256, which uses HMAC-SHA256 before bcrypt (like Passlib's bcrypt_sha256). No silent truncation, no BC break, andPASSWORD_BCRYPTstays unchanged. Proposed for next PHP 8.x, such as 8.7. - The 72-byte truncation problem is still real. If your Laravel app hashes the raw user password with
Hash::make(), you are almost certainly fine. If it glues a pepper, nonce, username, or token onto the password first, fix that now. - Laravel already has an opt-in guard:
BCRYPT_LIMIT(thehashing.bcrypt.limitoption). It is off by default and still worth considering.
Why this keeps coming up
Truncation is not a theory problem. Both RFCs cite two real cases:
- FreshRSS (CVE-2025-68402). A 64-character nonce was prepended to a 60-character bcrypt hash before hashing again. The 72-byte window held only the nonce and the
$2y$10$header, so any password worked. - Okta. In the original RFC's words, exceeding the length boundary in bcrypt cache key generation led to hash comparison failures and authentication bypasses under specific conditions.
Both bugs share a shape. Somebody fed bcrypt something other than a plain password. That is the case both RFCs are aimed at.
What happened to the reject RFC
The original RFC (Throw error for passwords longer than 72 bytes in password_hash() with bcrypt) proposed a hard line. PHP 8.7 would emit E_DEPRECATED for passwords over 72 bytes, and PHP 8.8 would throw ValueError. The goal was to turn silent truncation into a loud error.
The criticism was immediate and substantial. On October 5, 2026, RFC author Sjoerd Langkemper announced on the internals list that the reject approach is on hold. He said it received much criticism for backwards incompatibility and he does not think it is worth pursuing further at the moment. The RFC status remains Draft and there is no vote planned.
What the new bcrypt-sha256 RFC proposes
A gentler replacement appeared shortly after. The new draft RFC (Add PASSWORD_BCRYPT_SHA256 to password_hash()) takes an opt-in path instead.
- New constant:
PASSWORD_BCRYPT_SHA256. It applies HMAC-SHA256 to the password, then runs bcrypt on the result. This is the same scheme as Passlib's bcrypt_sha256 (version 2), so hashes are interoperable. PASSWORD_BCRYPTstays unchanged. No deprecation, no BC break. Existing code keeps working exactly as it does today.PASSWORD_DEFAULTstays unchanged. It still resolves to bcrypt (or Argon2id if compiled in).- Proposed for next PHP 8.x, such as 8.7. The reference implementation is php-src PR #24073.
The HMAC-SHA256 step base64-encodes the digest into a fixed 44-character ASCII string before bcrypt runs. That key is always under bcrypt's 72-byte limit, so there is no truncation risk. The tradeoff is stored hash size: bcrypt-sha256 uses a $bcrypt-sha256$v=2,t=2b,r=12$ style prefix plus salt and digest, about 83 characters total versus roughly 60 for plain $2y$ bcrypt, so you may need to widen your database column.
This is the path forward that internals seems more comfortable with. It fixes the truncation problem for new code without breaking anyone's existing login flow.
What Laravel does today
I read the current 13.x source to see where this lands.
bcrypt is the default. config/hashing.php ships with 'driver' => env('HASH_DRIVER', 'bcrypt').
There is already a length guard, but it is off. The bcrypt block looks like this:
php
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 12),
'verify' => env('HASH_VERIFY', true),
'limit' => env('BCRYPT_LIMIT', null),
],When limit is set, BcryptHasher::make() throws an InvalidArgumentException if strlen($value) is over the limit. It was added in laravel/framework PR #54509 (merged February 2025 for Laravel 12), written in response to the Okta incident. I could not find it in the 13.x hashing docs when I checked on 2026-11-20, so it is easy to miss. strlen counts bytes, which is the right unit here.
Rehash on login calls make() again. rehash_on_login defaults to true. After a successful login, EloquentUserProvider::rehashPasswordIfRequired() checks needsRehash() and, if the cost changed, calls $hasher->make($credentials['password']) with the plain password the user just typed.
That matters in two ways:
- If you set
BCRYPT_LIMIT=72today and later raiseBCRYPT_ROUNDS, an existing user with a longer password logs in successfully, then hits the length exception during the rehash. From my reading of the code, that looks like a failed request rather than a clean validation error. I have not reproduced it end to end yet, so treat this as something to test, not a confirmed bug. - If the on-hold reject RFC were ever revived as written, PHP 8.8 would do the same thing for everyone, guard or not.
One small thing I noticed. BcryptHasher::make() wraps password_hash() in try { ... } catch (Error) and rethrows RuntimeException('Bcrypt hashing not supported.'). ValueError extends Error, so if PHP ever throws on long input, the current code would report it with that misleading message. That is today's source, and Laravel has years to adjust it before any PHP 8.8. It is just worth knowing if you ever see that message on a box where bcrypt obviously works.
The validation trap
The obvious fix is a max length rule. Be careful with the unit.
Laravel's max:72 rule on a string uses mb_strlen(), so it counts characters. Password::max(72) adds the same max rule. A 72-character password made of accented letters, CJK characters, or emoji can be well over 72 bytes and still pass.
If you want the validator to match bcrypt's real limit, check bytes:
php
use Closure;
use Illuminate\Validation\Rules\Password;
'password' => [
'required',
'confirmed',
Password::min(12),
function (string $attribute, mixed $value, Closure $fail) {
if (is_string($value) && strlen($value) > 72) {
$fail('The password is too long. Please use 72 bytes or fewer.');
}
},
],The error message is the hard part. "72 bytes" means nothing to most users. I would probably word it as a shorter-password request and accept that a few multibyte users will see the limit earlier than they expect.
What PASSWORD_BCRYPT_SHA256 would mean for Laravel apps
If the bcrypt-sha256 RFC lands, Laravel apps could start using it whenever the framework adds support. Here is what to expect:
- It would be opt-in. You would set
HASH_DRIVER=bcrypt_sha256(or whatever Laravel names it) explicitly. The defaultbcryptdriver would stay as-is. - Hashes are longer. Stored hashes use the
$bcrypt-sha256$v=2,t=2b,r=...$modular crypt layout (22-character salt plus 31-character digest), about 83 characters versus roughly 60 for plain bcrypt. Check yourpasswordcolumn width if you migrate. 255 characters is a safe target. - It is not a drop-in replacement. With
HASH_VERIFY=true(the Laravel default), a bcrypt-sha256 hasher will refuse to verify plain bcrypt hashes. You would need a migration plan for existing users, probably something like checking both old and new hashes during a transition window. - It is interoperable with Passlib. If you have Python services or data pipelines that use Passlib's bcrypt_sha256 (ident
$bcrypt-sha256$), they can verify hashes from PHP and vice versa.
For most Laravel apps, Argon2id is still the better move if you are changing algorithms. It is already supported, well tested, and does not require a new PHP version. But if you have an existing pipeline that uses bcrypt-sha256, or if you need bcrypt-compatible hashes without the 72-byte truncation risk, the new constant would be a cleaner option than rolling your own pre-hash wrapper.
What I would check this week
- Search for concatenation before hashing. Grep for
Hash::make(,bcrypt(, andpassword_hash(and look at what goes in. Anything like$pepper . $password,$user->email . $password, or hashing a token plus a secret is the FreshRSS shape. Fix those first. This is the real risk, and it exists today on every PHP version. - Decide whether to set
BCRYPT_LIMIT=72. It turns silent truncation into an exception for new hashes. If you turn it on, add the byte-length validation rule above so users get a form error instead of a 500, and test a login for a long-password account before you changeBCRYPT_ROUNDS. - Consider Argon2id for new apps. Laravel supports
HASH_DRIVER=argon2id. For an existing app this is not a one-line flip. With the defaultHASH_VERIFY=true, the Argon2id hasher refuses to check hashes made with a different algorithm, so plan the migration instead of just changing the env var. - Watch for PASSWORD_BCRYPT_SHA256 support in Laravel. When PHP ships it and Laravel adds a driver, evaluate whether it fits your migration plan better than Argon2id.
My Take
I am glad internals is taking the gentler path. The original reject RFC was technically sound but brutal in practice. Silent truncation is a real problem, but breaking existing apps at the language level was never going to land cleanly.
The bcrypt-sha256 proposal feels right. It gives you a way out of the truncation trap without forcing a flag day. If you have concatenation bugs today, you still need to fix them, but now there is a forward path that does not require rewriting your entire auth stack or risking a ValueError for a user with a long passphrase.
For Laravel apps, the practical advice has not changed much. Stop concatenating things into passwords, decide on BCRYPT_LIMIT deliberately, and validate in bytes if you enforce a max. Those fixes work on every PHP version and they close the actual hole now. When bcrypt-sha256 ships, you can evaluate it as an opt-in upgrade instead of a forced march.
Sources
- PHP RFC: Throw error for passwords longer than 72 bytes in password_hash() with bcrypt (status Draft; on hold per RFC author; no vote opened as of 20 Nov 2026)
- PHP RFC: Add PASSWORD_BCRYPT_SHA256 to password_hash() (status Under discussion; 1 Nov 2026 changelog entry canonicalizes the bcrypt salt; voting thread not yet opened as of 20 Nov 2026)
- php.internals: bcrypt-sha256 RFC announcement (October 5, 2026, RFC author announces original RFC is on hold)
- php/php-src PR #24073 (bcrypt-sha256 reference implementation)
- php-net.pro roundup: PHP Internals Shifts bcrypt Fix to an Opt-In SHA-256 Scheme (October 8/9, 2026)
- PHP manual: password_hash() (72-byte truncation caution)
- laravel/framework PR #54509 (bcrypt length limit option)
- laravel/framework 13.x config/hashing.php
- laravel/framework 13.x BcryptHasher.php
- laravel/framework 13.x EloquentUserProvider.php (
rehashPasswordIfRequired()) - laravel/framework 13.x ValidatesAttributes.php (
getSize()usesmb_strlen()for strings) - Laravel 13.x docs: Hashing
- PentesterLab: FreshRSS bcrypt truncation auth bypass (CVE-2025-68402)
Checked on 2026-11-20
Comments
No comments yet
Loading comments...