IPBUF安全漏洞报告
English
CVE-2026-8274 CVSS 5.3 中危

CVE-2026-8274 cramfs-tools路径遍历漏洞

披露日期: 2026-05-11

漏洞信息

漏洞编号
CVE-2026-8274
漏洞类型
路径遍历
CVSS评分
5.3 中危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
npitre cramfs-tools

相关标签

路径遍历cramfs-tools本地漏洞CVSS-5.3目录遍历

漏洞概述

npitre cramfs-tools 2.1及之前版本中存在一个路径遍历安全漏洞。该漏洞位于Directory Handler组件的cramfsck.c文件中的do_directory函数。由于该函数在处理目录路径时未能正确过滤特殊字符,攻击者可以通过构建恶意的CramFS镜像文件来利用此漏洞。攻击需要本地环境且无需用户交互,成功利用可能导致信息泄露、数据完整性受损或可用性降低。官方已在2.2版本中修复此问题。

技术细节

该漏洞的根源在于cramfsck工具的do_directory函数在解析目录项时,未对从CramFS镜像中读取的路径名进行充分的规范化校验。CramFS是一种压缩的只读文件系统,cramfsck通常用于检查其完整性或解压。当工具处理包含“../”序列的恶意路径时,由于缺乏边界检查,操作上下文会跳出预期的解压或检查目录,指向父目录甚至系统根目录。攻击者利用这一点,结合本地低权限(PR:L),可以诱骗具有更高权限的用户或自动化脚本处理恶意镜像。一旦触发,攻击者可能利用当前进程的权限在文件系统的任意位置读取、创建或覆盖文件,从而造成本地权限提升或数据破坏。

攻击链分析

STEP 1
侦察
攻击者确认目标系统上安装了npitre cramfs-tools 2.1或更早版本。
STEP 2
武器化
攻击者构建一个特制的CramFS镜像文件,其中包含带有路径遍历序列(如../)的恶意文件名。
STEP 3
传递
由于是本地漏洞,攻击者将恶意镜像文件上传到目标系统,或诱导目标系统下载该文件。
STEP 4
利用
攻击者诱骗本地用户或管理员运行cramfsck工具检查该恶意镜像。由于无需用户交互(UI:N),该过程也可能被自动化脚本触发。
STEP 5
影响
do_directory函数处理恶意路径时发生路径遍历,导致工具在预期目录之外读取或写入文件,造成信息泄露或数据破坏。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import os # Simulating the vulnerable logic in cramfsck.c do_directory function # This script demonstrates how a lack of path sanitization leads to traversal. def vulnerable_do_directory(file_path, extract_to="."): # Vulnerability: No sanitization of path traversal characters (../) # The function directly joins paths without resolving or checking boundaries. full_path = os.path.join(extract_to, file_path) # Normalize path to see where it actually points (for demonstration) real_path = os.path.realpath(full_path) print(f"[DEBUG] Intended extraction dir: {os.path.realpath(extract_to)}") print(f"[DEBUG] Resolved file path: {real_path}") # Check if the path escaped the intended directory if not real_path.startswith(os.path.realpath(extract_to)): print("[ALERT] Path Traversal Detected! Writing outside the intended directory.") else: print("[INFO] Path is safe.") # Simulating file operation (e.g., reading or creating) try: # In the real vulnerability, this would write to the filesystem print(f"[ACTION] Attempting to write to: {full_path}") with open(full_path, 'w') as f: f.write("Exploited content") print(f"[SUCCESS] File written at {real_path}") except Exception as e: print(f"[ERROR] {e}") # PoC Execution if __name__ == "__main__": # Attacker crafts a malicious path inside the filesystem image # using '../' to escape the current directory malicious_payload = "../../../../tmp/pwned_by_cve_2026_8274.txt" print("--- CVE-2026-8274 PoC Simulation ---") print(f"Payload: {malicious_payload}") print("Running cramfsck (simulated) on malicious image...") # Assuming the tool runs in a directory like /home/user/extract/ # The vulnerable function processes the malicious path vulnerable_do_directory(malicious_payload)

影响范围

npitre cramfs-tools <= 2.1

防御指南

临时缓解措施
如果无法立即升级,建议限制对cramfsck工具的访问权限,仅允许受信任的管理员执行。在处理来源不明的CramFS镜像时,应在隔离环境(如沙箱或容器)中运行检查工具,以防止路径遍历攻击影响宿主系统文件。

参考链接