A recent security finding, highlighted on the website sshhole.com, identifies a vulnerability stemming from a change in the musl C library. The musl library, which is the default C library for Alpine Linux, modified the behavior of the `crypt()` function. Previously, the function would return NULL if it encountered an error. However, in the updated implementation, the function now returns a single character instead of NULL upon failure. This change was reportedly made to accommodate programs that do not properly check for NULL returns, but it introduces a security risk in specific configurations.
This behavior specifically affects systems that do not use Pluggable Authentication Modules (PAM). In these environments, a system might attempt to authenticate a user by comparing the output of the `crypt()` function against a stored password hash. If an attacker provides a password that causes the `crypt()` function to fail, the function now returns a single character. If that character happens to match the first character of the stored hash, the authentication check may succeed. This is particularly relevant for systems using long passwords, where the first character of the hash is a predictable target. Commenters on Hacker News noted that while many systems use PAM to handle authentication, certain configurations—particularly those in Docker containers—might still be vulnerable.
The practical implications of this finding are most significant for the large ecosystem of Docker containers built on Alpine Linux. While only a small minority of these containers might run OpenSSH with password authentication enabled without PAM, the sheer volume of Alpine-based images means that even a small percentage can represent a large number of vulnerable targets. To remediate the issue, users are advised to either disable password authentication by setting `PasswordAuthentication=no` in their SSH configuration or to update their systems to a patched version. The discovery has also sparked a debate regarding the musl developers' decision to prioritize 'convenience' over strict adherence to POSIX standards in core cryptographic functions.
