Software Development Security

A service verifies that a user may read a file, then opens it a few milliseconds later. An attacker replaces the file in that gap and reads another user's data. Which source-code weakness is this?

Show the answer

Correct answerA. TOCTOU race condition

AWhy this is right: The permission check and the file open are separate steps, and the attacker changes the file between them.

BWhy not this: Path traversal manipulates path input such as ../ sequences; here the exploit depends on timing, not path content.

CWhy not this: Error handling flaws leak information or fail unsafely; nothing in the scenario involves error output.

DWhy not this: Buffer overflows come from writing past a memory boundary, not from a gap between a check and its use.

A time-of-check to time-of-use race condition exists when the state verified by a check can change before the resource is used. The attacker exploits the gap, not the file path string, so path traversal does not fit.