69 points · by ikeboy · 10y ago · 88 comments
This is like saying "Why isn't this random sequence of bytes a valid JPEG file?" If you want a random image, you generate the image randomly, then you encode it. Strings are no different — though the encoding is simpler.
The password bit is really just the hook, the main info in this article is the fact that these values are interpreted as UTF-16, and that UTF-16 has requirements beyond "sequence of 16-bit values."
Which is kind of obvious, but still not well known for many.
For UTF-32, only valid code points are allowed. Values above 0x10FFFF are not allowed, nor are values in the range used for UTF-16 surrogates.
UTF-8 is more complex. It's ASCII compatible, which means all values with the top bit set to 0 are allowed. Bytes with the top bit set to 1 must exist as part of a multi-byte sequence. The first byte in such a sequence must contain 2-4 leading 1s followed by a 0. Subsequent bytes must be of the form 10xxxxxx. The total length of the sequence is equal to the number of leading 1s in the first byte. Any deviation from this is invalid UTF-8. Further, any sequence must be minimal, meaning that the value it encodes can't be one that would fit into a smaller sequence.
Whether it may just so happen to represent real, correctly typed, English words, or be a valid ASCII string, or UTF-16 string, or whether it was typed it from your keyboard, or generated from a program, these should also be incidental.
232e2252b8d5a294dd8564020f0cf609f511b3d196ed83030ce9615c6737f578
That's readable, typable, copy-pastable. Not very memorable but 256 bits is rarely memorable.
It's still short enough to send around by normal messaging.
This is specifically about randomly generated passwords, this is not about dealing with human generated "must have capitals, not start or end with a number" etc rules.
And before you Google and say "No! It changed to 127 in Windows XP!", remember:
- Somewhere on your network, NTLM is being used.
- Office 365 supports 16 max.
- Lots of random apps won't work.
1 - if you have ntlm (non-v2) on your network, you're fucked anyway and this debate is academic. 2 - even if you do, having a password of 15 or more characters will cause your legacy hash to be set to "AAD3B435B51404EEAAD3B435B51404EE" and will protect you against having your hash cracked if it's stolen from the non-v2 service. 3 - the office 365 limits can be worked around with dirsync or federation (source: I've done both)(note: outlook does weird things with leading/trailing spaces) 4 - those apps should be kerberized or similar
In any case, the point is as a user, especially on a big network, you have no idea what your actual effective password strength is. Plenty of places do lots of dumb things with AD -- one example that comes to mine was an inter forest trust between two good sized domains where bad DNS implementation and... Misguided security interpretations basically made it impossible to use Kerberos.
I login to Office 365 with a password that has over 16 characters. I have similar length passwords in Windows networks that use NTLM. Clearly it works just fine.
Example:
Your password is 12 characters on a system that says make it 8 characters or longer. If you type only the first 8 characters of your password, it lets you in. As someone else said, "silent truncation".
All of this is anecdote from personal experience so take it with a grain of salt. I haven't researched it.
$ dd if=/dev/random bs=1 count=32 | base64
ca2ktYYvppr1/HwwGYrg01udQX1cP4Ek5VmyzQydT+8=... when I just still wet behind the ears I was studying the codebase of my first job, and came across a quite extensive badwords.txt . On asking why we had a the dictionary of cussing in our project, I found out that the randomly generated passwords that we sent to our clients, apparently managed to get a customer quite angry when one of the words produced started with a slur, and this was a filter to prevent that from happening again
Generating random passwords isn't quite as straightforward as it would seem to be...
Different systems have different characters that will be included/discluded from "twice click highlighting" (I have no idea what the term is called). Hex works on virtually all systems.
The article does mention it's not very space efficient.
232e 2252 b8d5 a294
dd85 6402 0f0c f609
f511 b3d1 96ed 8303
0ce9 615c 6737 f578
Of course, it's still a lot of characters.No, it's not necessary, unbounded length is probably better. But it's pretty nice to have a lot more characters, and ought to be an easy win.
The goal should be long easy to type and remember passwords, adding an extra few digit is worth far more than forcing passwords to look like: 2K#@1j*
Compare say a 20 digit numeric password vs an 9 digit [0-9] [a-z] [A-Z] and special.
That is neither what the parent suggested nor really true. The space of, say, 8 character passwords A-Za-z0-9 that DO have at least one digit is very similar in size to the space of passwords maybe not containing digits. (The latter is 36^8 the former is 36^8-26^8, a reduction by less than 8% of the password space. The difference is even less important for longer passwords)
Once you hit 12+ characters it is extremely likely that the password is vulnerable to dictionary/phrase attacks combining whole words - or you're using a password manager.
The xkcd is funny - but it's also a terrible password suggestion.
My alphabet last letter is "ż" not "z".
\w = alphanumeric
Some people don't even have latin letters on their keyboards by default. And "latin letters" aren't well defined anyway. For one thing technicaly "w" isn't a latin letter.
I'm of the opinion that all restrictions on character set in password are unnesessary and harmful. You shouldn't store plain passwords anyway. You shouldn't even pass the plain password from client to server. Why do you care what character set your customer uses?
IMHO the main reason to restrict passwords' character set is to annoy users by forcing them to make another variation of their favorite throwaway password for your criticaly important blog comment section.
> For one thing technicaly "w" isn't a latin letter.
Don't be silly. Yes, I know how Romans pronounced 'ave'.If there was a predictable pattern, that would be even worse!
There's a number of advantages to this scheme:
- It's easy to write down and put in a safe.
- No funny characters required.
- Not case-sensitive.
- If a user makes a spelling error, we can correct it for him without any compromise in security.
- Guaranteed to be free from offensive words, unlike a randomly generated password.
- People are using words anyways, misspelled if necessary, whether we like it or not.
We can also make it even more user-friendly by carefully degrading security, such as trying common word substitutions for the forgetful users, or doing some kind of middle-ground "remember me" that does not let you straight in, but only demands first three words (to keep the family members at bay). Like I said, this required careful calculations as to how much security is sacrificed when we do that.
http://world.std.com/~reinhold/diceware.html
Some intrepid child got internet famous recently for making some money by doing this for you.
This gives you safe strings as well as space-efficient encoding. As a bonus virtually all systems support unicode without any tweaking necessary.
I hope the author of base64k gets around to writing an RFC because it would be a great standard to use.
• Some services require both upper and loweracase characters.
• Some services require punctuation characters whilst others prohibit them.
• Some services prohibit repeated characters.
• Some services impose a minimum password length; some impose a maximum password length; some impose both.
Covering all these situations is nearly impossible.
These restrictions exist for when humans are allowed to generate passwords. This article is discussing systems where humans don't generate passwords and don't in regular operation enter them.
Think of automatic password generation for a secure API endpoint, or automatic generation of private keys secured by a password that typically will be used in a system with it on the keychain but where the backup copies will be stored offsite.
In that case it's acceptable to have a password which is both secure but it has to be easy to type when required but doesn't have to be easy to type (i.e. short) for regular use.
The internet of things means that more and more devices will be creating "users" which are actually just other IoT devices. Those devices/device-users require these sorts of passwords.
Binary password is usually not called a password, it's a key.