ENGINEERING

OpenSSH 10.6p2: anyone can log in to some Alpine servers. Check whether yours is one

OpenSSH released 10.6p2 on November 5 with an emergency fix, and Alpine published its advisory the same day. On an affected machine, Alpine says, “an attacker who can reach your SSH port can log in without knowing any password. It takes one connection, works every time, and needs no retries.” There’s no CVE number yet. OpenSSH’s Damien Miller told users to turn off password logins immediately.

It only hits a narrow set of machines. Ubuntu, Debian, RHEL, Rocky, macOS and Windows aren’t affected, and neither is Alpine with PAM turned on.

How it works

When sshd is built without PAM, it checks a password by running it through the C library’s crypt() and comparing the result to the stored hash. musl’s crypt() returns * as an error when the password is longer than 256 bytes. * is also exactly what /etc/shadow holds for an account with no password. So a long enough password “matches” every passwordless account, and sshd lets it in.

You’re affected only if all of these are true

Root is safe on the defaults. OpenSSH’s PermitRootLogin prohibit-password keeps password logins off root unless someone set PermitRootLogin yes. Accounts locked with ! aren’t affected, and neither are containers that don’t run sshd.

What I saw in the lab

I put openssh-server in an Alpine 3.24 container on my Rocky lab VM and ran the checks below. Alpine’s repo already served the fixed package, 10.3_p1-r2. Root had * in its password field, and a user I made with adduser -D had !, which is locked and not affected. A build without PAM doesn’t print a usepam line in sshd -T at all. No line means no PAM. I didn’t try the bypass itself.

Check one host

cat /etc/alpine-release                       # no file: not Alpine
apk info -v | grep '^openssh-server'          # compare with the table below
sshd -T | grep -Ei '^(usepam|passwordauthentication|permitrootlogin) '
awk -F: '$2=="*" {print $1}' /etc/shadow      # accounts with no password

If sshd -T shows passwordauthentication yes and either no usepam line or usepam no, the host is exposed until it has the fixed package. To see whether someone already got in, Alpine says to look in /var/log/messages for Accepted password for an account that has no password.

Check the containers on a Linux host

Your Linux hosts aren’t affected, but Alpine containers running sshd on them can be. This lists every running Alpine container that’s running sshd, with its package version (swap podman for docker if that’s what you use):

for c in $(podman ps -q); do
  podman exec "$c" sh -c '[ -f /etc/alpine-release ] && pgrep sshd >/dev/null && apk info -v 2>/dev/null | grep "^openssh-server-[0-9]"' 2>/dev/null \
    | sed "s|^|$(podman inspect -f '{{.Name}}' "$c"): |"
done

I tested it with one Alpine container running sshd and one not. It listed only the first.

Fixed packages

AlpineFixed openssh-server
edge10.6_p2-r0
3.2410.3_p1-r2
3.2310.2_p1-r1
3.2210.0_p1-r11
3.219.9_p2-r1
3.209.7_p1-r6
3.199.6_p1-r3
3.189.3_p2-r4
3.179.1_p1-r7
3.169.0_p1-r6

What to do

  1. Update: apk upgrade -U -a, then rc-service sshd restart. The restart matters. The running sshd keeps the old code until it restarts.
  2. If you can’t update right now, add PasswordAuthentication no to /etc/ssh/sshd_config and restart sshd. Make sure you have a working SSH key first.
  3. For containers, rebuild the image on the fixed package, or take sshd out of it.
  4. Check /var/log/messages for password logins to accounts that have no password.

Doing it with RFF

The RFF Linux agent runs on glibc distributions, so it doesn’t run on an Alpine host itself. On the Ubuntu, Debian and RHEL-family hosts it does manage, you can run the container loop above as a script job on every host at once and get back which containers need a rebuild.

RFF is free for your first 100 endpoints: getrff.com.

Sources

One email per new post, nothing else. Unsubscribe in one click. Or use the RSS feed.

Comments

Comments use GitHub Discussions, so you'll need a GitHub account to post. Corrections are especially welcome.