← All articles

OpenSSH vulnerability bypasses Alpine Linux logins

OpenSSH vulnerability bypasses Alpine Linux logins

The OpenSSH vulnerability allows attackers to access certain Alpine Linux accounts that have no password, including accounts intended to accept only Secure Shell (SSH) keys. SSH is a system for remotely signing in to and managing a computer. An attacker needs network access to the server, the account name and a password between 257 and 1,024 bytes long. OpenSSH rates the flaw critical, but no attacks exploiting it had been reported at publication.

OpenSSH released version 10.6p2 to stop the bypass, while Alpine Linux published corrected packages for releases back to 3.16. The flaw affects sshd, the OpenSSH service that receives remote login requests, when it checks passwords without PAM. Pluggable Authentication Modules (PAM) is an interface through which software can use the operating system's authentication rules. Password login must also be enabled, and at least one other local account must have a compatible password hash, the stored mathematical representation of a password. Alpine's standard openssh-server package is compiled without PAM and enables password authentication by default.

Alpine's advisory identifies four conditions that must all be present. The machine must use openssh-server without PAM, or openssh-server-pam with UsePAM set to no. PasswordAuthentication must be yes. A target account must have * in its password field, meaning no password is set. Finally, another local account must have a password hash beginning with $5$ or $6$. One such password-protected account is enough to expose every passwordless account whose name the attacker knows. According to the advisory, the bypass succeeds on every attempt and needs only one connection.

Potential targets on Alpine include users created for SSH-key-only access with adduser and no password, or with usermod -p '*'. Users supplied by a directory service through musl-nscd can also qualify because they lack an entry in the shadow password file. The base image has shipped with root:* since about Alpine 3.16, while official cloud images built with tiny-cloud include an alpine user with no password. Root cannot normally be reached this way because the default PermitRootLogin prohibit-password setting blocks direct password access. That defence is lost if PermitRootLogin is changed to yes, or if another exposed user can elevate its access through doas, a command that lets an authorised user perform administrative tasks.

Tiny-cloud images from 3.18.11 through 3.24.3 give the alpine account passwordless doas access. They are not exposed at first boot, but become vulnerable after any $6$ password hash appears, such as when an administrator creates a console password. An attacker could then enter as alpine and use doas to become root. Containers that do not run sshd, machines with PasswordAuthentication no and cloud images configured through cloud-init are unaffected because cloud-init writes that setting. Accounts marked with ! in /etc/shadow are also unaffected, as are systems with no account using a $-style password hash.

The issue results from the interaction between sshd and musl, the C software library used by Alpine. Non-Linux systems, Linux distributions built with glibc and systems that pass password checks through PAM are not affected, according to OpenSSH. The Wakefield researcher who reported the problem also identified OpenWrt, Buildroot and Yocto as musl-based systems worth checking. OpenWrt normally uses Dropbear for SSH, and Dropbear is not affected. OpenWrt is exposed only if an administrator has installed OpenSSH server and the other required conditions exist.

Alpine users should run apk upgrade -U -a and then rc-service sshd restart. Updating the package alone does not restart the already running service. Alpine point releases 3.21.10, 3.22.8, 3.23.8 and 3.24.4 include the corrected package. Branches 3.16 through 3.21 have passed their support end dates but also received fixes. Cloud instances created from older tiny-cloud images still require the update or the configuration workaround. Anyone compiling OpenSSH directly should use 10.6p2.

If updating is not immediately possible, OpenSSH advises disabling password login or stopping SSH access. Administrators should first confirm that SSH-key access works, leave the existing session open and test a second login before changing anything. Set PasswordAuthentication no, validate the configuration with sshd -t and restart sshd. Alpine's advisory provides commands for placing the setting in /etc/ssh/sshd_config.d, which the default configuration reads from version 3.19 onward, and for changing every PasswordAuthentication yes line in /etc/ssh/sshd_config, including lines inside Match sections. Running sshd -T | grep -i passwordauthentication afterward should return passwordauthentication no.

Administrators should search /var/log/messages for sshd entries showing an accepted password login to an account that has no password, particularly alpine, root or a key-only user. On an exposed machine, they should also examine doas activity, recently created users, changed files and added authorised SSH keys. Alpine's advisory says a machine should be treated as compromised if an unauthorised login cannot be ruled out.

The bypass occurs because non-PAM sshd calls crypt(), a C library function that converts an attempted password into the form used for comparison. A passwordless account stores only *. Because that value is too short to include a salt, the prefix used when generating a password hash, sshd borrows the salt from another account with a real hash. For $5$ and $6$ hashes, musl's crypt() rejects passwords longer than 256 bytes and returns * as an error marker. That result matches the target account's stored *, so sshd accepts the password. OpenSSH itself limits submitted passwords to 1,024 bytes, producing the exploitable range of 257 to 1,024 bytes.

Musl changed crypt() on August 9, 2012, to return an intentionally unmatchable hash rather than NULL when processing failed because many programs did not check errors. It added the 256-byte ceiling on August 29, 2012, to reduce denial-of-service risks. OpenSSH introduced salt borrowing on July 15, 2016, while addressing CVE-2016-6210, which allowed attackers to determine whether usernames existed. The reporter says the present weakness has existed since that change.

OpenSSH 10.6p2 refuses a password match when the stored field contains fewer than four characters. The project describes this as a workaround and says the underlying cause is outside sshd; Alpine's stable packages contain a patch for the same issue. OpenSSH said it released the fix quickly because its team considers long disclosure embargoes dangerous after observing AI agents independently rediscover bugs, sometimes within hours. No CVE identifier had been assigned to this new flaw at publication. For organisations needing support around affected systems, AEU-I provides security-first IT, infrastructure and consulting.

Also available in: DeutschItalianoShqip