HAKATEMIA
01Intro

What are Template Injections (SSTI)?

Medium20MIN

What are templates?

Old-fashioned web applications built (and partly still build) HTML responses like this.

PY
1html = &quot;<h1> Welcome, &quot; + name + &quot;</h1> return html

This type of HTML structure is not only rigid but also terribly insecure. Such applications are usually quite easy to inject the attacker's own HTML/JavaScript code, which leads to XSS vulnerabilities.

A more modern approach is to use templates. Templates are separate HTML files that are also partly code files. The desired data is then given to the template, and the template builds the HTML. There is no vulnerability in this code because the template can safely build the HTML in a way that it doesn't matter what the attacker has entered as a name, it doesn't become dangerously part of the HTML structure.

PY
1template = &quot;<h1> Welcome, {{name}}</h1> &quot; return render_template(template, name=name)
1 / 4
Hakatemia Pro

Learn to hack — start here

Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.