CS FundamentalsVery hardGATE CS
A setuid-root program calls `access(path, R_OK)` to check the real user may read path, then calls `open(path)`. Which vulnerability does this pattern create?
- A. A time-of-check-to-time-of-use (TOCTOU) race: an attacker can swap path for a symlink to a protected file between the two calls
- B. A buffer overflow in access()
- C. A deadlock between access() and open()
- D. No vulnerability: access() and open() are atomic together
Correct answer: A. A time-of-check-to-time-of-use (TOCTOU) race: an attacker can swap path for a symlink to a protected file between the two calls
The check and the use are separate system calls, so the file named by path can change in between. The fix is to drop privileges (seteuid) before open or to use open flags such as O_NOFOLLOW and check the opened descriptor.
More Operating Systems questions
- Which defence makes a stack-buffer-overflow attack that jumps to injected shellcode on the stack fail, even if the return address is…
- In the Bell–LaPadula confidentiality model, which rules apply?
- Which component of a computer can a hypervisor of TYPE 1 run on directly?
- Why could a classic x86 CPU (before VT-x/AMD-V) not be virtualised by pure trap-and-emulate?
- Containers (e.g. using Linux namespaces and cgroups) differ from virtual machines mainly because:
- A 1 GB process is swapped to a disk with 100 MB/s transfer rate and 10 ms latency. Approximately how long does a full swap out followed by…