28

I'm creating a webapp, and part of my authentication method is password length.

Should I put one in place? (say, 50 characters?) Or should I just put a minimum length (Currently at 6).

Are there problems with not putting in a maximum length?

5
  • 1
    possible duplicate security.stackexchange.com/questions/144/…
    – H.B.
    Aug 15, 2011 at 18:45
  • H.B: It's similar, but I beg to differ - I think that this question is different enough because I'm asking it from a implementation aspect and not a users aspect. However, if it gets closed as a duplicate, so be it. :)
    – jrg
    Aug 15, 2011 at 18:59
  • 1
    You should actually make it so your users have to use phrases instead of the typical password.
    – Woot4Moo
    Aug 16, 2011 at 22:31
  • 3
    Attackers love it when websites place arbitrary restrictions on user passwords. It gives them the info they need to tune their attack parameters.
    – user12666
    Sep 4, 2012 at 21:30
  • 1
    Nothing makes me angrier then encountering a maximum password length. It is indicative of incorrect password storage, it is arbitrary, and encourages users to accept using passwords shorter then they are otherwise capable of using. If you must set an upper bound to make sure user's aren't sending you gigabyte long password strings, pick a limit of 1024 or 256 characters at the bare minimum... Nov 8, 2014 at 22:21

3 Answers 3

34

You should hash the passwords using a secure algorithm instead of storing it in clear text. The hash function will result in a constant output size regardless of the length of the input string.

Using a minimum length and perhaps some other quality rules is a good idea because it helps a little against laziness.

If you are afraid of Denial of Service attacks, you could put a server side limit for ordinary input fields into place, for example 1000 bytes. It's unlikely that someone wants to use such a long password.

24

My recommendation: 1,024 bytes.

The limitation on password sizes is a limitation that existed for reasons of obsolete technical requirements. Modern password storage should rely on hashing which makes the password storage field a fixed size regardless of the password length. We don't want to see 1mb passwords as that would simply indicate somebody trying to cause a denial of service. I don't think I'll ever see a human use a 1,024 character (or longer) password. I think that's a small enough value to prevent any real DOS and a high enough value to never be reached in any reasonable circumstance.

6
  • 16
    The venerable Apple 1 had only a very minimal ROM, just enough to type in hexadecimal code; so every time it was booted up, someone had to type what was the OS at that time, i.e. a 3 kB BASIC interpreter (so about 6000 characters). Steve Wozniak could do it in 20 minutes and knew it by heart. Aug 15, 2011 at 19:15
  • 7
    And if you believe that I've got some money I need help transferring out of the country.
    – webbiedave
    Aug 15, 2011 at 23:42
  • 3
    @webbiedave Thomas is telling the truth - I've read the same thing in Steve Wozniak's book, iWoz.
    – jrg
    Aug 16, 2011 at 1:08
  • 6
    He didn't need to change it monthly though.
    – Joubarc
    Aug 17, 2011 at 8:12
  • 5
    I don't think a basic interpreter would be a good password. Nov 20, 2011 at 13:43
4

It depends on the message digest function you use. For the majority (sha-256, even md5,sha1 ect...) it doesn't matter. However, if you are using bcrypt it does, bcrypt has a 55 char limit. So if you're salt is 27 bytes you can have a password of 28 bytes.

On a side note, CWE-521 does require that you have a max password length. However it doesn't state the max, and from a security prescriptive I don't see any reason why it could be 512kbyte or more.

2
  • 1
    hey, that's interesting? do you have a link for further reading on the BCrypt char limit?
    – Jacco
    Sep 24, 2012 at 7:22
  • 2
    ...however as stated here you can simply hash the password and put that into bcrypt instead Feb 13, 2013 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .