Django Security Release - 1.5.4
djangoproject.com
djangoproject.com
Sometimes we do releases because there's a serious exploitable thing in the wild.
This is the latter: it's a DoS vector, and it got out via a posting to a public mailing list. Please do not hold off on upgrading.
- bcrypt can have passwords up to 72 bytes (depending on implementation) due to its nature of feeding password into a block cipher, and Blowfish having max 448 bit keys but some implementations allowing 576 bits (see https://en.wikipedia.org/wiki/Blowfish_(cipher)#The_algorith...)
- scrypt accepts passwords of unlimited length, however the computational/memory cost doesn't depend on password length, as the first step in scrypt is expanding (or compressing) password and salt with 1-round PBKDF2, which is basically HMAC in counter mode.
When designing such systems, also consider that users sometimes accidentally copy-paste entire documents into text fields--given the number of users Django has, if a site has no input-field length limit, it's downright likely that someone will eventually paste a megabyte "password" in there with no ill intention.
Why should an end-user need to comprehend a limit in bytes at all? Good points though!
And my comment was an explanation of an other user's, nothing more.
The reason I still prefer arbitrary length fields is that I otherwise have to determine the limit myself. And finding reasonable limits isn't always that easy. For example, quite a few sites have about 20 chars as maximum password lengths. Using xkcd's correct-battery-horse-staple method (or formerly most commonly known as diceware) this assumption already fails. Also, what is the correct maximum length for a surname? (See Janice Keihanaikukauakahihuliheekahaunaele.) And then there are these ridiculously short text fields for complaints or questions on sites like UPS that only allow like 400 characters (how these are encoded into bytes raises other questions about how reasonable that limit is). I'd argue it's more work to find out the right limits than to implement arbitrary length fields.
In the case of PBKDF2 I would say it's the primitive's (PBKDF2's) fault for allowing a DOS on long passwords. I do not blame the designers though. I have read its definition several times and have never though about DOS attacks, too. Like with padding oracle or length extension attacks this should go on the check list for future designs and PBKDF2 should be phased out.
4096 is a convenient power of 2, and is the same as the default limit enforced by passlib (a popular password-hashing tool in Python).
>>> timeit.timeit('make_password(a, "asdfasdfasd")', setup="a = 'a' * 1024 * 1024; from django.contrib.auth.hashers import make_password;", number=1) 206.77019500732422