Lion Cipher Lab

Exploit the heap with the House of Einherjar (forge a chunk with a null-byte overflow and consolidate backward)

Why it matters

House of Einherjar is the technique that turns the single most common heap bug in real software — an off-by-one that writes ONE null byte past a buffer — into a controlled allocation anywhere you want. That is a huge amount of leverage from the smallest possible overflow: not a page of attacker bytes, just 0x00 in the wrong place. Learning it teaches two durable things. First, the mechanic: how the PREV_INUSE flag and the prev_size field let free() merge a chunk with the one before it, and how clearing one bit convinces the allocator to consolidate BACKWARD into memory you forged. Second, and…

What you'll learn

Steps in this lab

  1. The one-sentence idea: one null byte lies about who's free
  2. When this applied — the exact bug it needs
  3. Legal and ethical line — read before you run anything
  4. Spin up an OLD-glibc container — the version is the whole game
  5. Get how2heap and read the einherjar source before running it
  6. Run it and watch the backward consolidation land
  7. Inspect the consolidation in a debugger — see the chunk move backward
  8. Now watch the naive version DIE on modern glibc — and understand exactly why
  9. Where an off-by-null still bites — and the durable takeaway

Open the full interactive lab →