Challenge Description

The website was a greeting card maker with fields for a recipient’s name and a message. Whatever I entered would appear in the generated card.

I entered {{7 * 7}} to test for server-side template injection (SSTI), since {{ ... }} is the expression syntax of template engines such as Jinja2. The generated card displayed 49.

The expression was evaluated
Getting
49back meant the application was evaluating the expression instead of displaying my input as plain text, confirming a Server-Side Template Injection vulnerability.Reference: PortSwigger - Server-Side Template Injection (SSTI)
I used the following payload to run ls -la and list the files in the current directory:
{{ cycler.__init__.__globals__.os.popen('ls -la').read() }}total 24
drwxr-xr-x 1 root root 4096 Nov 4 03:58 .
drwxr-xr-x 1 root root 4096 Nov 4 03:58 ..
-rw-rw-r-- 1 challenge challenge 1186 Nov 2 11:01 app.py
-rw-rw-r-- 1 root root 30 Nov 2 11:01 requirements.txt
drwxr-xr-x 2 challenge challenge 4096 Nov 2 11:01 static
drwxr-xr-x 2 challenge challenge 4096 Nov 2 11:01 templatesJinja2 Sandbox Escapes
When direct access to dangerous built-ins is restricted, template engines allow walking the Python class hierarchy or accessing
__globals__via helper objects likecyclerto reachos. See HackTricks - Jinja2 SSTI.
This payload accesses the os module through cycler, runs the command with popen, and displays the output in the card. The listing included app.py, so I changed the command to cat app.py to read the application’s source code:
{{ cycler.__init__.__globals__.os.popen('cat app.py').read() }}In the source, app.config['FLAG'] was set from an environment variable, with a flag string as its default value. That string gave me the flag below.

Flag
HNF26{you_got_t3mpl4t3d}