Exploitation
Exploiting the SSTI
You can exploit SSTI in the following way:
Cross Site Scripting
Remote Code Execution
In this example we will focus on the exploiting SSTI in order to gain code execution in the Jinja2 templating engine (Python).
One of the exploits that can enable us to perform code execution can be found below:
it looks a little bit complicated but everything should become clear after the quick explaination of the code above.
Once the class is returned the payload uses MRO attribute (Method Resolution Order) which are classes that python search for base classes during method resolution (related to class inheritance).
When we have useful class that we can take advantage of we can proceed to choosing the useful subclasses:
Running the useful function which results in reading the /etc/passwd file:
Last updated