template injection

An injection attack where a user supplies the template itself, letting them walk into objects and data the template was never meant to show.

A user-controlled template can read data and sometimes run code on the server.

In more detail

Some template languages, such as Python's str.format, can follow attributes and indexes, so a template chosen by a caller is a small program. Templates are code and belong in your repository; caller data is only ever a value passed to one.

Example

In the course, Python's str.format follows dotted attributes, so the template {u.__init__.__globals__[SECRET]} prints a deploy key.

Related terms

Taught in

References