Server-Side Template Injection (SSTI)
Server-Side Template Injection (SSTI) occurs when user input is concatenated directly into a server-side template instead of being passed in as a parameter. Because templating engines are designed to evaluate expressions and call methods, an attacker who controls part of the template can frequently escalate from a reflected math expression like {{7*7}} all the way to remote code execution in the language the engine runs on.
The vulnerability class was first formalized by James Kettle's PortSwigger research, which demonstrated generic exploits and sandbox escapes across the most popular template engines. Since then, real-world SSTI has been found in Jinja2 (Python/Flask), Twig (PHP), Freemarker and Velocity (Java), Smarty and Mako, and even nominally sandboxed environments — sandbox escapes for Jinja2 are republished almost every year, and Apache Camel, OpenMetadata, and Alfresco have all shipped critical SSTI CVEs in production frameworks.
SSTI is easy to confuse with XSS at first glance because both involve injection into rendered output, but the impact is fundamentally different. XSS executes in the victim's browser; SSTI executes on the server, often as the application user, and leads directly to file read, environment access, and full RCE. Detection starts with simple expression probes ({{7*7}}, ${7*7}, *{7*7}), then engine fingerprinting through error messages, then engine-specific gadget chains.
This page collects PortSwigger's foundational research, Web Security Academy labs, HackTricks and PayloadsAllTheThings references, the standard tooling (tplmap, SSTImap), and engine-specific exploitation guides and CVE writeups for Jinja2, Twig, Freemarker, and beyond.
From PortSwigger Research
| Date Added | Link | Excerpt |
|---|---|---|
| 2026-04-10 NEW 2026 | GoSecure: Template Injection in Action workshop | GoSecure: Template Injection in Action workshop |
| 2026-04-10 NEW 2026 | Jinja2 SSTI filter bypasses | Jinja2 SSTI filter bypasses |
| 2026-04-10 NEW 2026 | OnSecurity: Server Side Template Injection with Jinja2 | OnSecurity: Server Side Template Injection with Jinja2 |
| 2026-04-10 NEW 2026 | Flask & Jinja2 SSTI cheatsheet | Flask & Jinja2 SSTI cheatsheet |
| 2026-04-10 NEW 2026 | Grav: SSTI via Twig escape handler advisory | Grav: SSTI via Twig escape handler advisory |
| 2026-04-10 NEW 2026 | Exploit-DB: Twig 2.4.4 Server Side Template Injection | Exploit-DB: Twig 2.4.4 Server Side Template Injection |
| 2026-04-10 NEW 2026 | OpenMetadata: FreeMarker SSTI in email templates leads to RCE | OpenMetadata: FreeMarker SSTI in email templates leads to RCE |
| 2026-04-10 NEW 2026 | CVE-2023-49964: FreeMarker SSTI in Alfresco | CVE-2023-49964: FreeMarker SSTI in Alfresco |
| 2026-04-10 NEW 2026 | GitHub Security Lab: SSTI in Apache Camel — CVE-2020-11994 | GitHub Security Lab: SSTI in Apache Camel — CVE-2020-11994 |
| 2026-04-10 NEW 2026 | Breaking the Barrier: RCE via SSTI in FreeMarker | Breaking the Barrier: RCE via SSTI in FreeMarker |
| 2026-04-10 NEW 2026 | Synack: Discovering an SSTI vulnerability in FreeMarker | Synack: Discovering an SSTI vulnerability in FreeMarker |
| 2026-04-10 NEW 2026 | YesWeHack: Limitations are just an illusion — advanced SSTI exploitation with RCE everywhere | YesWeHack: Limitations are just an illusion — advanced SSTI exploitation with RCE everywhere |
| 2026-04-10 NEW 2026 | vladko312/SSTImap: Automatic SSTI detection tool with interactive interface | vladko312/SSTImap: Automatic SSTI detection tool with interactive interface |
| 2026-04-10 NEW 2026 | epinna/tplmap: SSTI and Code Injection Detection and Exploitation Tool | epinna/tplmap: SSTI and Code Injection Detection and Exploitation Tool |
| 2026-04-10 NEW 2026 | PayloadsAllTheThings SSTI: Java | PayloadsAllTheThings SSTI: Java |
| 2026-04-10 NEW 2026 | PayloadsAllTheThings: Server Side Template Injection | PayloadsAllTheThings: Server Side Template Injection |
| 2026-04-10 NEW 2026 | HackTricks: Jinja2 SSTI | HackTricks: Jinja2 SSTI |
| 2026-04-10 NEW 2026 | HackTricks: SSTI (Server Side Template Injection) | HackTricks: SSTI (Server Side Template Injection) |
| 2026-04-10 NEW 2026 | OWASP Testing for Server Side Template Injection | OWASP Testing for Server Side Template Injection |
| 2026-04-10 NEW 2026 | Server-side template injection PortSwigger KB | Server-side template injection PortSwigger KB |
| 2026-04-10 NEW 2026 | Exploiting server-side template injection vulnerabilities | Exploiting server-side template injection vulnerabilities |
| 2026-04-10 NEW 2026 | Template Injection Research | PortSwigger Research | Template Injection Research | PortSwigger Research |
| 2026-04-10 NEW 2026 | Server-Side Template Injection | PortSwigger Research | Server-Side Template Injection | PortSwigger Research |
| 2026-04-10 NEW 2026 | Server-side template injection | Web Security Academy | Server-side template injection | Web Security Academy |
Frequently Asked Questions
- What is server-side template injection?
- SSTI happens when user input is concatenated into a template that the server then renders, instead of being passed as a parameter. Because templating engines support expressions and method calls, an attacker who controls part of the template can often execute arbitrary code in the language the engine runs on — Python, Java, PHP, JavaScript, and others have all seen real-world SSTI leading to remote code execution.
- How do you test for SSTI?
- The standard first probe is a math expression like {{7*7}} or ${7*7} — if the response contains 49 instead of the literal string, the input is being evaluated. From there, identify the engine through error messages or syntax fingerprinting and escalate to environment access, file reads, or code execution using engine-specific payloads. PortSwigger's SSTI research provides a complete methodology.
- Which template engines are most affected by SSTI?
- Jinja2 (Python), Twig (PHP), Freemarker and Velocity (Java), Smarty (PHP), and Mako (Python) all have well-documented SSTI exploitation paths. Even nominally sandboxed engines like Jinja2 have repeatedly had sandbox escapes published. Any engine that exposes object attributes, method calls, or filters is a candidate.
Weekly AppSec Digest
Get new resources delivered every Monday.