Skip to content
RCE Write-up Intermediate

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.

abda11atarek Follow

Published on systemweakness.com

Hi, I’m abda11atarek-and today I will show you a nice challenge in playsecure ctf .

abda11atarek, on systemweakness.com

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

  1. Open the challenge and find three input fields
  2. Try command injection, which only printed the command back
  3. Try a template expression and see it evaluated
  4. Probe the template context with self and config.items()
  5. Build a subclasses payload using attr and hex-encoded underscores
  6. 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.