Skip to main content

Settings

Color Mode

Theme Skin

Background

Appearance preferences are saved in this browser only.

Environment

Current Environment Production

Built with JEKYLL_ENV=production. Changes require deployment.

Quick Links

Theme & Build

Jekyll v3.10.0
Last BuildNov 24, 17:25

Page Location

Page Info

Layout default
Collection wargames
Path _wargames/leviathan/leviathan2.md
URL /wargames/leviathan/leviathan2/
Date 2026-04-07

Leviathan Level 2

Leviathan Level 2 — a setuid program checks whether you may read a file before printing it; learn what that check really verifies.

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 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.