Python Flask Jinja2 SSTI Payload Analysis @0xdf
Python Flask Jinja2 SSTI Payload Analysis  @0xdf
Uploaded August 2024 | Updated November 2026, 3 hours ago
I'll walk through a common SSTI payload pulled from PayloadsAllTheThings and look at how it works, using the Flask request object to get a function, which gives access to the __globals__. From there it gets the __builtins__ dictionary and the __import__ function.

Payload: github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Server%20Side%20Template%20Injection/README.md#jinja2---filter-bypass
Flask Request object: flask.palletsprojects.com/en/3.0.x/api/#flask.Request
Flask globals: flask.palletsprojects.com/en/3.0.x/templating/#standard-context
Jinja2 attr: jinja.palletsprojects.com/en/3.1.x/templates/#jinja-filters.attr
Python Function attributes: docs.python.org/3/reference/datamodel.html#special-read-only-attributes

☕ Buy Me A Coffee: buymeacoffee.com/0xdf

[00:00] Introduction
[00:55] Data overview
[01:33] Making dummy Flask app
[02:35] Flask request object
[03:38] request in Jinja context
[04:22] attr / getattr / dot
[05:30] Using function to get __globals__
[07:40] Getting __builtins__ from __globals__
[09:31] Using __import__ to get the os module
[10:31] Getting execution
[11:50] Conclusion

#ssti #ctf #python #jinja2
Python Flask Jinja2 SSTI Payload AnalysisDay 17 - Two Steps Forward [Revival of Code 2023 - Advent of Code 2016]Wearhouse Woes [Day 15 - Advent of Code 2024 - Python]Day 25: Snowverload [AOC2023 Python]Day 5: If You Give A Seed A Fertilizer [AOC2023 Python]Finding and Fixing a Bug in Netexec NFSReflective XSS via Link Click / SSRF [Hackvent 2022 - Day 14]Troubleshooting proxychainsElf Connect - JavaScript Game Hacking [Sans Holiday Hack 2024]Day 22: Sand Slabs [AOC2023 Python]Resonant Collinearity [Day 8 - Advent of Code 2024 - Python]Antipattern [0xff: One Last Address]
0xdf |

Python Flask Jinja2 SSTI Payload Analysis

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER