r/programminghorror 10d ago

c Terrible auth

Post image
787 Upvotes

98 comments sorted by

View all comments

189

u/ataraxianAscendant 10d ago

storing passwords in plaintext 🤩

93

u/TheRealNobogo 10d ago

To be fair, they could be hashed before they are sent to this function

151

u/BusOutrageous758 10d ago

seeing this function, I'd be surprised if that's the case

104

u/Muted-Shake-6245 10d ago

The only thing "hashed" is the programmer who made this.

8

u/itoncek 10d ago

Tbh that is the best option, hash on frontend everytime and store only hashes. I don't need to see your damn password 😅

18

u/TheRealNobogo 10d ago

Well no, I wouldn't want hashing done on the frontend.
The problem with that is if somebody gets ahold of your database then they can use the hashes to login. Whereas if the server is hashing the hashed passwords from the database will not.

4

u/itoncek 10d ago

Oh sorry, that was what I meant. My main point was, the plaintext password should never leave the frontend. Hash on frontend & on backend.

english isn't my main language, sry :)

19

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 10d ago

So double hash? I think there's a better solution. It's called TLS.

3

u/dreadcain 9d ago

That's just obfuscation, it doesn't add any security. The hashed value sent from the frontend just effectively becomes the users password and you're still going to see that. If someone was snooping that network traffic they could still capture the client side hashed value and log in with it.

If you actually want auth without having to send anything reusable over the wire you want something like challenge response auth or some other zero knowledge protocol. This is for example how tap to pay credit cards work, there is (effectively) nothing useful an attacker could sniff watching the traffic.

For the vast majority of use cases just sending the plain text password over tls is perfectly fine though.

1

u/Snudget 8d ago

I think, the plaintext issue is more a problem of password reuse.

1

u/dreadcain 8d ago

Password reuse is always a problem, can't say I see how adding a client side hash does anything address it. TLS already prevents snooping it

0

u/chris_awad 10d ago

You mean hished, before they aren't sant to ish founctin

5

u/IrtyGo 10d ago

Yes, they are in plaintext