In the world of containerization and minimalist Linux distributions, Alpine Linux has long been the gold standard. Its tiny footprint—often under 5MB for a base image—makes it the preferred choice for Docker enthusiasts and DevOps engineers looking to reduce their attack surface and optimize resource usage. However, the very minimalism that makes Alpine attractive relies on a specific set of tools, most notably the musl C library. For over a decade, a subtle interaction between musl and the ubiquitous OpenSSH daemon (sshd) hid a critical authentication bypass.

This vulnerability, colloquially known as the “Asterisk” flaw, allows an attacker to bypass password authentication entirely under specific conditions. Unlike many modern exploits that require complex heap sprays or ROP chains, this bypass is triggered by something remarkably simple: a password string longer than 256 characters. When targeted against an account locked with a single asterisk (*) in the system’s shadow file, the authentication mechanism fails open, granting a 100% success rate for unauthorized access.

The discovery of this flaw serves as a stark reminder that security is often found in the “glue” between components rather than the components themselves. While OpenSSH is hardened and musl is designed for correctness, their combined logic created a loophole that remained undetected for nearly ten years. For systems running Alpine-based microservices, IoT firmware, or edge routers, understanding this interaction is critical to securing the modern stack.

The Shadow of the Asterisk: Understanding Account Locking

To understand how this bypass works, we must first look at how Linux handles user authentication and account locking. In a standard Linux environment, user credentials are not stored in /etc/passwd. Instead, they reside in /etc/shadow, a file accessible only by the root user.

The Structure of /etc/shadow

Each line in the shadow file contains several fields separated by colons. The second field is the most important: the encrypted password hash. A typical entry looks like this:

jdoe:$6$rounds=5000$saltsalt$hashedpassword...:19000:0:99999:7:::

When a user attempts to log in, the system takes the provided password, combines it with the “salt” (the $saltsalt portion), hashes it using the specified algorithm (indicated by $6$ for SHA-512), and compares the result to the stored hash.

The Role of ‘*’ and ‘!’

System administrators often need to disable or lock accounts. This is common for system services (like bin, daemon, or nobody) that should never have an interactive login. Traditionally, two characters are used in the password field to signify a locked state:

  1. Exclamation Point (!): Usually indicates the account is locked (e.g., via passwd -l).
  2. Asterisk (*): Usually indicates the account has no valid password and cannot be used for password-based login.

The crypt() function, which is the standard C library interface for password hashing, is designed to handle these placeholders. If crypt() sees a * or a !, it should fail to produce a matching hash for any input, because these characters do not conform to the expected format of a valid hash string (which typically begins with a $ and contains specific delimiters).

For years, developers assumed that an asterisk was an unbreakable barrier. If the shadow file said *, no password—no matter how complex—could ever match. However, this assumption relied on the crypt() function behaving predictably across all C library implementations.

The Technical Breakdown: Salt Borrowing and musl libc

The vulnerability is not found in a single line of broken code, but in a logical intersection between how OpenSSH handles “non-existent” or “locked” accounts and how musl libc processes long strings.

The Mechanism of ‘Salt Borrowing’

OpenSSH’s sshd is designed to be resistant to timing attacks. In a timing attack, an attacker could potentially distinguish between a valid username and an invalid one by measuring how long the server takes to respond. Hashing a password takes CPU time; if sshd rejected an invalid username immediately without hashing the password, the response would be faster than if it had to hash a password for a real user.

To mitigate this, sshd uses a technique often called “salt borrowing.” If a user attempts to log in to an account that does not exist, or an account that has no valid hash (like one marked with *), sshd still performs a hashing operation to simulate a real authentication attempt. It “borrows” a salt from a dummy record or the existing placeholder to ensure the computation time remains consistent.

musl libc vs. glibc

Most Linux distributions (Ubuntu, CentOS, Debian) use glibc (the GNU C Library). Alpine Linux, however, uses musl libc. While glibc is feature-rich and large, musl is designed to be lightweight and strictly compliant with standards.

The divergence occurs in the implementation of the SHA-256 and SHA-512 hashing algorithms within the crypt() function. When sshd passes a password and a “salt” (in this case, the * from the shadow file) to musl’s crypt(), the library attempts to process the input.

In glibc, if the salt provided is not a validly formatted hash string, the function typically returns a null pointer or a failure. In musl, the library was designed to be more permissive in how it handled certain inputs to maintain performance and simplicity.

The 256-Character Trigger: Why Length Matters

The specific “trigger” for this vulnerability is the length of the input password. Within musl’s internal implementation of SHA-based crypt, there is a buffer limit of 256 characters for the input string.

The Logic Failure

When an attacker provides a password string exceeding 256 characters, musl’s internal hashing logic encounters a specific state. Instead of returning a standard error or a null value, the function’s internal state causes it to return a string that, under very specific circumstances, matches the placeholder it was given.

When sshd performs the comparison:

  1. It retrieves the “hash” from /etc/shadow, which is *.
  2. It calls crypt(long_password, "*").
  3. Due to the buffer limit and the logic in older versions of musl, the function returns a value that effectively validates against the *.

This results in sshd believing the password is correct. Because the comparison returns “true,” the authentication bypass is successful. This is particularly dangerous because it doesn’t require any knowledge of the system’s actual passwords; the attacker simply needs to find an account marked with * and send a very long string.

100% Success Rate

In a typical brute-force attack, success is probabilistic. Here, the success is deterministic. If the account is configured with * and the system uses a vulnerable version of musl without PAM (Pluggable Authentication Modules) intervention, the exploit works every single time in a single connection attempt.

Feature glibc Behavior musl Behavior (Vulnerable)
Invalid Salt Handling Returns error/null for * Attempts to process
Input Limit Handles long strings gracefully Logic error at >256 chars
Bypass Potential Low/None High (against * accounts)

This vulnerability is reminiscent of other logic-based bypasses where the “failure” state of a security function is incorrectly interpreted as a “success.” For those interested in how similar logic flaws can affect enterprise systems, our analysis of the JFrog Artifactory bypass explores how identity token validation can be subverted.

Impact Analysis: From IoT to the Cloud

The impact of the Asterisk vulnerability is widespread, primarily due to the ubiquity of Alpine Linux in modern infrastructure.

Docker Containers and Microservices

Alpine is the base image for thousands of official Docker images, including Nginx, Redis, and Node.js. While many containers do not run an SSH daemon (following the “one process per container” philosophy), those that do—such as “jump boxes,” development environments, or legacy applications ported to containers—are at extreme risk.

If a containerized Alpine system has sshd enabled and contains system accounts like bin, daemon, or adm (which almost always default to * in the shadow file), an attacker who can reach the SSH port can gain shell access to the container. From there, they can attempt to escape the container or pivot into the internal network.

IoT and Embedded Devices

The IoT sector is perhaps the most vulnerable. Routers, smart cameras, and industrial controllers often use Alpine or custom musl-based distributions to save flash memory space. These devices frequently expose SSH for remote management. Because these devices are rarely updated by end-users, the “decade-old” nature of this flaw means there are likely millions of devices currently sitting on the public internet that are vulnerable to a simple long-string password attack.

System Accounts as Targets

The primary targets are not usually the “root” account (which often has a real password or is locked with !), but rather the secondary system accounts. In many Linux distributions, accounts like sync, operator, or halt exist with * as their password field. While these accounts may have restricted shells, an attacker can often override the shell or use the authenticated session to exploit other local vulnerabilities.

Mitigation and Defense-in-Depth

Remediating this vulnerability requires a combination of immediate patching and long-term configuration changes.

Immediate Patching

The primary fix is to update the musl library. Alpine Linux released a patch in November 2024 (targeting musl 1.2.5-r3 and backports for older versions).

To update an Alpine-based system or Dockerfile:

apk update
apk add --no-cache 'musl>=1.2.5-r3'

After updating the library, the sshd service must be restarted to ensure it links against the new version of the library.

The Role of PAM

One reason this bypass is so effective on Alpine is that Alpine’s default sshd configuration often does not use PAM. In distributions like Debian or RHEL, PAM acts as an intermediary. Even if crypt() were to return a “success” state, a well-configured PAM module (like pam_unix.so) would see the * in the shadow file and explicitly deny the login before sshd can finalize the authentication.

If your infrastructure permits the extra overhead, enabling PAM on Alpine can provide a critical layer of defense-in-depth against similar C-library level vulnerabilities.

Auditing /etc/shadow

Administrators should audit their shadow files to identify accounts that use the * placeholder. If an account does not need to be accessed via SSH, it is safer to use the ! placeholder or set the shell to /sbin/nologin.

You can find vulnerable accounts using a simple awk command:

awk -F: '$2 == "*" {print $1}' /etc/shadow

Note: If you find accounts like bin or daemon in this list, ensure they are not permitted to log in via SSH by adding DenyUsers or AllowUsers directives to your sshd_config.

Conclusion: The Cost of Minimalism

The Asterisk vulnerability highlights a fundamental tension in modern software engineering: the trade-off between minimalism and security auditing. By choosing musl and Alpine, developers gain efficiency and a smaller attack surface in terms of “lines of code.” However, they also move away from the most heavily audited and battle-tested codebases like glibc.

This flaw was not a failure of OpenSSH, nor was it a simple “bug” in musl. It was a failure of assumptions. It assumed that a “locked” account was a universal constant across all implementations. As we move toward more diverse ecosystems—including specialized kernels and alternative C libraries—the necessity for cross-library security testing becomes paramount.

The industry must move toward a “trust but verify” model for base images. We cannot assume that because a base image is small, it is inherently more secure. Continuous scanning of container layers and staying informed about low-level library vulnerabilities is the only way to defend against “silent” threats that linger for decades. As we’ve seen with other low-level threats like the BlackX UEFI bootkit, the most dangerous vulnerabilities are often the ones that sit beneath the application layer, waiting for the right string of characters to wake them up.