Skip to main content
Server side Template Injection (SSTI) occurs when an attacker can inject templating code into a template that is later rendered by the server. If an attacker injects malicious code, the server may execute the code during the rendering process, allowing the attacker to take complete control of the server.

Confirming SSTI

The process of identifying an SSTI vulnerability is similar to the process of identifying any other injection vulnerability, such as SQL injection. The most effective way is to inject special characters with semantic meaning in template engines and observe the web application’s behavior. The following polyglot test string is commonly used to provoke an error message in a web application vulnerable to SSTI, as it consists of all special characters that have a particular semantic purpose in popular template engines:
If you get an error (a stack trace, a 500, or any failing output), it’s a good indicator for a SSTI Injection. From there, test with something that proves code execution rather than just a parsing error:
If 49 comes back in the response, you’ve got SSTI. Before exploiting further, you need to identify which template engine is in use, payloads are not portable between various engines.

Identifying the Template Engine

We can use slight variations in the behavior of different template engines to determine which one is in use. Each delimiter style and math operator narrows down the possible engine: Template Decision Tree Once you have a possible engine, jump to its tab below.

Template Engines

Check PayloadsAllTheThings: Jinja2 for more techniques

Automated Tools

SSTImap identifies the engine and automates exploitation (file read, command execution, interactive shell and more..)
Tplmap is an older, Python2 only alternative with similar functionality.

Quick Reference Tools

SSTImap

Detects the engine and automates exploitation across Jinja2, Twig, Mako, Freemarker, and more.

tplmap

Older Python 2 SSTI automation tool, still useful as a fallback.

PayloadsAllTheThings: SSTI

Per-language payload breakdown (Python, PHP, Java, Ruby, JavaScript) with sandbox-bypass chains.

HackTricks: SSTI

Broader engine coverage including less common ones (Pebble, Thymeleaf, Mako, Tornado).

PortSwigger: SSTI

Methodology writeup and Academy labs for practicing detection and exploitation.