Skip to content

Commit 6944aca

Browse files
author
Vladimir Kotal
committed
mention TOCTOU
1 parent d4d25a8 commit 6944aca

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

file-api.tex

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,14 +1158,17 @@
11581158
\item The function was meant for an SUID process to verify whether the user
11591159
running the process would have had access to a file if it was not for the SUID
11601160
privileges. However, there is an inherent security hole in this approach.
1161-
The test and the subsequent action on the file is not an atomic operation. An
1162-
attacker could possibly \texttt{unlink} the file and immediately symlink it to a
1163-
different file to what it actually had no rights to manipulate with. If the
1164-
timing is right, the SUID process will operate on that other file. The correct
1165-
solution is not to use the \texttt{access} call but return to the real UID/GID
1166-
and try the operation. For example, if we succeed in opening the file under the
1167-
real UID/GID and continue working with the file descriptor, the file
1168-
manipulation mentioned above would not gain the attacker anything.
1161+
The test and the subsequent action on the file is not an atomic operation.
1162+
This is called the time-of-check to time-of-use (TOCTOU) problem,
1163+
see \url{https://en.wikipedia.org/wiki/Time-of-check\_to\_time-of-use}.
1164+
An attacker could possibly \texttt{unlink} the file and immediately symlink it
1165+
to a different file to what it actually had no rights to manipulate with.
1166+
If the timing is right, the SUID process will operate on that other file.
1167+
\\
1168+
The correct solution is not to use the \texttt{access} call but return to the
1169+
real UID/GID and try the operation. For example, if we succeed in opening the
1170+
file under the real UID/GID and continue working with the file descriptor, the
1171+
file manipulation mentioned above would not gain the attacker anything.
11691172
\end{itemize}
11701173

11711174
%%%%%

unix_dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,4 @@ multi
378378
tickless
379379
ViM
380380
IMproved
381+
TOCTOU

0 commit comments

Comments
 (0)