Title here
Summary here
Django ships built-in backends for its own template system, creatively called the Django template language (DTL), and for the popular alternative Jinja2
.
Basic example of DTL:
Usage of DTL in a Django application:
Example of vulnerable code:
DTL vs Jinja2:
Payload | Jinja2 | Django Templates |
---|---|---|
{% csrf_token %} | Causes error | Anti-CSRF token HTML tag |
{{ 7*7 }} | 49 | Causes error |
When messages
is present in the template context and CookieStorage
is being used we can walk through attributes of messages
to access app’s SECRET_KEY
:
You can include other templates in your page:
safe
: Marks a string as not requiring further HTML escaping prior to output. When autoescaping is off, this filter has no effect.escape
: Escapes a string’s HTML (HTML entity).force_escape
: Applies HTML escaping to a string.