by wulczer · 15y ago · 0 comments
Example A field accepts a username. A good regex would
be to verify that the data consists of the following
[0-9a-A-Z]{3,10}. The data is rejected if it doesn't
match.
I guess then that pg won't be able to sign up for your service... Nor will donfernandovillaverde79. The variations of attacks are enormous. Use regular expressions
to define what is good and then deny the input if anything else is received.
In other words, we want to use the approach "Accept Known Good" instead of
"Reject Known Bad"Moral: account registration and authentication must use the same password normalization functions, and if you validate at auth time (which is pointless, but hey), the validation function must be the same as the registration one.
Better moral: just don't do silly things with passwords. Encrypt them and store them, accepting whatever the user wants to send you that's sufficiently long/high-entropy.
That said, it could confuse people. I'd suggest to fill a bug at bugzilla.mozilla.org to put a broader example, or to specify that you might want different characters in the known good list, specially for non-latin writing people, cause yeah, many would just copy paste it without thinking further.
Then there is unicode normalization. OSX might decide to encode "e-with-an-accent" as two code points, while Windows will combine them into a single code point. Users will not be impressed if they can't log in because their OS doesn't use the right encoding and the web site forgot to normalize.