← ClaudeAtlas

detect-toctou-raceslisted

Detection and hardening methodology for TOCTOU (time-of-check to time-of-use) file race conditions used for local privilege escalation, where an attacker swaps a symlink, hardlink, junction, or file between a privileged process's check and its use (MITRE ATT&CK T1068, setuid case T1548.001). ATT&CK has no TOCTOU-specific technique, so detection keys off observable edges: Linux auditd SYSCALL/PATH records for symlink/link/rename, the fs.protected_* sysctls, Falco, Sysmon for Linux, osquery; Windows Sysmon FileCreate (Event ID 11) and Security object-access auditing (4663/4656). Gives the defender view of the attack, a hunt, public rule sources, and a hardening plan. Use when investigating a suspected symlink or race-condition local root, triaging a privileged process writing through a world-writable path, hunting for symlink-swap attempts in /tmp, auditing services operating on user-controllable paths, or writing TOCTOU detections.
umbrasec-labs/umbra-blue · ★ 0 · AI & Automation · score 62
Install: claude install-skill umbrasec-labs/umbra-blue
# TOCTOU Race Conditions - Defensive Methodology > **Tier 2 - methodology skill.** No bespoke UMBRASEC detection rule ships with this skill yet. It gives the defender's method, the log sources and signals, the hunt, and the hardening, and points to public rule sources. Promotion to Tier 1 (a sourced, tuned UMBRASEC rule) is tracked in [COVERAGE.md](https://github.com/umbrasec-labs/umbra-blue/blob/main/COVERAGE.md). Do not treat the content below as citing a UMBRASEC rule; there is none for this threat yet. ## TL;DR for defenders A TOCTOU (time-of-check to time-of-use) bug is a race: a privileged process checks a path (does this file exist, who owns it, may I write it) and then acts on that path a moment later, and an unprivileged attacker swaps what the path points to in the gap between the two. The classic shape is a root or SYSTEM process that resolves a filename through a directory the attacker can write to (`/tmp`, `/var/tmp`, `/dev/shm`, `C:\ProgramData`, `%TEMP%`), letting the attacker redirect the privileged write into `/etc/passwd`, `/etc/shadow`, `/etc/sudoers.d/`, a cron directory, or a new setuid binary. You almost never catch the race itself, so detect its three edges: the precondition (a privileged process operating on a user-writable path), the attempt (an unprivileged account creating symlinks or hardlinks pointing at sensitive targets, often in a fast rename loop to widen the window), and the outcome (a privileged process writing to a file it should never t