Server Side Template Injection - SSTI
Last updated
Last updated
User data concatenated into templates instead of passed as data.
Templates: strings
Detecting:
Fuzz for a potentially valid parameter:
${{<%[%'"}}%\
If this brings about an exception it's possible the server is vulnerable.
Contexts:
Plaintext:
Vulnerable result: Hello, 49
The syntax varies by template engine.
Code:
Vulnerable code:
greeting = getQueryParameter('greeting') engine.render("Hello {{"+greeting+"}}", data)
Injection:
Vulnerable result: Hello <name>
To test for this, it may be necessary to test for XSS first as they can look similar.
Inject HTML to test:
If there's an error or a blank “Hello” with no username, test it again to break out of the html:
http://vulnerable-website.com/?greeting=data.username}}<tag>
Vulnerable result
Hello Name<tag>
NB: It's possible if it is returned blank then the wrong syntax was used, so could keep trying.