
用于 CVE-2026-123158("*SSHole") 的审计与临时缓解工具,该漏洞是 OpenSSH 在基于 musl 的 Linux(Alpine)上的密码认证绕过漏洞。它覆盖你的运行中的 Docker 容器、本地镜像以及主机。
示例输出(节选,来自一台测试机器):
$ sudo ./sshole-check.sh --images
CVE-2026-123158 (*SSHole) audit · sshole-check 1.0.0 · 2026-11-05 22:45:52 UTC
[VULN ] container sshole-real ghcr.io/requarks/wiki:2.5
OpenSSH 10.3p1 · openssh-server-10.3_p1-r1 openssh-server-common-10.3_p1-r1 · alpine 3.24.3
PasswordAuthentication=yes · PAM=off · PermitRootLogin=prohibit-password · port: 22
'*' accounts: root carol · $5$/$6$ hashed: bob
sshd running: yes · published: 22→0.0.0.0:33776 [::]:33776
→ unpatched (package older than 10.3_p1-r2, the Alpine 3.24 fix) and all conditions are met
· root is '*' but PermitRootLogin=prohibit-password, root cannot log in with a password
· sshd is running and published to the outside
[WARN ] image docker.gitea.com/gitea:1.24.4 dd29b53ab011
OpenSSH 10.0p2 · openssh-server-10.0_p1-r7 openssh-server-common-10.0_p1-r7 · alpine 3.22.1
PasswordAuthentication=yes · PAM=off · PermitRootLogin=without-password · port: 22
'*' accounts: root git · $5$/$6$ hashed: -
EXPOSE 22/tcp 3000/tcp
→ unpatched (package older than 10.0_p1-r11, the Alpine 3.22 fix); conditions not met right now, becomes exploitable once an account gets a password
[OK ] container postgres postgres:16-alpine
no sshd
Summary: OK=339 WARN=8 VULN=1 BREACH=0 SKIPPED=11
它从不尝试登录。 探测程序只读取 sshd 二进制文件、
sshd -T/sshd_config、/etc/shadow、apk 数据库以及每个目标内的日志文件。运行前请先阅读脚本;它是一个由纯 bash 和 POSIX sh 编写的单文件。
curl -fsSLO https://raw.githubusercontent.com/ersinkoc/sshole-check/main/sshole-check.sh
less sshole-check.sh # read it first
chmod +x sshole-check.sh
sudo ./sshole-check.sh # running containers + host
sudo ./sshole-check.sh --images # also every local image
要求:运行该工具的机器上需有 bash,并能访问 Docker(或 Podman)CLI。目标容器只需 /bin/sh。没有 shell 的镜像(如 distroless 或 scratch 镜像)会被报告为 SKIP;它们本来也无法运行 sshd。
| 名称 | *SSHole / "sshhole" |
| 组件 | OpenSSH sshd,不使用 PAM 的密码认证 |
| 平台 | Linux + musl libc(Alpine,也包括 OpenWrt / Buildroot / Yocto 构建) |
| 修复于 | OpenSSH 10.6p2(2026-11-05),以及 Alpine 对 3.16 起所有分支的向后移植 |
| CVSS 3.1 | 8.1 High,AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| CWE | CWE-394(意外的状态码或返回值) |
| GHSA | GHSA-4fcc-vm97-gx3x |
| 报告者 | Özgün Kültekin(Wakefield) |
三种各自看似合理的行为叠加在一起,就构成了登录绕过:
crypt() 在失败时返回 "*"。 自 2012 年起,musl 在失败时返回失败字符串而非 NULL。其 SHA-crypt 实现拒绝长度超过 256 字节的密钥(KEY_MAX,一项 DoS 防护),因此长度超过 256 字节的密码会被哈希为字面字符串 *。$5$/$6$ 哈希的盐值和设置,使时序看起来一致。这就是为什么需要第二个受密码保护的账户。root:*。 自 Alpine 3.16(2022)起,* 是 root 的“无密码,仅密钥”标记。同一标记也用于仅密钥用户、目录服务用户(nslcd、sssd、winbind)以及 tiny-cloud 镜像中的 alpine 用户。在不使用 PAM 的情况下,sshd 会将 crypt(password, borrowed_salt) 与存储字段进行比较。对于 257 到 1024 字节的密码,比较结果为 "*" == "*",登录即被接受。
OpenSSH 10.6p2 通过拒绝过短、无法有效的存储哈希来规避此问题。musl 中的底层行为并未改变;修复位于 sshd 中。
sshd 为 OpenSSH < 10.6p2,且未包含 Alpine 向后移植,并链接到 muslopenssh-server 包,或 openssh-server-pam 且 UsePAM noPasswordAuthentication yes(默认值)*(! 锁定不受影响)$5$ 或 $6$ 哈希root 本身只有在 PermitRootLogin yes 时才可访问;默认的 prohibit-password 会阻止 root 的密码登录。不过,在 Alpine 的 AWS/Azure tiny-cloud 镜像上,* 用户 alpine 拥有免密码的 doas,因此以 alpine 身份进入即意味着获得 root。
不受影响: glibc 发行版(Debian、Ubuntu、RHEL、Fedora 等)、UsePAM yes、PasswordAuthentication no、不运行 sshd 的容器、Dropbear,以及 OpenBSD 的 sshd。
| Alpine 分支 | 首个修复的 openssh | 修复点版本 |
|---|---|---|
| edge | 10.6_p2-r0 | – |
| 3.24 | 10.3_p1-r2 | 3.24.4 |
| 3.23 | 10.2_p1-r1 | 3.23.8 |
| 3.22 | 10.0_p1-r11 | 3.22.8 |
| 3.21 | 9.9_p2-r1 | 3.21.10 |
| 3.20 | 9.7_p1-r6 | (EOL,仅包) |
| 3.19 | 9.6_p1-r3 | (EOL,仅包) |
| 3.18 | 9.3_p2-r4 | (EOL,仅包) |
| 3.17 | 9.1_p1-r7 | (EOL,仅包) |
| 3.16 | 9.0_p1-r6 | (EOL,仅包) |
Alpine 向后移植了该修复,因此大多数分支保留其旧的上游版本:已修复的 3.24 机器仍会报告 OpenSSH_10.3p1。仅凭 sshd -V 无法判断你是否已打补丁。 这就是本工具要将 apk 包发布版本与上表进行比对的原因。
apk upgrade,容器重建后这些更改就会丢失。你需要修复的是镜像。alpine:3.22.1、FROM node:20-alpine@sha256:…)会永远保留有漏洞的软件包,而且带缓存的重新构建可能会复用旧的 apk add 层。$6$ 账户),但只要入口脚本运行 chpasswd,就会立刻变得可利用。sshole-check 会将其报告为 WARN。--network host 的容器,或使用 -p 22:22 / -p 2222:22 的容器,会把该漏洞暴露到网络上。sshole-check 会显示每个容器发布的端口映射。对于每个目标,它都会在其中运行一个小型 POSIX sh 探测脚本。容器通过 docker exec -u 0 进行探测。镜像通过 docker run --rm --network none --entrypoint sh -u 0 启动。主机则直接探测。
| 检查项 | 方式 |
|---|---|
| libc | 存在 /lib/ld-musl-* |
| sshd + 版本 | sshd -V |
| 是否已修补? | 上游版本 ≥ 10.6p2 或 apk 软件包 ≥ 目标 Alpine 分支的修复版本(apk version -t)或作为回退,软件包构建日期晚于 2026-11-05 |
| 生效配置 | sshd -T(如果镜像还没有主机密钥,则在临时目录中使用一次性主机密钥),回退到解析 sshd_config + sshd_config.d/*.conf |
| PAM | sshd / sshd-session 链接到 libpam 且 UsePAM yes |
| 账户 | /etc/shadow:密码字段恰好为 * 的账户,以及使用 $5$/$6$ 哈希的账户 |
| Root | PermitRootLogin 必须为 yes,root:* 才会计入 |
| 暴露面 | 正在运行的 sshd、docker port 映射、主机网络、镜像 EXPOSE |
| 证据 | /var/log/{messages,auth.log,secure} 中的 Accepted password for <user>,以及可选的 docker logs 中的记录,并与 * 账户进行匹配 |
| 判定 | 含义 |
|---|---|
OK | 无 sshd、非 musl、已修补,或正在使用 PAM |
WARN | 未修补,但当前不可利用(密码认证关闭、没有 $5$/$6$ 账户、仅有使用 prohibit-password 的 root:*,或 shadow 不可读) |
VULN | 未修补且所有条件均满足 |
BREACH | 记录了某个密码字段为 * 的账户成功登录。请将该目标视为已失陷 |
SKIP | 非 musl(主机)、无 shell,或执行失败 |
| 代码 | 含义 |
|---|---|
0 | 干净 |
1 | 至少有一个 WARN |
2 | 至少有一个 VULN 或 BREACH |
64 | 命令行选项错误 |
sshole-check.sh [options]
Scan targets:
(default) running containers + host
--images, --all also scan local images (each started briefly with --network none)
--no-host skip the host
--no-containers skip running containers
Extra checks:
--logs scan `docker logs` for "Accepted password for"
--online inside containers, compare installed openssh with the apk repo (needs network)
Interim mitigation (running containers only, asks before each change):
--mitigate prepend "PasswordAuthentication no" to sshd_config and reload sshd
--upgrade upgrade openssh packages via apk and reload sshd
Output:
-y, --yes don't ask for confirmation
-q, --quiet only print targets with problems
-V, --version print version
-h, --help this help
Environment:
DOCKER=podman use another docker-compatible CLI
# Everything, only show problems
sudo ./sshole-check.sh --images --logs -q
# Podman
sudo DOCKER=podman ./sshole-check.sh
# Just the images (e.g. on a build server / in CI)
./sshole-check.sh --no-host --no-containers --images -q || echo "fix your images"
# Hot-fix running containers: upgrade openssh, then disable password login
sudo ./sshole-check.sh --upgrade --mitigate
# Alpine host without bash
apk add bash && sudo bash sshole-check.sh --no-containers
--upgrade、--mitigate)两者都只作用于正在运行的容器,且这些容器尚未修复、也未使用 PAM;除非传入 -y,否则每次更改前都会询问。