SSTI

Testing for SSTI

Try submitting a fuzzed payload such as ${{<%[%'"}}%\ if a stack trace error is displayed then the application is vulnerable.

To distinguish between XSS and SSTI submit payloads that trigger mathematical operations such as ${2*2} if the output is 4 then the vulnerability is aa SSTI

If the user input is included inside a code block follow these steps

  1. Verify that the attack is not an XSS by passing a payload including HTML tags such as str<b>test</b> if the tags and the content included are not rendered then the vulnerability is not an XSS

  2. Try to escape from the code block by submitting a payload as follow (adjust based on the engine's syntax): }}<b>test</b>

  3. If the content of the code block is rendered correctly alongside the injected tags then the application is vulnerable to SSTI

Server Side

ASP

Identification

<%= 7*7 %>
<%= "foo" %>
<%= response.write(date()) %>

Remote file inclusion

Java

Identification

Command execution

Get system variables

Java - FreeMarker

Identification

Command execution

File read

Sandbox escape

requires FreeMarker version < 2.3.30

Java - Velocity

Identification

Blind command execution

Command execution

Java - Thymeleaf

Identification

Command execution

Java - Pebble

Identification

Command execution

Version < 3.0.9

Newer versions

Java - JinJava

Identification

Command execution

NodeJs

Code execution via handlebars

Code execution via JsRenderer

XSS via JsRenderer

NodeJs - Jade

Identification

Command execution

Command execution as subprocess

Useful for spawning independent shells

NodeJs - PugJs

Identification

Command execution

NodeJs - NUNJUCKS

Identification

Command execution

PHP - Smarty

Identification

Command execution

PHP - Twig

Identification

Command execution

File read

Remote file inclusion

Python - Jinja2

Identification

Command execution

Command execution via GET parameter

Register the GET parameter

Send a request containing the given parameter with the code to execute as value. For instance a request can be <url>/?<param>=<code>

Read file

Write file

Python - Tornado

Identification

Command execution

Python - Mako

Identification

Command execution

Ruby - ERB

Identification

Blind command execution

Command execution

List folders

Read file

Ruby - Slim

Identification

Blind command execution

.Net - Razor

Identification

Command execution

Client Side

AngularJS

VueJS

Mavo

Last updated