•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
OK, I think I see what’s going on with this, in this configuration. The goal from an attacker’s perspective is to get this to be true: `$ret = crypt($pw, $hash); $ret == $hash` when called by OpenSSH’s sshd. This is how sshd validates that the user logging in knew the account password. The `$hash` is the “settings” to the crypt call and will normally look like “$6$--gibberish” for users with passwords set, but could look like “*” or “!” for users not intended to be able to login. The bug is from the intersection of all of these things: 1. musl can return “*” for errors, rather than leave the return value NULL. Other libc have adopted something like this too, but seem to use a different result “*0”. 2. musl can also return “+” for errors, but only does so if $hash starts with “*”. This is intended to eliminate the possibility of an error causing `$ret == $hash` to be true, however it assumes that applications calling `crypt()` will set $pw and $hash to values corresponding to the `$ret == $hash` comparison to be made immediately afterwards. 3. OpenSSH can be convinced to pass the hash of a different user if the hash is “*” or “!” to avoid timing attacks that can enumerate the user list, so it will set $pw and $hash to correspond to different users. $hash will be a real “$6$--gibberish” style hash in this case, and OpenSSH expects `crypt()` to either return NULL or return a hash string. But now there’s two hashes OpenSSH uses. It does: `$ret = crypt($pw, $hash2); $ret == $hash1`; 4. This should normally not be a problem because OpenSSH will pass in valid $pw and $hash2 that should not lead to errors in hashing, so the $ret that musl generates should be a real hash that cannot match the “*” or “!” $hash1 for the login-disabled user. However as a DDoS mitigation, musl will return error if the password is too long when using SHA-2-based hashes (the default, it seems). 5. This error will result in a non-NULL result of “*” or “+”. Since OpenSSH passed in a real hash ($hash2), musl will return “*”, which compares equal to the actual user hash $hash1 for the disabled-login user. The OpenSSL adjustment ensures a minimum hash length for the user before logging them in, even if crypt() succeeds somehow.
••••••••••••••••••••
That highlights a bigger point. In the age anyone can create and publish their own software, including people without the most basic knowledge about it, how is one supposed to distinguish good from bad and avoid drowning in a sea of crap? Also, this has another angle, let's say I've created some tools I've invested quite a bit of time in but what is the point of publishing it, if anyone that needs it can simply make it for themselves (spending a week or two of time and some tokens)? Not only it has became essentially impossible to find if a given thing is quality (for example I recently looked for a pi plugin that does tool use classification for AI that I could extend with my ideas. I found one, then I discovered the author copied leaked cloude code source and "released it under MIT license" - which made my work on top of it basically useless and I had to throw it all out and start from scratch, as I wanted to publish the result- the final thing is called adaptive-acl). And second, is there any point in publishing code? In the "old days" when software was worth something the motivation to publish open source, in addition to feel good factor, was that people would send you patches with functionality you may find useful. Both that and the feel good time has ended. I still publish some of my stuff that I think may be useful to someone at some point, but I'm not sure there is any actual point in this. In a way AI has made each of us much more self sufficient. A computer with a good local model and half a dozen GPUs, few TB of software and one can have all of their computing needs fulfilled forever. No Internet or other people required. There is certain power in this. My young pre-internet self would have felt like living in a star trek universe with this :-) But something is definitely being lost in the process as well.
•••••••••••••••••••••
 Top