Hacker News
Alpine Linux Security Advisory: OpenSSH-server password authentication bypass
NewJazz
|next
[-]
Does anyone know why musl does this? Are they the only C library that behaves this way?
For a C library that famously tries to adhere to POSIX as much as possible, this seems like a crazy choice. From POSIX standard:
Upon successful completion, crypt() shall return a pointer to the encoded string. The first two bytes of the returned value shall be those of the salt argument. Otherwise, it shall return a null pointer and set errno to indicate the error.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/c...
hnfong
|root
|parent
|next
[-]
worksonmine
|root
|parent
|next
|previous
[-]
cyphar
|root
|parent
[-]
Though I am surprised that all of the code examples do not use constant-time strcmp(). Actually, I wonder if even constant-time strncmp() would still leak information about whether the account is disabled because in that case both arguments are much shorter? Food for thought.
But yeah, the crypt(3) API is very 80s C, the man page even features a lengthy description of a long-deprecated and utterly broken hashing algorithm using DES that is even implied to be broken in the text itself (and the warning message is so old it refers to "parallel computers" as though they were a new concept). Given that the default mode is to use a broken hashing algorithm, I'm shocked anyone actually uses the libc crypt(3) -- surely it's trivial to just write your own that isn't awful...?
mik1998
|root
|parent
[-]
0x457
|next
|previous
[-]
slopinthebag
|next
|previous
[-]
my-huge-pony
|root
|parent
|next
[-]
Not every C vuln is a memory safety problem.
realharo
|root
|parent
|next
[-]
In Rust, the type of the return value would be a `Result<T, E>`, which means the chain of events that led to this would never have started in the first place.
my-huge-pony
|root
|parent
[-]
Edit: at the beginning, crypt always returned a value. So hypothetical Rust return type would be a String, and then it would be retained for backward compatibility. Or something else would happen, this is a complex logic bug triggered by a 25 year old chain of events.
realharo
|root
|parent
[-]
That's what led some people to write code where it crashes without checks. Which is still their mistake. But if the type was something that can't be implicitly used like an always-present value, that would have prevented the situation, even with those same people.
oguz-ismail2
|root
|parent
|next
|previous
[-]
slopinthebag
|root
|parent
[-]
what will it take to move away from c? older devs retiring. Planck said that "science advances one funeral at a time" and i fear it will be the same for software.