Skip to content

ext/standard: notice on long passwords in bcrypt - #23076

Draft
Sjord wants to merge 3 commits into
php:masterfrom
Sjord:bcrypt-72-notice
Draft

ext/standard: notice on long passwords in bcrypt#23076
Sjord wants to merge 3 commits into
php:masterfrom
Sjord:bcrypt-72-notice

Conversation

@Sjord

@Sjord Sjord commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@Sjord

Sjord commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

This could also apply to crypt. However, with crypt there is not a distinction between creating the hash and verifying the hash, as there is with password_hash / password_verify, which means that anyone that can access to login screen can trigger the notice by entering a long password. That makes the notice less meaningful and bigger chance of BC break.

@Sjord

Sjord commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@nikic @narfbg @ircmaxell I am looking into this again, and you seemed to have objected last time. Do you feel the same now?

This is mostly for the case where some static string is prepended to the password before being passed to password_hash, and not so much for the case where users actually use 72 character passwords.

@narfbg

narfbg commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for the ping, @Sjord.

I do still think that warnings would do more harm than good.

However, I might not be against a fail-closed approach where an exception is thrown. Not to say that I'd outright support that (the BC break can be too big a price to pay) but it would solve most of the problems I have with the warning idea.

@Sjord

Sjord commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

password_hash and password_verify are supposed to take a user's password. For both this is clear from the documentation. In that case, it is really rare and no problem if it's longer than 72 bytes.

However, in the FreshRSS bug (and more or less the Okta bug) mentioned above, they don't just supply the password, but prepend a nonce or a username. This is a bad idea and not a supported way of using password_hash/verify.

I think throwing an error is warranted. For FreshRSS this would mean severe BC break: their authentication method stops working when they upgrade their PHP version. Perhaps that's acceptable? It could be better than that users can bypass the authentication altogether. And if you use functions in undocumented and unsupported ways, you can expect BC break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants