Lion Cipher Lab

Exploit an integer overflow into a heap overflow — then fix it

Why it matters

Some of the most expensive memory-corruption bugs in history are not dramatic — they are a single multiplication that quietly gave the wrong answer. A program computes how many bytes to allocate, the arithmetic overflows and wraps around to a small number, the allocation comes back far too small, and then a loop writes the amount the program THOUGHT it needed. The bounds were 'checked'; the check just ran on the wrong (wrapped) value. MITRE tracks the arithmetic fault as CWE-190 (Integer Overflow or Wraparound) and the exact pipeline you build here — an integer overflow that leads to an…

What you'll learn

Steps in this lab

  1. Read this first: the target is your own program, on your own machine
  2. What this bug class is — an arithmetic mistake that becomes memory corruption
  3. How this differs from the stack buffer overflow lab — and why both matter
  4. Get a Linux machine, a compiler, and AddressSanitizer
  5. Write the deliberately-vulnerable program
  6. Compile with AddressSanitizer — and a legit run to show it works
  7. Trigger it: one crafted count, a tiny allocation, a heap overflow
  8. Why the check passed yet the buffer was too small
  9. Honest detour: what does and does NOT catch this automatically
  10. Fix it: checked arithmetic, calloc, and a sane bound — then prove it
  11. When, why, better — and the honest limits

Open the full interactive lab →