SSTI (Server-Side Template Injection)
Last updated
Was this helpful?
Last updated
Was this helpful?
Server-side template injection is when an attacker is able to use native template syntax to inject a malicious payload into a template, which is then executed server-side.
Tplmap is a Server-Side Template Injection and Code Injection detection and exploitation tool.
./tplmap.py -u 'http://www.target.com/page?name=John'
We have to identify input vectors that may not be properly sanitized in GET and POST parameters. For this, we may fuzz parameters using the following payload
${{<%[%'"}}%\
Once you have detected the template injection, the next step is to identify the template engine.
By manually testing different language-specific payloads and study how they are interpreted by the target, we may identify the template engine.
a{*comment*}b
Smarty
#{ 2*3 }
Pug, Spring
*{ 2*3 }
Spring
${"z".join("ab")}
Mako, ???
{{ '7'*7 }}
Angular, Django, Flask, Go, Jinja2, Tornado, Twig, ???
{{:2*3}}
JsRender
{% debug %}
Django
@(7*7)'
Razor (.NET)
Once you have identified the engine, refers to the corresponding page to exploit it: