SSH situation is insane | Low Level
The Gist
A critical OpenSSH flaw in Alpine Linux allows root access by inputting passwords longer than 256 characters, exploiting a historical hash comparison error.
Quick Overview
Alpine Linux and musl libc contain a severe SSH vulnerability where supplying a password over 256 characters tricks the system into comparing error returns against invalid credentials. Ozgun Kultekin discovered this vulnerability, which affects default Alpine Docker images lacking PAM and utilizing traditional password authentication. Emergency fixes have been issued for OpenSSH and musl libc, but the underlying issue stems from a coding practice introduced in 1980.
Key Points: Ozgun Kultekin discovered the vulnerability, which is tracked on sshhole.com and affects specific Linux distributions using musl libc. The vulnerability allows unauthorized root access if a password exceeds 256 characters on vulnerable systems. The core issue stems from the cryptsha512 implementation in musl libc returning the star character instead of null upon a cryptographic failure. Systems using glibc are unaffected by this bug because glibc handles password hashing and error conditions differently. Alpine Linux Docker images are particularly vulnerable because they ship with password logins enabled and PAM disabled by default. The flaw allows an attacker to bypass authentication by providing a long password when targeting an account that lacks a password while another account has a valid password hash. This behavior traces back to a 1980 Unix decision by Bill Joy where the star character was used to denote accounts without valid passwords.
Context: Secure Shell (SSH) is a standard protocol used for secure remote login and other network services on Unix based operating systems. Musl libc is a lightweight alternative to the standard GNU C Library, commonly found in containerized environments like Alpine Linux.
Detailed Analysis
The vulnerability relies on a cascading failure involving password length limits and error handling in the musl libc cryptography library. When a user attempts to log in via SSH, the system runs a hash check against the shadow file. If the input exceeds the 256 character key maximum specified by KEYMAX, the cryptsha512 function returns zero. Because older implementations returned null for errors, but musl libc was modified to return a star character, the system mistakenly compares the error symbol against stored password hashes. When an account with a star password exists alongside an account with a real password, supplying a long string forces a successful match due to this flawed comparison logic.