通过 POSIX 集群审计器、零信任 sshd 配置、Ansible 回滚和 Falco eBPF 规则,审计、加固并检测 OpenSSH musl 认证绕过漏洞(CVE-2026-123158)的暴露情况。
面向 OpenSSH musl Salt 截断认证绕过漏洞(CVE-2026-123158 / OpenSSH 10.6p2)的企业级纵深防御、漏洞审计与零信任加固工具包
2026 年 11 月,安全研究人员披露了 OpenSSH 服务器中的一个未认证远程认证绕过漏洞,该漏洞影响针对 musl libc 编译的 OpenSSH 服务器(主要涉及 Alpine Linux)。在特定前置条件下,提供长度介于 256 至 1,024 字节之间的超大密码字符串会触发内部字符串比较匹配,从而在无凭据的情况下授予未授权的交互式 shell 或 root 访问权限。
该缺陷源于独立组件之间的架构契约冲突:
/etc/shadow 密码字段中以星号 * 表示。$5$)、SHA-512($6$)、yescrypt($y$)或 bcrypt($2b$)salt。以 ! 为前缀的锁定账户、已过期账户或格式错误的哈希无法充当 salt 提供者。musl libc 对 crypt_sha512.c 和 crypt_sha256.c 的实现强制密码密钥最大长度为 256 字节(KEY_MAX)。当输入长度达到或超过 256 字节时,musl 会返回字面错误哨兵字符串 *,而不是计算哈希摘要。strcmp("*", "*") == 0,将认证检查判定为成功。关键修复指令: 最终修复方案是部署厂商已修补的软件包。系统管理员必须立即应用厂商更新:
- 上游版本: OpenSSH 10.6p2
- Alpine Linux 官方向后移植版本:
- Alpine 3.24:
openssh-10.3_p1-r2- Alpine 3.23:
openssh-10.2_p1-r1- Alpine 3.22:
openssh-10.0_p1-r11- Alpine 3.21:
openssh-9.9_p2-r1⚠️ 操作警告: 在 Alpine Linux 上,运行
apk add -u openssh会更新磁盘上的二进制文件,但不会重启正在运行的 sshd 服务。必须重启守护进程(rc-service sshd restart或重新部署容器),才能从进程内存中清除已解除链接的易受攻击代码。在需要先经过资格验证窗口再进行二进制替换的企业环境中,协议层缓解措施可完全消除暴露风险。本仓库提供自动化集群审计、通用零信任即插即用配置、带经验证的补偿性回滚的 Ansible 部署自动化,以及 eBPF 运行时检测规则。
flowchart TD
classDef l1 fill:#022c22,stroke:#10b981,stroke-width:2px,color:#f8fafc;
classDef l2 fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc;
classDef l3 fill:#2e1065,stroke:#a855f7,stroke-width:2px,color:#f8fafc;
classDef l4 fill:#451a03,stroke:#f59e0b,stroke-width:2px,color:#f8fafc;
L1["Layer 1: Primary Prevention\nVendor Patch and Hardening\nPasswordAuth Disabled"]:::l1
L2["Layer 2: Exposure Assessment\nPOSIX Fleet Auditor v1.1.6\n5-State SCAP/OVAL Engine"]:::l2
L3["Layer 3: Runtime Detection\nFalco eBPF Security Rules\nCredential Tampering Defense"]:::l3
L4["Layer 4: Verification Gate\n30-Scenario Regression Suite\nUbuntu + Alpine CI Matrix"]:::l4
L1 --> L2
L2 --> L3
L3 --> L4
PasswordAuthentication no、KbdInteractiveAuthentication no)。audit_openssh_immunity.sh),用于验证 PID 进程身份(/proc/$PID/comm)、软件包归属(apk info -W、dpkg -S、rpm -qf)、内存中可执行文件一致性(/proc/$PID/exe)、守护进程命令行 -f 配置恢复、严格的 9 字段 /etc/shadow 记录,以及全字段锚定的算法特定模块化 crypt 哈希。tests/test_auditor.sh),在 GitHub Actions CI 中跨 Ubuntu(glibc)和 Alpine Linux(musl libc)执行。| 组件 | 标准 / 指令 | 本仓库中的实现 | 技术功能 |
|---|---|---|---|
| 认证协议 | CIS Benchmark 5.2.11 | PasswordAuthentication no | 在协议层终止密码查询;完全绕过 crypt 函数 |
| 键盘交互 | CIS Benchmark 5.2.12 | KbdInteractiveAuthentication no | 禁用 PAM 质询-响应密码回退 |
| Root 公钥访问 | CIS Benchmark 5.2.5 | PermitRootLogin prohibit-password | 禁止管理账户使用密码认证 |
| 算法限制 | CIS Benchmark 5.2.14 | PubkeyAcceptedAlgorithms ... | 强制使用现代椭圆曲线标准(ED25519 / ECDSA / RSA-SHA2) |
| PAM 委托 | OpenSSH Portable Standard | UsePAM yes | 将认证执行转移至 PAM 模块;在无 PAM 的 musl 构建中被安全忽略 |
| 账户 Shadow 防护 | Linux Shadow Standard | passwd -l <user>(强制执行 !) | 将锁定的 * 哨兵值替换为 !,以防止字符串比较冲突 |
要在不部署外部运行时的情况下评估集群系统,请下载 POSIX 审计器脚本、验证加密摘要并执行:
# 1. Download auditor script and canonical SHA-256 digest
curl -sSLO https://raw.githubusercontent.com/mc493/openssh-musl-enterprise--hardening-cve-2026-123158/main/audit/audit_openssh_immunity.sh
curl -sSLO https://raw.githubusercontent.com/mc493/openssh-musl-enterprise--hardening-cve-2026-123158/main/audit/audit_openssh_immunity.sh.sha256
# 2. Verify cryptographic SHA-256 digest
sha256sum -c audit_openssh_immunity.sh.sha256
# 3. Execute fleet inspection
chmod +x audit_openssh_immunity.sh
./audit_openssh_immunity.sh
为防止生产环境中环境变量意外泄漏,除非同时提供 --internal-test-mode CLI 标志和 AUDIT_ENABLE_TEST_HARNESS=1 环境变量,否则所有模拟覆盖项(AUDIT_MOCK_*)都会被无条件取消设置。注意:此双门控是一种测试隔离机制,而非针对控制进程调用的不可信调用者的权限边界。
用于与 Ansible、Datadog 或集中式日志采集集成:
./audit_openssh_immunity.sh --json
示例 JSON 遥测数据(v1.1.6 五状态模式,含 PID 身份与包来源信息):
{
"timestamp": "2026-11-06T21:40:00Z",
"auditor_version": "1.1.6",
"verdict": "NOT_AFFECTED",
"reason": "Host runs GNU C Library (glibc); crypt() does not return '*' on oversized password inputs (256-1024 bytes)",
"operational_status": {
"binary_provenance": "verified",
"pid_identity_verified": true,
"package_owned": true,
"restart_required": false,
"test_harness_active": false
},
"details": {
"libc_type": "glibc",
"sshd_binary": "/usr/sbin/sshd",
"sshd_pid": "3622",
"pid_identity_verified": 1,
"package_owned": 1,
"active_config_file": "/etc/ssh/sshd_config",
"is_deleted_binary": 0,
"binary_provenance": "verified",
"restart_required": false,
"test_harness_active": false,
"sshd_pam_linkage": "pam_linked",
"effective_pam": 1,
"password_authentication": "no",
"kbd_interactive_authentication": "no",
"use_pam": "yes",
"package_version": "OpenSSH_9.6p1 Ubuntu-3ubuntu13.20",
"is_patched": 0,
"has_star_target_account": -1,
"has_valid_salt_donor": -1,
"has_conditional_match_blocks": 0,
"match_block_enables_password_auth": 0
}
}
| 判定状态 | 底层环境与配置条件 | 所需机群操作 | 退出码 |
|---|---|---|---|
PATCHED | 已验证已修补的软件包(上游 $\ge$ 10.6p2 或 Alpine 向后移植版本),并已验证守护进程 PID 身份、活动进程内存一致性,以及确认的包管理器归属(binary_provenance: verified)。 | 无。补丁已生效并在活动内存中得到证实。 | 0 |
NOT_AFFECTED | 底层环境缺少先决条件:GNU C 库(glibc),或未安装 OpenSSH 服务器守护进程。 | 无。底层环境无法触发 musl 错误哨兵。 | 0 |
MITIGATED | 主机运行 musl libc,但密码和键盘交互式认证在全局及条件 Match 块中均被显式禁用,或有效 PAM 处于活动状态,或在有效的 9 字段 /etc/shadow 中确凿不存在已锁定的 * 账户 / 活动的未锁定盐值提供者。 | 已验证对攻击向量安全。在维护窗口期间安排软件包修补。 | 0 |
VULNERABLE | 主机运行 musl libc,且无有效 PAM,密码认证已启用(全局启用或在条件 Match 块内重新启用),并且已锁定的 * 目标账户与活动的未锁定盐值提供者在 /etc/shadow 中共存。 | 需要立即采取关键行动。 部署零信任 drop-in 或补丁并重启守护进程。 | 1 |
UNKNOWN | 凭据检查无定论(/etc/shadow 缺失、不可读或违反 9 字段模式),运行中的 sshd 映射到未链接/已删除的可执行文件 inode,二进制文件不属于包管理器(package_owned: false),或无法建立守护进程内存来源(binary_provenance: unknown)。故障关闭。 | 以 root/sudo 权限重新运行审计器,验证二进制包来源,或重启 sshd 服务以建立内存一致性。 | 2 |
将提供的 drop-in 配置部署到 /etc/ssh/sshd_config.d/00-zero-trust-hardening.conf: