# 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 | Goal | Probe | Signal | |---|---|---| | Fuzz for template parsing | polyglot 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). ## Related - [[Server-Side Template Injection]] - [[Jinja2 SSTI]] · [[Twig SSTI]] · [[Java Template Engine SSTI]] · [[JavaScript Template Engine SSTI]] · [[Go Template SSTI]] - [[Cross-Site Scripting]] (the common misclassification) ## Sources - [[raw/portswigger.net/server-side-template-injection-portswigger-research-3873|Server-Side Template Injection (PortSwigger Research)]] - [[raw/portswigger.net/server-side-template-injection-web-security-academy-3874|Server-side template injection (Web Security Academy)]] - [[raw/owasp.org/owasp-testing-for-server-side-template-injection-3869|OWASP Testing for Server Side Template Injection]] - [[raw/github.com/payloadsallthethings-server-side-template-injection-2885|PayloadsAllTheThings - Server Side Template Injection]] - [[raw/research.checkpoint.com/ssti-transforming-web-apps-from-assets-to-liabilities-4144|SSTI: Transforming Web Apps from Assets to Liabilities]] - [[raw/akto.io/ssti-in-freemarker-akto-4580|SSTI in Freemarker (Akto)]] - [[raw/pequalsnp-team.github.io/flask-jinja2-ssti-cheatsheet-3854|Flask & Jinja2 SSTI cheatsheet]] - [[raw/classroom.anir0y.in/tryhackme-ssti-ssti-to-rce-12495|TryHackMe SSTI: SSTI to RCE]] - [[raw/cobalt.io/a-pentester-s-guide-to-ssti-cobalt-2881|A Pentester's Guide to SSTI]] - [[raw/medium.com/from-a-broken-error-message-to-full-server-rce-jinja2-ssti-writeup-9-0-14802|From a broken error message to full server RCE]] - [[raw/modzero.com/exploiting-ssti-in-a-modern-spring-boot-application-4140|Exploiting SSTI in a Modern Spring Boot Application]] - [[raw/synack.com/how-a-pydantic-object-defeated-a-jinja2-sandbox-ssti-to-rce-12639|How a Pydantic Object Defeated a Jinja2 Sandbox]] - [[raw/github.com/vladko312-sstimap-automatic-ssti-detection-tool-with-interactive-inter-3863|vladko312/SSTImap]] - [[raw/github.com/epinna-tplmap-ssti-and-code-injection-detection-and-exploitation-tool-3864|epinna/tplmap]]