TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Is there a good reason for disallowing some characters from a password?

38 pointsby andy_herbertover 2 years ago
I see this restriction quite often, and it makes no sense to me whatsoever. Am I missing a compelling reason for this practise, or is it an example of bad design?

29 comments

remramover 2 years ago
You might want to run the password through Unicode-normalizing functions first (NFD or NFKD) but otherwise no.<p>Some sign-up forms don&#x27;t even give you feedback on which characters are problematic. The Oracle Cloud one kept erroring with &quot;you need one uppercase, one lowercase, and one number&quot; when what it meant to say is &quot;remove that tilde&quot;, that took a while to figure out.
评论 #32638544 未加载
评论 #32639394 未加载
评论 #32640961 未加载
RicoElectricoover 2 years ago
Bad design, this seems to be part of many legacy systems. People tended to make bespoke textual formats, instead of, how we do now, using properly escaped serialization like JSON. And because they couldn&#x27;t bother making a robust parser with escaping, they went the lazy route of just disallowing characters with special meaning.
评论 #32638392 未加载
评论 #32638308 未加载
Someone1234over 2 years ago
Typically, they&#x27;re using legacy software to store the password itself (e.g. database, mainframe, etc).<p>For a specific example Oracle Database has a very restrictive list of characters allowed in a user password. If you&#x27;re using Database Users behind the scenes (even if not directly, but via an Oracle integration) you&#x27;re subject to those same restrictions. Up until Oracle 11g passwords were also limited to 30 characters and a few releases before that were case-insensitive (!).<p>Is this a good reason? I&#x27;d argue, no, but I&#x27;ve worked at tons of organizations where &quot;things that don&#x27;t make sense&quot; often have an explanation even if it isn&#x27;t an explanation you&#x27;re happy with. We should definitely push companies to use cryptographically secure one-way hashing functions with salts, and adjustable difficulty.
评论 #32639200 未加载
评论 #32638615 未加载
noufalibrahimover 2 years ago
A relevant anecdote. During my younger more adventurous years. We used to try to peek over admins shoulders to figure out passwords for root. Not to do anything malicious but just as a act of geeky bravado. Naturally, they got savvy and prevented us from doing this.<p>The keyboards in the lab were heavily used and was noisy. The space bar, because of its shape, sounded distinctly different from the other keys. I stayed away from the admins when they entered the password like a decent citizen but listened in and found that the password was 7 characters long and also that the second and sixth characters were space (thanks to the different sound of the key). So .˽...˽.<p>I brute forced this using a shell script (since I has just learned how to write shell script), ran it overnight, and got in the next day.<p>So yes, I think there might, atleast in theory, be good reasons to avoid certain characters in a password.
评论 #32638685 未加载
评论 #32638617 未加载
RedNifreover 2 years ago
I think there was a story about somebody locking himself out of macOS, because he couldn&#x27;t enter Emoji on the login screen.<p>Also, since my password manager types letters one by one, I wouldn&#x27;t use tabs or line feeds.<p>Maybe don&#x27;t use grapheme clusters that have multiple valid encodings and make up for it by using a longer password instead?
Someoneover 2 years ago
As others said, it’s important that your users can enter their password on all devices they would want to use.<p>Because of that, outlawing the likes of line feed, carriage return and backspace (raw input on a tty will store those in passwords, but good luck entering them in a web form) makes sense, as does normalizing Unicode input (typing ‘é’ on their phone may produce a byte sequence that’s different from typing ‘é’ on their PC)<p>Apart from that, it should not be necessary. If, however, you don’t trust your programmers to do the right thing, you may want to rule out characters that are related to security incidents such as single quotes, and also may want to prevent users from entering strings that might get decoded to such strings such as ‘&amp;quot;’.<p>That path can be endless, though. If you forbid ‘&amp;’, because your programmers might accidentally html-decode it, should you guard against double html-decoding? URI-decoding and then uudecoding? Getting programmers you can trust to do the right thing and giving them the time to do so is the better option.
jollyllamaover 2 years ago
It&#x27;s always annoying when a special character is required in a password, but &quot;no, not that special character&quot;. Presumably those devs can&#x27;t figure out how to escape special characters properly.
_dain_over 2 years ago
I suppose one legitimate reason might be to safeguard you in a scenario where you have to enter the password on a nonstandard keyboard? Also, if they can be easily confused with some other characters it might make sense to disallow them just to remove a headache for support staff trying to deal with people entering the password wrong (e.g. en-dash vs em-dash vs hyphen).<p>But they&#x27;re probably just storing it in plaintext on some legacy system that can&#x27;t handle certain characters. Or the plaintext goes through one of those systems on its way to being hashed and salted.
josephcsibleover 2 years ago
For characters between U+0020 and U+007E inclusive, there&#x27;s no good reason at all, and it probably means that they&#x27;re storing passwords in plaintext instead of hashing them, and that they aren&#x27;t using parameterized queries to protect against SQL injection.<p>For characters outside that range, there is a good reason: it&#x27;s hard to type those characters consistently across different platforms&#x2F;systems, and they don&#x27;t want you to lock yourself out over that.
mstefover 2 years ago
let me quote NIST Special Publication 800-63B: <a href="https:&#x2F;&#x2F;pages.nist.gov&#x2F;800-63-3&#x2F;sp800-63b.html#memsecret" rel="nofollow">https:&#x2F;&#x2F;pages.nist.gov&#x2F;800-63-3&#x2F;sp800-63b.html#memsecret</a><p>&gt; Verifiers SHALL require subscriber-chosen memorized secrets to be at least 8 characters in length. Verifiers SHOULD permit subscriber-chosen memorized secrets at least 64 characters in length. All printing ASCII [RFC 20] characters as well as the space character SHOULD be acceptable in memorized secrets. Unicode [ISO&#x2F;ISC 10646] characters SHOULD be accepted as well.
brendoncarrollover 2 years ago
I can think of a few reasons to exclude a character:<p>- Requires quoting or escaping in the shell or some other programming environment<p>- Hard to type on mobile keyboard.<p>- Not in a given person&#x27;s touch-typing repertoire.<p>The correct way to think about password security is as randomly generating a binary string of the desired security strength&#x2F;length and then encoding it. If you generate 16 random bytes, that&#x27;s 128 bits of security whether you encode it with hex, base32 or base64.<p>Required characters also do little to improve security, since there is usually only 1 of each kind of required character, and it&#x27;s often at the beginning or end. They don&#x27;t cause the user to select a random string from a meaningfully larger space.
csydasover 2 years ago
I think as long as the list is clear on what it must not have in advance and what it must have, it&#x27;s not as big of a deal. Strings are a pain in the ass and come up with surprising ways to be frustrating, so I can totally get a restriction on some character.<p>What I cannot get is sites that make you play 20 questions to figure out their rules instead of just telling you, as in my experience, it leads to lousy passwords that meet only the bare minimum. I seem to recall some popular site (want to say it was AirBnB) which threw an error &quot;password cannot contain name&#x2F;username&quot; for basically anything it didn&#x27;t like, regardless of whether the password actually contained that, and it&#x27;s very annoying.<p>It was one of the most welcomed changes to the password system at a former work place when I convinced the small team behind the authentication to put the requirements plain and simple and change from red to green as people met the requirements. We also added a passphrase helper that could be summoned if they missed requirements a few times which based on metrics got some fair use.<p>People generally want to do well by security and it&#x27;s on their mind, but no one wants to look stupid because they can&#x27;t think of a password that meets unknown requirements. Make it clear what&#x27;s expected, and even a nudge towards how to think of good passphrases, and you&#x27;ll get happy people using your site.
remorsesover 2 years ago
Some Unicode characters can be represented in multiple ways, maybe it’s better to normalize password strings before storing or hashing them
4oo4over 2 years ago
I don&#x27;t remember exactly which sites, but I run into the problem every so often with a handful where I&#x27;m prompted to change my password according to vague guidelines that say I usually need special characters, without saying which ones it accepts.<p>I change my password with something randomly generated by my password manager, and the site accepts it, and as far as I know I&#x27;m good to go. Then next time I try to log into the website, it doesn&#x27;t accept the password it previously (falsely) accepted before, and I have to reset it again and play the guessing game of what special character it didn&#x27;t like. Madness.
wizofausover 2 years ago
Allowing linefeeds&#x2F;carriage returns&#x2F;ASCII nulls seems like a bad idea. I have wanted to include backspace in a password though!
评论 #32638939 未加载
Ekarosover 2 years ago
Somethings like control characters and null byte might cause issues. So likely better safe than sorry with those.
GnarfGnarfover 2 years ago
It would be interesting (and helpful) to see some real-life examples of which Websites disallow what characters. Then maybe we could hazard an explanation.<p>Possibly they&#x27;re preparing for password entry on more ubiquitous devices with limited keyboards? (ATMs, credit card keypads).
grishkaover 2 years ago
IMO you shouldn&#x27;t be interpreting passwords at all, besides maybe enforcing a minimum length of 4-6 characters. Other than that you receive a string from the user and you just hash it as is.
fallingknifeover 2 years ago
I see a lot of mention of unicode and unusual space&#x2F;null characters here which makes sense, but I was not allowed to use @ in my pw for my Amex account, and that seems absolutely crazy.
blitzarover 2 years ago
If the character can not be hashed - outside of that, no reason at all.<p>Although you should probably not allow &quot;1234&quot; as passwords or anything on the top 100 list for that matter.
dioxideover 2 years ago
I do this on IRC to prevent people from using characters that clients will interpret. It&#x27;s not safer, but it prevents a ton of password support issues.
brodouevencodeover 2 years ago
My credit card company does this, and it&#x27;s infuriating
hulituover 2 years ago
Try to type a password with accents on an english keyboard
lexicalityover 2 years ago
it&#x27;s very important when you&#x27;re storing passwords in plain text, so typically it&#x27;s a sign the website is dangerously insecure, though sometimes it&#x27;s also just some product manager going &quot;well everyone else does it, so it must be important&quot;.<p>That said, I did actually run into an instance where having &quot;;-- in your password would trigger the WAF during login and because we needed to ship ASAP the easiest way to get around that was to ban ; in passwords. I don&#x27;t think we ever went back to fix that one...
评论 #32638501 未加载
can16358pover 2 years ago
Mandatory plug: <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;936&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;936&#x2F;</a>
评论 #32638624 未加载
phloover 2 years ago
Let&#x27;s start at the edgest of cases.<p>Some emoji, for example, are combinations of multiple other emoji, and a given combined emoji may not be uniquely represented by a sequence of codepoints. In the pathological case, this could mean that an OS update on the user&#x27;s system changes the composition of the same emoji, which might make it impossible for them to input their password. It is probably prudent for a system to disallow emoji passwords.<p>One step away from Emoji, Unicode also allows for other m̸̱̜̅ͅȋ̴̩̠̀s̸̺͐c̶͈͇͉̐͛̚h̸̤̣̆i̴͍͍͒͌e̴̲̽̓f̸̞̽̊. Chances are, full-on Zalgo passwords can lead to problems. Again, there are probably prudent reasons to restrict some characters. On the other hand, those modifiers exist for a reason, and disallowing phrases in the user&#x27;s native language doesn&#x27;t make for great UX.<p>Towards the more common use of Unicode, there is a pretty good _practical_ reason to restrict the use of some non-ASCII characters: if your system accepts ç, ö and ø as characters in passwords, and non-technical users venture into a part of the world where the keyboard layout doesn&#x27;t, your helpdesk is going to have to deal with the occasional annoyed customer. From a systems design perspective, those characters seem fine -- operationally, they may cause headaches.<p>Finally, we&#x27;ve arrived at printable ASCII characters. Restrictions on maximum length (usually 6 or 8 characters), and on certain characters (%, &amp; or :) tend to be based on interactions with legacy systems (e.g. DES crypt() used to have an 8-character minimum), or on bad input handling. Either way, it&#x27;s probably a bad sign.
评论 #32638692 未加载
评论 #32638858 未加载
评论 #32638769 未加载
pestatijeover 2 years ago
It forces the use of a new password specific to that site. Reusing passwords is considered bad for security.
评论 #32638359 未加载
评论 #32638547 未加载
prof-dr-irover 2 years ago
I once used a special character in my login password (on Ubuntu I think) but the keyboard settings at the passwd prompt happened to be set differently from the ones at the (graphical) login manager at boot. So in the one case, something like &#x27;e was interpreted as é and in the other case it wasn&#x27;t.<p>I think it took me about five reboots in single-user mode and password resets before something clicked. I wish Ubuntu would not have allowed special characters. :)
tiffanyhover 2 years ago
On mobile, keyboards typically auto capitalize the first letter of the first word.<p>So if your password is &quot;password&quot;, it will get entered in as &quot;Password&quot; - and the user will get confused why their username&#x2F;password aren&#x27;t logging them in.<p>So a UX pattern is to actually lowercase the first letter on the backend.
评论 #32638424 未加载
评论 #32638857 未加载
评论 #32638422 未加载
评论 #32638447 未加载