Welcome Card
A welcome card generator was vulnerable to server-side template injection in its Jinja2 templates, and the author bypassed a filter on underscore characters by hex-encoding them. This allowed arbitrary command execution on the server and reading of the flag file from the filesystem.
Published on systemweakness.com
Hi, I’m abda11atarek-and today I will show you a nice challenge in playsecure ctf .
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely user input was passed into a Jinja2 template and rendered, so template expressions were evaluated as code, with only a weak character filter as protection.
Impact
The author could run arbitrary system commands on the server and read the flag file, so full remote code execution was achieved.
What the attacker needed
Access to the challenge site; input fields accept template syntax
How it was found
- Open the challenge and find three input fields
- Try command injection, which only printed the command back
- Try a template expression and see it evaluated
- Probe the template context with self and config.items()
- Build a subclasses payload using attr and hex-encoded underscores
- Find the subprocess class index and run commands to locate and read the flag
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The website built its welcome cards by filling in a template, a kind of text with placeholders that the server fills in. Because user input was treated as part of that template, the author could make the server run their own instructions, including system commands. A filter tried to block certain characters, but encoding them differently got around it.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.