appsec.fyi

Server-Side Template Injection (SSTI) Resources

Post Share

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

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 2026GoSecure: Template Injection in Action workshopGoSecure: Template Injection in Action workshop
2026-04-10 NEW 2026Jinja2 SSTI filter bypassesJinja2 SSTI filter bypasses
2026-04-10 NEW 2026OnSecurity: Server Side Template Injection with Jinja2OnSecurity: Server Side Template Injection with Jinja2
2026-04-10 NEW 2026Flask & Jinja2 SSTI cheatsheetFlask & Jinja2 SSTI cheatsheet
2026-04-10 NEW 2026Grav: SSTI via Twig escape handler advisoryGrav: SSTI via Twig escape handler advisory
2026-04-10 NEW 2026Exploit-DB: Twig 2.4.4 Server Side Template InjectionExploit-DB: Twig 2.4.4 Server Side Template Injection
2026-04-10 NEW 2026OpenMetadata: FreeMarker SSTI in email templates leads to RCEOpenMetadata: FreeMarker SSTI in email templates leads to RCE
2026-04-10 NEW 2026CVE-2023-49964: FreeMarker SSTI in AlfrescoCVE-2023-49964: FreeMarker SSTI in Alfresco
2026-04-10 NEW 2026GitHub Security Lab: SSTI in Apache Camel — CVE-2020-11994GitHub Security Lab: SSTI in Apache Camel — CVE-2020-11994
2026-04-10 NEW 2026Breaking the Barrier: RCE via SSTI in FreeMarkerBreaking the Barrier: RCE via SSTI in FreeMarker
2026-04-10 NEW 2026Synack: Discovering an SSTI vulnerability in FreeMarkerSynack: Discovering an SSTI vulnerability in FreeMarker
2026-04-10 NEW 2026YesWeHack: Limitations are just an illusion — advanced SSTI exploitation with RCE everywhereYesWeHack: Limitations are just an illusion — advanced SSTI exploitation with RCE everywhere
2026-04-10 NEW 2026vladko312/SSTImap: Automatic SSTI detection tool with interactive interfacevladko312/SSTImap: Automatic SSTI detection tool with interactive interface
2026-04-10 NEW 2026epinna/tplmap: SSTI and Code Injection Detection and Exploitation Toolepinna/tplmap: SSTI and Code Injection Detection and Exploitation Tool
2026-04-10 NEW 2026PayloadsAllTheThings SSTI: JavaPayloadsAllTheThings SSTI: Java
2026-04-10 NEW 2026PayloadsAllTheThings: Server Side Template InjectionPayloadsAllTheThings: Server Side Template Injection
2026-04-10 NEW 2026HackTricks: Jinja2 SSTIHackTricks: Jinja2 SSTI
2026-04-10 NEW 2026HackTricks: SSTI (Server Side Template Injection)HackTricks: SSTI (Server Side Template Injection)
2026-04-10 NEW 2026OWASP Testing for Server Side Template InjectionOWASP Testing for Server Side Template Injection
2026-04-10 NEW 2026Server-side template injection PortSwigger KBServer-side template injection PortSwigger KB
2026-04-10 NEW 2026Exploiting server-side template injection vulnerabilitiesExploiting server-side template injection vulnerabilities
2026-04-10 NEW 2026Template Injection Research | PortSwigger ResearchTemplate Injection Research | PortSwigger Research
2026-04-10 NEW 2026Server-Side Template Injection | PortSwigger ResearchServer-Side Template Injection | PortSwigger Research
2026-04-10 NEW 2026Server-side template injection | Web Security AcademyServer-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.