Behemoth Level 4
Behemoth Level 4 — a program reads a file whose name depends on its process ID, which opens the door to a race condition using symbolic links.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
There is no information for this level, intentionally.
Study guide
Level map: logged in as behemoth4, find the password for behemoth5.
What this level teaches
Race conditions and predictable file names.
Key ideas
- Predictable names. A file path derived from a value you can learn, such as the process ID, is predictable.
- Time window. The program pauses between steps, which gives you time to change what a path points at.
- Symbolic links. A link at the expected path can make the privileged program read a file it was never meant to show you.
- Controlling the process. Job control or signals (
kill -STOP) let you pause a process so you can prepare the link.
How to approach it
- Use
straceto find which path the program opens and how it names it. - Work out how to learn the process ID early and arrange for the right file to exist.
- Repeat until the timing works.
Why it matters
Time-of-check to time-of-use bugs are a major real-world class, which is why secure temporary-file functions exist.