Lion Cipher Lab

Exploit and fix Server-Side Template Injection (SSTI)

Why it matters

Server-Side Template Injection is one of the highest-impact web bugs because it frequently escalates all the way to remote code execution on the server. A template engine (Jinja2 in Flask, Twig in PHP, Freemarker/Velocity in Java, ERB in Ruby) is meant to combine a developer-written TEMPLATE with runtime DATA — 'Hello {{ name }}' plus name='Ada' gives 'Hello Ada'. The vulnerability appears the moment user input is placed into the TEMPLATE half instead of the DATA half: if the code builds the template by concatenating user text (render_template_string("Hello " + name)), the engine compiles and…

What you'll learn

Steps in this lab

  1. What SSTI is — the vocabulary, how it differs from XSS, and the ground rules
  2. Set up: confirm Python, make a folder, install Flask
  3. Build the VULNERABLE app (it concatenates user input into the template)
  4. DETECT: send {{7*7}} and read the 49
  5. ESCALATE (benign): leak the planted secret, then reach the OS
  6. Why blocklisting {{ (and trusting the sandbox) is the wrong fix
  7. FIX: pass user input as DATA into a fixed template, then prove it
  8. What you did — and the reflex to keep

Open the full interactive lab →