SSTI Detection

Finding where user input is parsed as template source, confirming evaluation, and fingerprinting the engine before any escalation.

How it works

Kettle’s 2015 methodology is still the baseline: detect → identify → exploit. Detection splits by injection context:

  • Plaintext context — input lands in literal template text (render("Hello " + name)). Evaluation shows up as transformed output, e.g. {{7*7}} → 49. Easily mistaken for reflected XSS when the response just echoes HTML.
  • Code context — input lands inside an existing expression ({{ user.<input> }}). Probe by breaking out of the expression (closing the tag, then appending markup) and watching whether output is blank, errors, or renders the appended text.

Evaluation that returns arithmetic results distinguishes SSTI from XSS; an HTML-only reflection does not.

Techniques / probes

GoalProbeSignal
Fuzz for template parsingpolyglot of metacharacters, e.g. ${{<%[%'"}}%\500 / template stack trace
Confirm evaluation{{7*7}}, ${7*7}, <%= 7*7 %>, #{7*7}49
Jinja2 vs Twig{{7*'7'}}7777777 = Jinja2, 49 = Twig
FreeMarker check${89*91}8099 (Akto rule)
Smarty{'Hello'\|upper}HELLO
  • Decision tree. PortSwigger’s tree branches on which syntax evaluates (${} vs {{}} vs <%= %>) and then on engine-specific behavior such as the string-multiplication split above.
  • Error messages. Stack traces and verbose errors name the engine; a $9,000 Jinja2 bounty began with a broken error message that leaked internals.
  • Blind SSTI. When output is not reflected: time-based (engine-side sleep), boolean-based (error vs no error), and OOB DNS callbacks. PayloadsAllTheThings groups techniques as Rendered, Error-Based, Boolean-Based and Time-Based; Check Point documents sleep- and nslookup-based validation.
  • Second-order. Stored values rendered later — email/notification templates, PDF/report generators, CMS theme or “message” fields, wizard steps. Many 2026 CVEs are second-order and authenticated.
  • Context enumeration. After identification, list the objects the template can see (self, config, request, developer-exposed models). Synack’s Pydantic case shows the context matters more than the payload.

Where to look

  • Parameters reflected in rendered pages, especially names, greetings, titles, error pages.
  • Headers rendered into templates (modzero: Referer reflected into a Thymeleaf view).
  • Admin features: email template editors, notification bodies, themes, export/report templates, webhook bodies.
  • Non-web inputs: config files, data documents and model chat templates rendered with Jinja2 (fsspec, Dynaconf, llama-cpp-python pattern).

Tools

  • SSTImap — successor to tplmap; detection, blind techniques, engine modules (Python, PHP, Java, JS, Ruby).
  • tplmap / tplmap-python3 — original automated detector, 15+ engines.
  • TInjA — polyglot-based scanner (Hackmanit).
  • Burp Scanner and template-injection extensions (OWASP WSTG reference).

Sources