Lion Cipher Lab

Stop a 'billion laughs' XML entity-expansion denial-of-service

Why it matters

The 'billion laughs' attack -- also called an XML bomb -- is one of the cheapest denial-of-service attacks there is: a file a few hundred bytes long can force a naive XML parser to try to build hundreds of millions or billions of characters in memory, freezing or crashing the service that parsed it. It works with no external files and no network at all. It abuses a feature of XML called entity expansion: you declare a small 'internal entity' in the document's DTD, then declare a second entity that expands to ten copies of the first, a third that expands to ten of the second, and so on. Ten…

What you'll learn

Steps in this lab

  1. What a 'billion laughs' is -- the vocabulary in one breath
  2. Set up: confirm Python, make a folder, and generate a SMALL bomb
  3. EXPLOIT (measured): parse it and watch the curve go exponential
  4. FIX (measured): defusedxml rejects the same file instantly
  5. Judgment: when to forbid entities outright, and when you cannot

Open the full interactive lab →