
Python PoC exploiting CVE-2026-123158, an OpenSSH password authentication bypass on Alpine musl systems, with auto-scan, precondition checks, and post-login command execution.
OpenSSH Password Authentication Bypass on Alpine Linux (musl libc)
CVSS 3.1: 8.1 (High) · CWE-394 · Disclosure: 2026-11-05
Reporter: Özgün Kültekin (Wakefield)
Legal Disclaimer
This repository is intended solely for educational purposes, security research, and testing in authorized and controlled environments. Using this material against systems without explicit permission from the owner is illegal and unethical. The author assumes no responsibility for any misuse, damage, or legal consequences resulting from the use of this content outside an authorized context.
sshd on Alpine Linux accepts password authentication for accounts with no password configured (* in shadow) when the attacker sends a password longer than 256 bytes. No prior privileges are required — network access to the SSH port is sufficient.
The vulnerability arises from the interaction of three independent design decisions:
┌──────────────────────────────────────────────────────────┐
│ 1. musl libc — crypt() returns "*" on failure │
│ (glibc returns NULL; no ambiguity) │
│ │
│ 2. musl SHA-512 — KEY_MAX = 256 bytes │
│ password > 256B → crypt() fails → returns "*" │
│ │
│ 3. OpenSSH (CVE-2016-6210 patch) — anti-enumeration │
│ sshd ALWAYS calls crypt() even for no-password accts │
│ using a salt "borrowed" from another account │
│ │
│ RESULT: │
│ crypt("A"×300, real_salt) → "*" ← musl failure │
│ strcmp("*", "*") → 0 ← no-password acct │
│ LOGIN ACCEPTED │
└──────────────────────────────────────────────────────────┘
This is a critical detail not documented in public CVE sources.
Alpine's sshd uses pick_salt() in xcrypt.c with a static cache (salt_0). The bypass requires exactly two attempts within the same SSH connection:
| Attempt | pick_salt() | pw_password state | crypt() | Result |
|---|---|---|---|---|
| 1st | Runs getpwent/getspnam loop → overwrites musl static buffer | Corrupted (points to another account's data) | "*" | strcmp("*", <corrupted>) → FAIL |
| 2nd | Cache salt_0 != '\0' → returns immediately, no getspnam() | Valid: still "*" from target account | "*" | strcmp("*", "*") == 0 → SUCCESS |
musl buffer aliasing: getspnam() uses a single global static buffer for all calls. On the 1st attempt, pick_salt() calls getspnam("hashuser") to retrieve the salt, overwriting the buffer that pw_password points into (which came from getspnam("victim")). On the 2nd attempt, the loop is skipped — buffer untouched → exploit succeeds.
The exploit uses paramiko.Transport directly to perform both attempts within the same SSH connection.
Binary: sshd-session (ELF x86_64, OpenSSH 9.9p2, Alpine 3.21, with debug symbols)
| Function | Address | Role |
|---|---|---|
sys_auth_passwd | 0x10f2e0 | Main gate — vulnerable condition |
xcrypt | 0x1a7720 | pick_salt inlined here (was static) |
shadow_pw | 0x1a7700 | Calls getspnam() — buffer aliasing |
pick_salthas no separate symbol; the compiler inlined it insidexcrypt.
sys_auth_passwd — vulnerable condition// victim has shadow "*" → pw_password = "*"
char *pw_password = shadow_pw(pw);
// GATE: pw_password[1] == '\0' ← for "*" (len=1) → condition FALSE
// salt stays NULL → xcrypt() calls pick_salt()
if (authctxt->valid && pw_password[0] && pw_password[1])
salt = pw_password; // NOT executed
else
salt = NULL; // vulnerable path
encrypted_password = xcrypt(password, salt);
return strcmp(encrypted_password, pw_password) == 0; // strcmp("*","*") → LOGIN ACCEPTED
xcrypt — static cache salt_0if (salt == NULL) {
if (salt_0 == '\0') { // 1st call: populate cache
setpwent();
do {
pw = getpwent();
pcVar1 = shadow_pw(pw); // getspnam() → overwrites musl static buffer!
} while (*pcVar1 != '$');
strlcpy(&salt_0, pcVar1, len);
explicit_bzero(pcVar1, strlen(pcVar1));
endpwent();
}
// 2nd call: salt_0 != '\0' → skips loop, no getspnam()
salt = &salt_0;
}
return crypt(password, salt); // musl: len > 256 → returns "*"
| Condition | Alpine default |
|---|---|
PasswordAuthentication yes | yes (default) |
UsePAM no (no PAM) | yes (default, no PAM installed) |
Target account with * in shadow | yes (root since Alpine 3.16; key-only accounts) |
At least one other account with $5$/$6$ hash | required for pick_salt() |
Not vulnerable: glibc systems (Debian/Ubuntu/RHEL), UsePAM yes, PasswordAuthentication no, or shadow ! (locked account).
* in shadow — real-world prevalence| Account | Context |
|---|---|
root | Alpine default since 3.16 (key-only login) |
alpine | Cloud-init default user (AWS, GCP, Hetzner) |
ec2-user | Amazon Linux AMIs based on Alpine |
nobody, nginx, postgres | Created by package managers without passwords |
≤ 256 bytes → rejected (crypt() works, returns real hash)
257–1024 → ACCEPTED (crypt() fails at KEY_MAX, returns "*")
≥ 1025 → rejected (OpenSSH MAX_PASSWORD_LEN = 1024)
| Alpine branch | Patched version |
|---|---|
| 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.16 | no patch available |
Upstream fix: OpenSSH 10.6p2 — auth-passwd.c rejects a match when the shadow field is fewer than 4 characters.
# Alpine — update openssh and restart daemon
apk upgrade -U -a
rc-service sshd restart # mandatory — installing alone does not replace the running process
# Without updating — disable PasswordAuthentication
echo "PasswordAuthentication no" > /etc/ssh/sshd_config.d/disable-pw.conf
sshd -t && rc-service sshd restart
Confirm key-based login works before disabling password authentication.
usage: exploit.py (--single IP | --list FILE) [--port N] [--user NAME]
[--auto] [--scan] [--check] [--workers N] [--output FILE]
[--cmd CMD] [--size N] [-v] [-h]
required:
--single IP Single target (e.g. 192.168.1.10)
--list FILE IP list file (one per line; supports IP:port)
--port N SSH port (default: 22)
--user NAME Target user (not required with --auto)
operation mode (default: direct exploit):
--auto Test common accounts with '*' in shadow: root, alpine,
ec2-user, nobody, nginx, postgres
--scan Map the password size boundary (requires --user)
--check Check preconditions without exploiting (requires --user)
optional:
--workers N Parallel workers for --list (default: 1; recommended: <= 20)
--output FILE Save vulnerable results to .txt (append; skips non-vulnerable)
--cmd CMD Command to run after login (default: id)
--size N Oversized password length (default: 300; range: 257-1024)
-v, --verbose Verbose output with technical mechanism details
-h, --help Show this message and exit
examples:
# auto-scan a single target (tests common accounts)
python3 exploit.py --single 192.168.1.10 --port 22 --auto