Use {{7*'7'}} to tell Jinja2 from Twig after a {{7*7}} template injection hit
A reflected 49 from {{7*7}} only tells you some engine evaluated your input. Send a second probe, {{7*'7'}}, in the same parameter. Jinja2 repeats the string and returns 7777777; Twig converts it to a number and returns 49. If neither works, try ${7*7} (Freemarker, Velocity, Thymeleaf-style), <%= 7*7 %> (ERB, EJS) and #{7*7} (Pug, Ruby), and compare which delimiter evaluates.
This works because the application concatenates user input into the template source instead of passing it as data. Each engine has its own operator semantics, so the arithmetic result identifies the engine and tells you which documented object chain applies next.
Prove it with the raw response from curl, not the browser. If the 49 only shows up after the page loads, a client-side framework such as AngularJS evaluated it, which is XSS territory rather than server-side injection. Also check the value is not just your own calculation echoed back by a calculator-style feature. Stop at the fingerprint unless the program allows deeper testing: the arithmetic result plus the engine name is enough for a valid report, and running commands on the server is not needed. Stay in scope and use your own test account.
Follow #fingerprinting, #jinja2, #ssti or #twig for new tips like this one, on your notifications page and, if you choose, in a daily or weekly email.
Comments
No comments yet.