
27
Security and Cryptography
TOCTTOU: These attacks exploit the fact that there is a finite time from time-of-
check to time-of-use. An example would make things clearer. UNIX stores user
passwords (or rather their hashes with salt) in /etc/pwd file. When users want to up-
date their passwords, UNIX does the following:
1. Pick a random filename, say, rand123.txt
2. Check if rand123.txt exists in /tmp. If yes, goto 1
3. If not, open /tmp/rand123.txt.
4. Copy contents of /etc/pwd to rand123.txt
5. Add new entry.
6. Copy rand123.txt to /etc/pwd.
The vulnerability that TOCTTOU exploits is that the system call required for step 2
(checking) is ...