this post was submitted on 23 Aug 2023
84 points (96.7% liked)

Programming

17322 readers
64 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

Why do so many companies and people say that your password has to be so long and complicated, just to have restrictions?

I am in the process of changing some passwords (I have peen pwnd and it’s the password I use for use-less-er sites) and suddenly they say “password may contain a maximum of 15 characters“… I mean, 15 is long but it’s nothing for a password manager.

And then there’s the problem with special characters like äàáâæãåā ñ ī o ė ß ÿ ç just to name a few, or some even won’t let you type a [space] in them. Why is that? Is it bad programming? Or just a symptom of copy-pasta?

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 67 points 1 year ago (3 children)

Is it bad programming?

With very few exceptions, yes. There should be no restrictions on characters used/length of password (within reason) if you're storing passwords correctly.

[–] [email protected] 40 points 1 year ago

And if a site does have such restrictions, it could be an indication that they store passwords in plaintext, rather than hashed

[–] [email protected] 18 points 1 year ago* (last edited 1 year ago) (3 children)

A very high max of something like 500 characters just to make sure you don't get DOSed by folks hitting your endpoint with huge packets of data is about the most I would expect in terms of length restrictions. I'm not a security expert or anything though.

[–] [email protected] 12 points 1 year ago* (last edited 1 year ago) (2 children)

That's a misunderstanding of DDoS. 0 byte packets are actually worse than large packets.

Which is why most DDoS (at least was) is extremely slow 0 byte requests until the server throttles/crashes under the number of requests.

E: Consider this. Are you more likely to throttle a bandwidth of terabytes/petabytes with couple million 1gb requests; or break it entirely by sending >4294967295 0 byte requests that effectively never stop being requested from the server?

[–] [email protected] 5 points 1 year ago (5 children)

It depends on what the DoS is targeting. If hashing is being done with an expensive hash function you can absolutely cause a lot of resource usage (CPU or memory depending on the hash) by sending long passwords. That being said this likely isn't a huge concern because only the first round needs to process the whole submitted data, the later rounds only work on the previous round's output.

Simple empty requests or connection opening attempts are likely to be stopped by the edge services such as a CDN and fleet of caches which are often over-provisioned. A targeted DoS attack may find more success by crafting requests that make it through this layer and hit something that isn't so overprovisioned.

So yes, many DoS attacks are request or bandwidth floods but this is because they are generic attacks that work on many targets. But that doesn't mean that all DoS attacks work this way. The best attacks target specific weaknesses in the the target rather than pure brute-force floods.

load more comments (5 replies)
[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

Very true and a good explanation of DDoS but I was talking about DoS generally, not specifically DDoS. In my (admittedly pretty limited) experience, a single mega request which is not blocked or rejected by your server can cause it to choke. If you don't have sufficient redundancy or if you get several of these requests coming through it can take down some of your backend services.

It's a good point though, there are lots of different attack vectors each fun in their own way that you need to watch out for.

[–] [email protected] 5 points 1 year ago* (last edited 1 year ago) (1 children)

Right, that's why I put the "within reason" in my comment. You still need to guard against malicious inputs so ultimately there is some max length limit, but it should be way beyond what a reasonable password length would be.

[–] [email protected] 7 points 1 year ago

My password is the bee movie script

[–] [email protected] 4 points 1 year ago

The best way to handle passwords IMO, is to have the browser compute a quick hash of the password, and then the server compute the hash of that. That way the "password" that is being sent to the server is always the same length.

[–] [email protected] 2 points 1 year ago (2 children)

Underappreciated fact: Bcrypt has a maximum of 72 bytes. It'll truncate passwords longer than that. Remember that UTF8 encoding of special characters can easily take more than one byte.

That said, this is rarely a problem in practice, except for some very long passphrases.

load more comments (2 replies)
[–] [email protected] 38 points 1 year ago (4 children)

And then there are times you set a password and everything just seems to work fine, but later the new password never works. You reset the password, try again and really focus because you think you made some mistake with the password manager. Again the password you set does not work.

You begin to google the problem and see that there is a max password lenght of 12. But you always set passwords of the lenght 20-30 and the interface never complained. But because you are desperate, you try just the first 12 characters of the last password you set. And it works!

I hate HP printers.

[–] [email protected] 14 points 1 year ago

You, you can add that list. Motherfuckers will let you type a password as long as you wish, only to internally truncate it. Was driving me crazy until I tried to log in on the mobile app, where it does prevent you to type more characters…

[–] [email protected] 5 points 1 year ago

This explains a whole lot…

[–] [email protected] 3 points 1 year ago

Old Steam calling.

Website and Client used different password rules, what worked for the other didn't in the other.

load more comments (1 replies)
[–] [email protected] 16 points 1 year ago* (last edited 1 year ago) (6 children)

I hope you're using a password manager, I recommend bit warden if not.

Password requirements are all attempts at getting people to introduce entropy into their passwords. The length the characters the not allowed characters the allowed characters. All about adding entropy

Restrictions on allowed characters tend to be based on legacy systems and the input state allow. So if you have an input system that only has Latin characters, it would be foolish to allow non-Latin characters into a password, because then people could get stuck unable to login. So typically they reduce to the safest set of characters that all of their systems use. And for some of the older systems that parse passwords, some of the Meta characters could be problematic.

Password length is also down to legacy systems. If you have an old school Solaris system somewhere in your back end, that truncates password fields at 15 characters. Then 15 characters is the max.

[–] [email protected] 4 points 1 year ago (1 children)

I agree. Bitwarden is open source and also provides a pretty good user experience. Now that passkey support is also coming, I like it even more. Currently a premium member. 10€/year isn't alot for a good service.

[–] [email protected] 2 points 1 year ago (1 children)

Plus you can self host if you want the save the $10 a year, but its worth it to support the ecosystem

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

Yes. Exactly. I don't know why anyone would prefer anything else over Bitwarden if they want a online password manager.

[–] [email protected] 3 points 1 year ago (1 children)

It feels like a lot of sites are taking active measures to block the use is password managers, too. I hate those sites. Why I'm the hell would you do that???

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago) (2 children)

Example please? This has not been my experience

[–] [email protected] 4 points 1 year ago

Prairie Centre Credit Union.

After years of complaining, they finally did something about their hopelessly insecure authentication, only to completely bork it.

Bitwarden could open the site, but couldn't push the login info. They prohibited pasting, so I had type everything by hand. And they couldn't even get that prohibition right, because I discovered that I could type a character then CTRL+V to paste, then HOME, DEL.

All of that is written past tense, because it was the last straw. I took my banking elsewhere, despite the fact I now have to drive 2.5 hours if I need to talk to someone in person.

[–] [email protected] 4 points 1 year ago (1 children)

Mainly financial sites, in my experience. I also have problems logging into Mastodon, because if I manually type my user and password I get logged in but if I use Bitwarden or even copy/paste it fails.

But also every site where you type in the user name and then submit and it takes you to enter the password - I use a lot of custom emails to avoid spam so I may not remember my username for a given site, but Bitwarden won't recognize it as a login page (much bigger problem on mobile, which is where I do most of my stuff).

[–] [email protected] 2 points 1 year ago

It's your browser. You can install JavaScript or a browser extension which disallows the no paste input field. So that you can always paste in.

The financial institutions that implement that they're trying to guard against local copy and paste password theft. Any program can have access to the clipboard. So I understand why they do it, and I understand why it's annoying.

For financial institutions I highly recommend using something like a Fido 2 key. I'm partial to the yubikey bioseries.

load more comments (2 replies)
[–] [email protected] 15 points 1 year ago (1 children)

Every time I find a site like this, I assume the programming is bad and the security is poor. (They don't know how to sanitize input? They don't know how to hash passwords?) It's a good reason to use random passwords on every site for when that one is compromised.

[–] [email protected] 2 points 1 year ago

What is "funny" is that I had the maximum password size thing on several bank websites (and a low one, at that). Fortunately, with 2FA, it doesn't really matter I guess.

[–] [email protected] 14 points 1 year ago* (last edited 1 year ago)

The new NIST guidance is to have something long. Special characters don't matter. So a good passphrase that you can remember > short line noise. NIST also recommends against constant password rotation, but to instead audit for dictionary attacks. See also: https://www.netsec.news/summary-of-the-nist-password-recommendations-for-2021/

Yes, it is bad programming. Of course, on the backend you must never store passwords in the clear. You should never grow your own hashing algorithm.

[–] [email protected] 14 points 1 year ago (5 children)

Yes its bad programing. These restrictions suggest that the company is either doing improper storage and processing, or does not understand how to deal with passwords.

The proper password storage is a hash. This is a cryptographic function that is easy to do and imbossible to undo. The hash function operates on the underlying binary representation of your password, and doesn't card what letters or symbols are in it. A program should take your password, hash it, and compare the result to the hash they have in their detebase.

The current recomended hash algorythm is called 'bcrypt'. Depending on the implementation, the input is between 50 and 70 bytes (the spec was a little unclear so people defined the inputs diferently, but the algorithe is the same). This means a password should be able to take at least 50 normal keyboard characters, including letters, symbols, and spaces. Anything less than that indicates a poor practice on behalf of the website.

(a lot of this is simplified. There is some variation and nuance that I don't think affects the main idea)

[–] [email protected] 4 points 1 year ago

Well we don't know how that website is actually storing the password. They may well be using a password hash. Also, you should use scrypt or argon over bcrypt IMO. And there should be no upper restrictions on password length. argon2 can handle hashing megabytes of data in about the same time as a short password, so there's never a need to limit the password length.

load more comments (4 replies)
[–] [email protected] 9 points 1 year ago (5 children)
[–] [email protected] 2 points 1 year ago

I'm always reminded of this when I see arbitrarily low caps on password character lengths.

Recently signed up on a site that limited passwords to 11 characters. Why? Like, seriously, why?

load more comments (4 replies)
[–] [email protected] 9 points 1 year ago

It is bad programming. Specifically it is very bad security (especially setting a maximum length - that is just ridiculous). I think websites should not rely too much on passwords anyway. They should be designed under the assumption that attackers will fairly commonly get access to user passwords, and therefore not let someone do too much damage from simply being able to login to your account.

[–] [email protected] 7 points 1 year ago (1 children)

Non-ASCII characters can cause troubles because of different encodings and because you may need to type them on a machine where corresponding keyboard layout is missing.

The password length limit is nothing short of stupid.

xkcd:936

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

My mother’s password for everything got compromised recently. I told her to think of a sentence that will never happen and to write it down and store it somewhere safe.

She remembered it instantly.

Oh, and I made her a password manager

[–] [email protected] 7 points 1 year ago (2 children)

Banks are the worst in this, the one website that should have secure passwords uses standards so low that KeePass can't even go so low. I have to use a password I can remember, which may not actually be of a low standard but is in this case, considering it's only 10 chars.

[–] [email protected] 7 points 1 year ago

Banks are the single industry most likely to be handing the passwords over to a 1970s mainframe that expects everything to be encoded in EBCDIC at some point in the validation sequence.

This is an explanation, not an excuse.

[–] [email protected] 6 points 1 year ago

That’s the digital equivalent to the key under the rock, but it’s the only rock on your porch.

[–] [email protected] 6 points 1 year ago

Is it bad programming

No, it's bad requirements, well ok maybe the programmer came up with the requirements too.

[–] [email protected] 6 points 1 year ago

Likely more bad design than bad programming, but that's not a very meaningful distinction.

It's downright scary how many "professionals" are onboard with this shit.

[–] [email protected] 2 points 1 year ago

My passwords use the full set of characters I can type by hand on a standard US qwerty keyboard, and I've only run into a few sites that have complained and made me use something simpler. PayPal is one of them. Some of the others are Zenni Optical, eBay, and FedLoan.

In total that's about 8% of my accounts. So the vast majority of sites seem to let you use whatever, at least. I only use 15 characters so I have no comments on length. I am equally annoyed when a new site makes me use simpler passwords.

[–] [email protected] 2 points 1 year ago (1 children)

I wish passphrase generators included foreign words. I’d like to mix my password with polish, Spanish, vietnamese, and Latin

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

Nguyễn, él quien tesseras 2 toczyl!

load more comments
view more: next ›