Any password over 256 bytes: how four reasonable changes unlocked musl sshd
On OpenSSH over musl libc, an account locked with "*" accepted any password of 257 to 1024 bytes. A walk through the code, line by line, and the four changes that had to line up.
Some bugs aren’t in any one line of code. Each program involved is doing something reasonable, and the bug sits in an assumption one of them makes about the other. *sshole, found by Ozgun Kultekin, is the clearest case of that I’ve read in a while.
The short version: on an OpenSSH server built against musl libc (Alpine, OpenWRT, Buildroot, Yocto, and a large share of container images), an account whose password is locked with * accepted any password between 257 and 1024 bytes long. It did not need a particular password. Any long one worked. On Alpine that account is root.
I wanted to know exactly why, so I read the code on both sides: OpenSSH’s password check and musl’s crypt(). Below I go through it in the order a login runs. The bug is public and already fixed. I’m writing it up for the mechanism, because nothing about it is specific to sshd.
What a locked account is
Unix does not store your password. It stores a one-way hash of it in /etc/shadow:
alice:$6$abc123$k2P9...:20000:0:99999:7:::$6$ names the algorithm (SHA-512-crypt), abc123 is the salt, and the long tail is the hash. To check a login, the system hashes the typed password with the same $6$abc123$ prefix and compares the result to the stored string. If they are equal, you knew the password.
To lock an account, you put something in that field that is not a hash at all. The convention since 3BSD in 1980 is a single *:
root:*:20000:0:99999:7:::Every hash crypt() produces starts with $6$, $5$, $2b$, or is a 13-character DES string. None of them is *, so the comparison can never succeed, whatever the password. Key logins still work, because they never look at this field. That is what “locked” means, and it has held for forty years.
One detail matters later: the result of crypt() and the stored field are compared as plain strings. The check does not know that * means “locked”. It only knows that two strings are or are not equal.
What sshd does with your password
When UsePAM is off, OpenSSH checks passwords in sys_auth_passwd() in auth-passwd.c. Here is the core, trimmed, as it stood before the fix (4353fdc4, the left-hand side of the diff):
/* Just use the supplied fake password if authctxt is invalid */char *pw_password = authctxt->valid ? shadow_pw(pw) : pw->pw_passwd; // the stored field, e.g. "*"
/* * Encrypt the candidate password using the proper salt, or pass a * NULL and let xcrypt pick one. */if (authctxt->valid && pw_password[0] && pw_password[1]) salt = pw_password;encrypted_password = xcrypt(password, salt);
return encrypted_password != NULL && strcmp(encrypted_password, pw_password) == 0;Look at the if. sshd only uses the stored field as the salt when it is at least two characters long. A real hash always is. A * is not: pw_password[1] is the terminating \0, so salt stays NULL.
It was not always like this. Before July 2016, a short field got a hard-coded fallback:
/* Encrypt the candidate password using the proper salt. */encrypted_password = xcrypt(password, (pw_password[0] && pw_password[1]) ? pw_password : "xx");"xx" selects traditional DES, which only reads the first 8 characters of a password and never fails on length. A locked account hashed this way could never match *, however long the password was.
That changed with the fix for CVE-2016-6210, in 9286875a. For usernames that did not exist, sshd hashed with a fake salt whose algorithm differed from the one real accounts used. The timing difference, which long passwords made easier to measure, leaked which usernames existed. The fix replaced the "xx" fallback with salt = NULL, which makes xcrypt() call a new pick_salt() that returns a realistic salt from the system itself. The first version only looked at root. A week later, dbf788b4 made it keep searching when root is locked:
/* * Pick an appropriate password encryption type and salt for the running * system by searching through accounts until we find one that has a valid * salt. Usually this will be root unless the root account is locked out. * If we don't find one we return a traditional DES-based salt. */pick_salt() walks /etc/passwd, reads each account’s shadow entry, and takes the prefix of the first one that looks like $id$salt$. If it finds none, it falls back to "xx", an old DES salt.
Note the part about usually this will be root unless the root account is locked out. On Alpine, root is locked, so the walk moves on and borrows the salt from the first account that has a real password.
So when someone tries a password for root on an Alpine box, sshd does not hash it against *. It hashes it as SHA-512 with alice’s salt, then compares the result with *. Normally that is still safe: the result is a $6$... string, and $6$... is not *.
What musl does when hashing fails
crypt() comes from the C library. POSIX says that on failure it returns NULL. That’s easy to get wrong. Plenty of code passes the result straight to strcmp() and crashes on NULL. A crash is bad, but at least nobody gets logged in.
musl chose differently. Its crypt() never returns NULL. When hashing fails, it returns a short string that is not a valid hash, so careless callers do not crash. The SHA-512 implementation says so in its header, on error “*” is returned, and the wrapper does exactly that:
char *__crypt_sha512(const char *key, const char *setting, char *output){ ... p = sha512crypt(key, setting, output); ... if (!p || ...) return "*"; return p;}Now, when does sha512crypt() fail? SHA-512-crypt does more work the longer the password is, so a server that hashes whatever it receives can be made to burn CPU. musl added a cap to prevent that:
/* key limit is not part of the original design, added for DoS protection. */#define KEY_MAX 256
/* reject large keys */for (i = 0; i <= KEY_MAX && key[i]; i++);if (i > KEY_MAX) return 0;A password of 257 bytes or more makes sha512crypt() return 0. The wrapper turns that into "*".
The original 2012 change, b3c4cc12, shows musl saw this collision coming. In the DES code it did not always return "*":
return (setting[0]=='*') ? "x" : "*";If the salt passed in was itself *, musl returned "x" instead, so a failed hash could never equal a stored *. That guard only works if the caller passes the stored field as the salt. sshd passes alice’s salt instead, so the guard never sees the *.
Both decisions make sense on their own. Returning "*" instead of NULL means nothing crashes, and "*" can never match a real hash. The 256-byte cap stops a denial-of-service. The trouble is that "*" isn’t a neutral value: to anything that reads /etc/shadow, it means locked.
Four changes, ten years apart
Here are the pieces in the order they landed. Different people made each one, in different projects, and each had a good reason.
- Aug 2012, musl (
b3c4cc12):crypt()returns an unmatchable string on failure instead ofNULL, so callers that skip theNULLcheck do not crash. - Aug 2012, musl (
88bf5a8a): the new SHA-256/512-crypt reject keys longer than 256 bytes to block a CPU denial-of-service, and return"*"when they do. - Jul 2016, OpenSSH (
9286875a,dbf788b4): for CVE-2016-6210, accounts with no usable hash borrow a real salt from another account instead of using DES"xx". - Dec 2021, Alpine (
fbe926af, released in 3.16): root is locked with*instead of!. Earlier, CVE-2019-5021 showed that Alpine images had shipped with an empty root password.!fixed that but also broke key logins for root when PAM was not in use, so Alpine switched to the classic*.
I don’t think a reviewer could have caught any of these. The bug only exists when all four end up on the same machine.
Putting it together
Now trace a login as root on an Alpine box running sshd without PAM, with a 300-byte password:
- sshd reads root’s stored field:
*. *is one character, sosalt = NULLandxcrypt()callspick_salt().pick_salt()skips locked root and returnsalice’s prefix,$6$abc123$.- musl sees
$6$and runssha512crypt(). The key is 300 bytes, which is overKEY_MAX, so it returns0. - The wrapper turns that failure into
"*". - sshd runs
strcmp("*", "*"). They are equal. - The login is accepted. You are root.
Now repeat it with a 20-byte password. Steps 1 to 3 are identical. At step 4, sha512crypt() succeeds and returns a real $6$abc123$... hash, which does not equal *, and the login is refused. The only thing that changed is the length.
There is also a ceiling. Before any of this, sshd’s auth_password() rejects passwords longer than MAX_PASSWORD_LEN, which is 1024 bytes. So the window is 257 to 1024 bytes: long enough to trip musl’s cap, short enough to get past sshd’s.
So it comes down to one character meaning two things. In musl, * means hashing failed. In /etc/shadow, it means this account is locked. sshd compared the two without knowing about either meaning.
Why each condition matters
Each condition on the affected list comes from a specific line above, and removing any one of them breaks the chain:
| Condition | Why it is needed |
|---|---|
| sshd built on musl | On glibc or libxcrypt, a long key either hashes normally or fails with NULL or *0. sshd checks for NULL, and *0 is not *. Only a library that returns exactly * lines up. |
| PAM off | With PAM, the password is checked by pam_unix, not by sys_auth_passwd(). Alpine’s openssh-server does not use PAM by default. |
| Password auth on | Without it, sshd never calls sys_auth_passwd(). On is the default. |
A target account stores * |
A one-character field is what sends sshd to pick_salt(), and * is what the failure value has to match. |
Another account has a real $id$ hash |
Without one, pick_salt() falls back to "xx", which selects traditional DES. DES only uses the first 8 characters, so a long password still produces a real 13-character hash, and the login is refused. |
That last row is the surprising one. A fresh Alpine box where nobody has set a password has nothing to borrow from, so it is safe. The box only becomes vulnerable once someone adds a normal user with a password, which is exactly what happens on real servers.
glibc distributions, anything using PAM, Dropbear, and OpenBSD are not affected. One case is much worse: on Alpine’s official AWS and Azure images, the default alpine user has passwordless doas, so getting into that account means getting root.
Why it took ten years to notice
All the ingredients existed by 2016. Root as * on Alpine arrived in 2022. Even then, no one noticed for four years:
- Nobody tests this combination. OpenSSH is developed and tested on OpenBSD and glibc. musl does not run sshd in its tests. Each project’s CI passed, and the bug lives only where they meet.
- Most of Linux uses PAM.
pam_unixchecks locked accounts on its own and never reaches this code. - Nobody types a 300-byte password by accident. Ordinary failed logins, even millions of them from brute-force bots, use short passwords and get refused correctly.
- The warning signs pointed elsewhere. A 2013 Debian discussion covered
crypt()returningNULL. A 2024 musl mailing-list thread covered busyboxpasswdfailing on 257-character passwords. Both were about failure, and neither asked what the failure value would be compared against.
Kultekin found it the slow, careful way: building sshd against glibc and musl, with and without PAM, with and without shadow, and sending each build about 17,600 unusual logins. Every build agreed except one, musl without PAM, which accepted logins it should have refused. That’s what I like about differential testing. You don’t need to guess where the bug is.
The fix, and what to do
Damien Miller fixed it in 4353fdc4 on November 4, 2026, with one more condition in the final comparison:
#define MIN_PASSWORD_HASH_LEN 4#define MAX_PASSWORD_LEN 1024... return encrypted_password != NULL && ret = encrypted_password != NULL && strlen(pw_password) >= MIN_PASSWORD_HASH_LEN && strcmp(encrypted_password, pw_password) == 0;The commit message says plainly where the OpenSSH team thinks the bug is: “We do not consider the root cause to be within OpenSSH.”
A stored field too short to be a real hash can no longer match anything, whatever crypt() returns. That closes the hole in sshd, whichever C library is underneath. I think sshd is the right place for it anyway, because the caller is the one that knows a one-character field can’t be a hash.
Update OpenSSH. According to Kultekin’s write-up, the fix is in OpenSSH 10.6p2. On Alpine:
apk upgrade opensshIf you can’t update yet, turn off password logins. On anything facing the internet you probably want this anyway:
echo "PasswordAuthentication no" > /etc/ssh/sshd_config.d/00-no-passwords.confrc-service sshd restartWith no password authentication, sshd never calls sys_auth_passwd(), so the whole chain is gone.
Check whether it was used against you. In your auth logs, look for an Accepted password line for an account whose shadow field is *. That should never happen, so treat any match as a compromise. Kultekin published a checker at github.com/oz9un/sshole.
What I’m taking from it
I’d have approved every change in this chain. Returning a sentinel instead of NULL, capping key length, hiding which usernames exist, locking root: they’re all defensive moves, and together they let anyone in with a long enough password.
What went wrong is a sentinel value crossing a boundary. Inside musl, "*" is a safe failure value because it is not a hash. musl cannot know that the caller will compare it with a field where "*" means something else. Inside sshd, comparing two strings for equality looks like the most obvious check there is, and nothing in the code says that one side might be an error code.
Now when I write a magic value in my own code (-1, "", 0, "*"), I try to ask who else will end up holding it, and whether it already means something to them.
References
- O. Kultekin, “*sshole,” Nov. 2026.
- O. Kultekin, sshole: detection tooling, GitHub repository, 2026.
- D. Miller, “avoid password authn bypass,” OpenSSH Portable, commit
4353fdc4, Nov. 4, 2026. - D. Tucker, “Determine appropriate salt for invalid users,” OpenSSH Portable, commit
9286875a, Jul. 15, 2016. - D. Tucker, “Search users for one with a valid salt,” OpenSSH Portable, commit
dbf788b4, Jul. 21, 2016. - R. Felker, “make crypt return an unmatchable hash rather than NULL on failure,” musl libc, commit
b3c4cc12, Aug. 9, 2012. - R. Felker, “add sha256/sha512 crypt,” musl libc, commit
88bf5a8a, Aug. 29, 2012. - A. Xu, “scripts/genrootfs.sh: locked -> invalid password,” Alpine aports, commit
fbe926af, Dec. 10, 2021. - OpenSSH Portable,
auth-passwd.candopenbsd-compat/xcrypt.c, source at commit4353fdc4. - musl libc,
src/crypt/crypt_r.candsrc/crypt/crypt_sha512.c, source at commit7813e911. - MITRE, “CVE-2016-6210,” CVE record, 2016.
- MITRE, “CVE-2019-5021,” CVE record, 2019.