5 ms·
Password hashes are specifically designed to be computationally intensive. You can feed any length of password into a hash, but the longer the password is, the
by thaumasiotes 9y ago
Password hashes are specifically designed to be computationally intensive. You can feed any length of password into a hash, but the longer the password is, the more work you have to do.
"No length restriction on passwords" is a common and valid report on HackerOne, because servers that do store passwords securely can be DoSed by someone providing a long password and forcing the server to hash it.
- wongarsu 9y agoThat is an important consideration, but it still sets reasonable password length limits in the hundreds or thousands of characters.
- bigiain 9y agoNIST's latest recommendations say "at least 64 characters". I doubt there's anyone who can make a strong argument that "64 characters isn't enough", and I doubt even intentionally computationally expensive password hashing is going to end up with significant resource usage with 64 or 128 character strings. I wouldn't want my shared hosting WordPress site with a password plugin to need to calculate the bcrypt hash of the entire text of War And Peace, bit I suspect the difference between bcrypting "password123" and a random 64 or 128 character string is insignificant enough to be ignored (but I've never tried benchmarking it, so I'm open to changing my mind here if anyone has links to benchmarks that show otherwise...)
- thaumasiotes 9y agoI usually see recommendations for a 72 character limit. I doubt there's any particular reason for 72, but as you say, it's enough. Login attempts (should) get rate limited independently of password length limits, which makes the difference between hashing 8 characters and hashing 72 characters even less meaningful.
- CodesInChaos 9y agoI'd guess it's because bcrypt only supports 72-byte inputs (though there are workarounds, like pre-hashing)
- tracker1 9y agoWhich is why you add a randomized wait/sleep before responding to an invalid login attempt, to, hopefully slow down "tries" having a cache for recent tries by IP as well would assist in mitigation. The strength of the hashing is also of issue... for example pbkdf2 is very compute heavy. If you're working in an environment that has a FaaS (AWS Lambda, etc), it may be worthwhile to have this as an async function call so as not to block your primary application. Another option is to break authentication into its' own application, and have that return a signed auth token to your application. There are lots of options.