python.django.security.audit.templates.debug-template-tag.debug-template-tag

Author
6,591
Download Count*
License
Detected a debug template tag in a Django template. This dumps debugging information to the page when debug mode is enabled. Showing debug information to users is dangerous because it may reveal information about your environment that malicious actors can use to gain access to the system. Remove the debug tag.
Run Locally
Run in CI
Defintion
rules:
- id: debug-template-tag
languages:
- generic
severity: WARNING
message: Detected a debug template tag in a Django template. This dumps
debugging information to the page when debug mode is enabled. Showing
debug information to users is dangerous because it may reveal information
about your environment that malicious actors can use to gain access to the
system. Remove the debug tag.
pattern: "{% debug %}"
metadata:
owasp: A06:2017 - Security Misconfiguration
cwe:
- "CWE-489: Active Debug Code"
references:
- https://docs.djangoproject.com/en/3.1/ref/templates/builtins/#debug
- https://stackoverflow.com/questions/2213977/django-debug-display-all-variables-of-a-page
category: security
technology:
- django
subcategory:
- audit
likelihood: LOW
impact: MEDIUM
confidence: LOW
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
Examples
debug-template-tag.html
<!DOCTYPE html>
<html>
<head></head>
<body>
<!-- ruleid: debug-template-tag -->
<pre> {% filter force_escape %} {% debug %} {% endfilter %} </pre>
<!-- ok: debug-template-tag -->
<p>There should be debug information up there. {{ random_debug_variable }}</p>
</body>
</html>
Short Link: https://sg.run/dK3E