Python-PoC, das CVE-2026-123158 ausnutzt, eine OpenSSH-Passwortauthentifizierungs-Umgehung auf Alpine-musl-Systemen, mit Auto-Scan, Voraussetzungsprüfungen und Befehlsausführung nach dem Login.
OpenSSH-Passwort-Authentifizierungsumgehung unter Alpine Linux (musl libc)
CVSS 3.1: 8.1 (Hoch) · CWE-394 · Offenlegung: 2026-11-05
Melder: Özgün Kültekin (Wakefield)
Rechtlicher Haftungsausschluss
Dieses Repository dient ausschließlich Bildungszwecken, Sicherheitsforschung und Tests in autorisierten und kontrollierten Umgebungen. Die Verwendung dieses Materials gegen Systeme ohne ausdrückliche Genehmigung des Eigentümers ist illegal und unethisch. Der Autor übernimmt keine Verantwortung für jeglichen Missbrauch, Schaden oder rechtliche Konsequenzen, die sich aus der Verwendung dieses Inhalts außerhalb eines autorisierten Kontexts ergeben.
sshd unter Alpine Linux akzeptiert die Passwort-Authentifizierung für Konten ohne konfiguriertes Passwort (* in shadow), wenn der Angreifer ein Passwort sendet, das länger als 256 Bytes ist. Es sind keine vorherigen Berechtigungen erforderlich — Netzwerkzugriff auf den SSH-Port genügt.
Die Schwachstelle entsteht aus dem Zusammenspiel von drei unabhängigen Designentscheidungen:
┌──────────────────────────────────────────────────────────┐
│ 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 │
└──────────────────────────────────────────────────────────┘
Dies ist ein kritisches Detail, das in öffentlichen CVE-Quellen nicht dokumentiert ist.
Alpines sshd verwendet pick_salt() in xcrypt.c mit einem statischen Cache (salt_0). Die Umgehung erfordert genau zwei Versuche innerhalb derselben SSH-Verbindung:
| Versuch | pick_salt() | pw_password-Zustand | crypt() | Ergebnis |
|---|---|---|---|---|
| 1. | Führt getpwent/getspnam-Schleife aus → überschreibt musl-Statikpuffer | Beschädigt (zeigt auf Daten eines anderen Kontos) | "*" | strcmp("*", <beschädigt>) → FEHLSCHLAG |
| 2. | Cache salt_0 != '\0' → kehrt sofort zurück, kein getspnam() | Gültig: weiterhin "*" vom Zielkonto | "*" | strcmp("*", "*") == 0 → ERFOLG |
musl-Puffer-Aliasing: getspnam() verwendet einen einzigen globalen statischen Puffer für alle Aufrufe. Beim 1. Versuch ruft pick_salt() getspnam("hashuser") auf, um das Salt abzurufen, und überschreibt dabei den Puffer, auf den pw_password zeigt (der aus getspnam("victim") stammte). Beim 2. Versuch wird die Schleife übersprungen — Puffer unberührt → Exploit gelingt.
Der Exploit verwendet paramiko.Transport direkt, um beide Versuche innerhalb derselben SSH-Verbindung durchzuführen.
Binärdatei: sshd-session (ELF x86_64, OpenSSH 9.9p2, Alpine 3.21, mit Debug-Symbolen)
| Funktion | Adresse | Rolle |
|---|---|---|
sys_auth_passwd | 0x10f2e0 | Hauptprüfung — anfällige Bedingung |
xcrypt | 0x1a7720 | pick_salt hier inlined (war static) |
shadow_pw | 0x1a7700 | Ruft getspnam() auf — Puffer-Aliasing |
pick_salthat kein separates Symbol; der Compiler hat es inxcryptinlined.
sys_auth_passwd — anfällige Bedingung// 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 — statischer 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 "*"
| Bedingung | Alpine-Standard |
|---|---|
PasswordAuthentication yes | ja (Standard) |
UsePAM no (kein PAM) | ja (Standard, kein PAM installiert) |
Zielkonto mit * in shadow | ja (root seit Alpine 3.16; nur-Schlüssel-Konten) |
Mindestens ein weiteres Konto mit $5$/$6$-Hash | erforderlich für pick_salt() |
Nicht anfällig: glibc-Systeme (Debian/Ubuntu/RHEL), UsePAM yes, PasswordAuthentication no oder shadow ! (gesperrtes Konto).
* in shadow — reale Verbreitung| Konto | Kontext |
|---|---|
root | Alpine-Standard seit 3.16 (nur-Schlüssel-Anmeldung) |
alpine | Cloud-init-Standardbenutzer (AWS, GCP, Hetzner) |
ec2-user | Amazon Linux AMIs auf Alpine-Basis |
nobody, nginx, postgres | Von Paketmanagern ohne Passwörter erstellt |
≤ 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-Zweig | Gepatchte 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 | kein Patch verfügbar |
Upstream-Fix: OpenSSH 10.6p2 — auth-passwd.c lehnt eine Übereinstimmung ab, wenn das Shadow-Feld weniger als 4 Zeichen enthält.
# 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
Bestätigen Sie, dass die schlüsselbasierte Anmeldung funktioniert, bevor Sie die Passwortauthentifizierung deaktivieren.
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)