3 ms·
There should be limits. What if someone pastes the text of the bible into the name field? What if you want to send an email containing the name, and you hit the
by layer8 4y ago
There should be limits. What if someone pastes the text of the bible into the name field? What if you want to send an email containing the name, and you hit the maximum email size accepted by the SMTP server (they all have a limit)? What if you want to send a postal letter and print the name on the envelope?
Not setting explicit limits either means that you still have implicit limits, but you don’t know what they are and where and when you’ll run into them, or it means you’re opening yourself up to DoS attacks, because your database or your backups or your AWS bill will run amok.
- GauntletWizard 4y agoI have legitimately used the complete works of William Shakespeare, unabridged, as a password. Even that is in megabytes, and not significant load for bcrypt2. Not that there should be no limits at all, but the upper bound should be relatively high.
- asynchronous 4y agoDoesn’t bcrypt2 essentially truncate every source input to no longer than 35 characters?
- layer8 4y agoIt’s 72 bytes, but yes. Probably a good reason to have a length limit on the password field if you use bcrypt.
- mellavora 4y agoNow all I have to do is guess which order you used them in, and I'll have full access to your system!
- jagged-chisel 4y agoYes, you need input validation that enforces some kind of limit. But every layer of processing (function calls, RPC…) in the stack from the text entry through the network through the database engine to the disk doesn’t need to be concerned with the 200 character limit for a name. The database can give you an error if the size is exceeded. The input field can warn the user about the limit. But the code that converts from the user’s chosen encoding to utf-8 doesn’t need to know anything about those limits.
- layer8 4y agoYes, the important thing is to have a data schema that defines the limits and that is enforced at all system boundaries. That way you also identify the cases where the limits may not match those of the protocols you are talking to (mappings between schemata, basically).