Alpine Linux Security Advisory: OpenSSH-server password authentication bypass

If you run sshd on Alpine Linux, update openssh now and restart sshd. Upgrading the package alone does not replace the running daemon.

如果您在 Alpine Linux 上运行 sshd,请立即更新 openssh 并重启 sshd。仅升级软件包并不会替换正在运行的守护进程。

If you cannot update yet, at least disable password logins: set PasswordAuthentication no in your sshd configuration and restart sshd. Either one closes the hole.

如果您暂时无法更新,请至少禁用密码登录:在 sshd 配置中设置 PasswordAuthentication no 并重启 sshd。这两种方法中的任何一种都能堵住漏洞。

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.

能够访问您 SSH 端口的攻击者无需知道任何密码即可登录。只需一次连接,每次都能成功,且无需重试。

The attacker needs the name of an account whose password field is * (an account with no password set, which is normal for key-only accounts), and needs the machine to have at least one other account with a $5$ or $6$ password hash. The attacker then sends a very long password (257 to 1024 bytes). One user with a password is enough: it makes every account without one reachable.

攻击者需要一个密码字段为 * 的账户名称(即未设置密码的账户,这对于仅使用密钥的账户很常见),并且机器上必须至少有另一个拥有 $5$ 或 $6$ 密码哈希的账户。随后,攻击者发送一个超长密码(257 到 1024 字节)。只要有一个设置了密码的用户,就足以使所有未设置密码的账户变得可被入侵。

Details are in the OpenSSH 10.6p2 release notes. No CVE identifier had been assigned at the time of writing.

详细信息请参阅 OpenSSH 10.6p2 发行说明。撰写本文时,尚未分配 CVE 标识符。

You are affected if all of the following are true:

如果您符合以下所有条件,则会受到影响:

Affected releases: every Alpine release we checked, 3.21 through 3.24 and edge, and the older releases that no longer receive regular updates (3.16 to 3.20).

受影响的版本:我们检查过的所有 Alpine 版本,包括 3.21 到 3.24 以及 edge 版本,还有不再接收常规更新的旧版本(3.16 到 3.20)。

Alpine 3.21.10, 3.22.8, 3.23.8 and 3.24.4 contain the fixed package (see the release announcement). The fixed package versions are:

Alpine 3.21.10、3.22.8、3.23.8 和 3.24.4 包含修复后的软件包(请参阅发布公告)。修复后的软件包版本为:

Restart sshd after upgrading (rc-service sshd restart). Upgrading the package does not restart a running sshd, so you must do it after.

升级后请重启 sshd (rc-service sshd restart)。升级软件包不会重启正在运行的 sshd,因此您必须在升级后手动执行此操作。

Before you start, make sure your SSH key login works, and keep your current session open until you have tested a new login.

在开始之前,请确保您的 SSH 密钥登录功能正常,并保持当前会话开启,直到您测试过新的登录方式。

Run these as root. The first two commands create a drop-in file. Alpine’s default sshd_config reads that directory from 3.19 onward; older releases ignore it. The sed command changes yes to no on every PasswordAuthentication line in /etc/ssh/sshd_config, whatever the spacing, including lines inside a Match block. It also adds PasswordAuthentication no at the top of the file, for the case where there was no such line, and saves the original as /etc/ssh/sshd_config.bak. The last two commands check the configuration, restart the daemon, and show the result:

请以 root 身份运行这些命令。前两条命令用于创建一个插入式配置文件。从 3.19 版本开始,Alpine 的默认 sshd_config 会读取该目录;旧版本则会忽略它。sed 命令会将 /etc/ssh/sshd_config 中所有 PasswordAuthentication 行的 yes 改为 no,无论其间距如何,包括 Match 块内的行。它还在文件顶部添加了 PasswordAuthentication no,以防原文件中不存在该行,并将原始文件保存为 /etc/ssh/sshd_config.bak。最后两条命令用于检查配置、重启守护进程并显示结果:

The last command should print passwordauthentication no. To undo, delete /etc/ssh/sshd_config.d/00-no-passwords.conf and copy /etc/ssh/sshd_config.bak back over /etc/ssh/sshd_config.

最后一条命令应输出 passwordauthentication no。如需撤销,请删除 /etc/ssh/sshd_config.d/00-no-passwords.conf 并将 /etc/ssh/sshd_config.bak 复制回 /etc/ssh/sshd_config。

The official tiny-cloud images (the qcow2, VHD and AMI artifacts) from 3.18.11 through 3.24.3 ship an alpine user with a * password field and passwordless doas. They are safe on first boot. They become exploitable as soon as any $6$ hash exists on the machine, for example when an admin sets a console password, or user-data adds a user with hashed_passwd. An attacker then gets a shell as alpine and can use doas to become root.

从 3.18.11 到 3.24.3 的官方 tiny-cloud 镜像(qcow2、VHD 和 AMI 制品)预装了一个密码字段为 * 且支持无密码 doas 的 alpine 用户。它们在首次启动时是安全的。一旦机器上存在任何 $6$ 哈希值(例如管理员设置了控制台密码,或用户数据添加了带有 hashed_passwd 的用户),它们就会变得可被利用。攻击者随后可以获得 alpine 的 shell,并使用 doas 提权为 root。

Images built from 3.21.10, 3.22.8, 3.23.8, 3.24.4 and later include the fixed package. Images from earlier point releases do not, so on every running instance, update openssh or disable password authentication.

从 3.21.10、3.22.8、3.23.8、3.24.4 及更高版本构建的镜像已包含修复后的软件包。更早的点版本镜像则不包含,因此在每个正在运行的实例上,请务必更新 openssh 或禁用密码验证。

These releases have the same bug. 3.21 reached its end of support on 2026-11-01, but we have published fixed packages for each release all the way back to 3.16.

这些版本存在相同的漏洞。3.21 版本于 2026 年 11 月 1 日结束支持,但我们已为从 3.16 开始的每个版本发布了修复后的软件包。

Look in /var/log/messages for sshd lines reading Accepted password for an account that has no password (alpine, root, or any key-only user). Review doas use and recently created users, files and authorized keys on exposed machines. If you cannot rule out a login, treat the machine as compromised.

请查看 /var/log/messages 中是否有 sshd 行显示“Accepted password for…”且该账户本应没有密码(如 alpine、root 或任何仅使用密钥的用户)。检查暴露机器上的 doas 使用记录以及最近创建的用户、文件和授权密钥。如果您无法排除异常登录,请将该机器视为已被入侵。

When sshd is built without PAM, it checks a password by hashing the attempt with crypt() (the C library function that turns a password into its stored hash) and comparing the result to the stored password field. For an account whose stored field is too short to contain a salt (the random prefix of a hash), sshd borrows the salt of another account.

当 sshd 在没有 PAM 的情况下构建时,它会通过使用 crypt()(将密码转换为存储哈希的 C 库函数)对尝试登录的密码进行哈希处理,并将结果与存储的密码字段进行比较来验证密码。对于存储字段太短而无法包含盐值(哈希的随机前缀)的账户,sshd 会借用另一个账户的盐值。

musl’s crypt() returns the string * as an error indicator when the key is over 256 bytes long. * is also exactly what the stored field contains for every account with no password, so the “hash” matches and the login succeeds.

当密钥长度超过 256 字节时,musl 的 crypt() 会返回字符串 * 作为错误指示符。而 * 正好是每个无密码账户存储字段中的内容,因此“哈希”匹配成功,登录得以通过。

OpenSSH 10.6p2 avoids the problem in sshd. The stable-branch packages above carry a patch for the same problem.

OpenSSH 10.6p2 在 sshd 中规避了此问题。上述稳定分支软件包也针对该问题应用了补丁。

Reported by Özgün Kültekin of Wakefield. Thanks to Damien Miller and Darren Tucker of the OpenSSH project for the fix and the 10.6p2 release, to Timo Teräs for help analyzing the issue, and to Natanael Copa, who built and uploaded the updated packages.

由 Wakefield 的 Özgün Kültekin 报告。感谢 OpenSSH 项目的 Damien Miller 和 Darren Tucker 提供修复方案及 10.6p2 版本,感谢 Timo Teräs 协助分析该问题,并感谢构建并上传更新软件包的 Natanael Copa。