thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Application & OT Security · Intermediate

Time-of-Check to Time-of-Use (TOCTOU)

A race condition in which a resource changes between the time it is checked and the time it is used.

Definition

Examples include checking a file's permissions and then opening it after an attacker swaps in a symbolic link, or checking a balance and then debiting it in separate steps. Mitigations include atomic operations, file descriptors rather than paths, locking and transactions. Tracked as CWE-367.

Example

A setuid program checks access() on /tmp/report then opens it, but the attacker replaces it with a symlink to /etc/shadow in between.

Exam tip

TOCTOU is the canonical race condition; atomic operations are the fix.

Related terms