Skip to content

Leviathan Level 2

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 leviathan2, find the password for leviathan3.

What this level teaches

How a program decides whether you are allowed to read a file, and how the name it checks can differ from the file it finally opens.

Key ideas

  • Check, then use. Many programs test permission first and open the file afterwards. Anything that can change between the two steps is an opportunity.
  • File names are strings. Spaces, symbolic links and relative paths all affect which file a name finally refers to.
  • Trace it. ltrace shows the library calls used to check and open files.

How to approach it

  1. Run the program under ltrace with a file you own and watch its calls.
  2. Compare what it checks with what it opens, and think about a name that means different things in each place.
  3. Use a private directory under /tmp for your experiments.

Why it matters

This class of bug, known as time-of-check to time-of-use, has caused real privilege escalations in widely used software.