Skip to content
uencoder

Time of Use (TOCTOU)

Time-of-use (TOU) is the second half of a TOCTOU race: the moment the program uses the resource, whose state may differ from check time.

Purpose

To understand the risk of the resource being tampered with between check and use; defend with atomic operations.

Mechanism

At TOU the resource may already have been replaced by an attacker (e.g., a symlink), invalidating the security assumptions of the TOC check. Defenses: open the file and fstat the descriptor instead of the path.

Use cases

  • Race vulnerability defense
  • Atomic file operations
  • Secure coding

Related tools

References