A privileged script verifies that a temporary file is not a symbolic link, then opens it. An attacker swaps in a link to a protected file between the two steps. What should the developer change?
Show the answer
Correct answerC. Make the check and the open a single atomic operation
AWhy not this: Update signatures protect the script's delivery, not the gap between its check and its use of a file.
BWhy not this: EDR can spot memory injection, but nothing is injected here; the attacker only swaps the file in the gap.
CWhy this is right: An atomic check-and-open leaves no window in which the file can be swapped after the check.
DWhy not this: Filename length limits guard against buffer overflows, but the problem here is a timing gap, not oversized input.
The flaw is a time-of-check race: the file's state changes after the check but before it is opened. Performing the check and open as one atomic operation leaves no gap. Limiting filename length addresses buffer overflows, which are not involved here.