CVE-2017-12794
Medium · 6.1CVSS
6.1
EPSS
23.6%
Published
Sep 7, 2017
CISA due date
—
Cloudanix analysis
A flaw in the web framework's developer error page could allow an attacker to run malicious code in a developer's web browser, potentially leading to the theft of their account credentials.
- Exploitation
- Requires User Interaction
- Attacker needs
- None
- Complexity
- Moderate
- Impact
- Data Exposure
- Component
- Web Framework
- Class
- XSS
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
A flaw in the Django technical 500 debug page template fails to properly escape HTML characters in user-provided data. This allows for a reflected Cross-Site Scripting (XSS) attack. An attacker can inject arbitrary JavaScript code into the debug page, which will execute in the browser of any user who views it, typically a developer or system administrator.
Why it matters to the business
This vulnerability primarily affects non-production environments where debug mode is enabled. If exploited, an attacker could steal session cookies from a developer or administrator viewing the error page, leading to account takeover. Compromise of a privileged account, even in a development environment, can lead to source code theft, introduction of further vulnerabilities, or lateral movement into other corporate systems.
How an attack unfolds
An attacker first identifies a Django application running with the `DEBUG = True` setting. They then craft a malicious request containing a JavaScript payload, specifically designed to trigger a 500 server error. When a developer or administrator investigates the error, the application renders the technical debug page. Due to the lack of HTML autoescaping, the attacker's payload is rendered as executable code, not text. The script runs in the developer's browser, allowing the attacker to perform actions on their behalf, such as exfiltrating session cookies to an attacker-controlled server to hijack their session.
How to fix it
The primary remediation is to upgrade Django to a patched version. For the 1.10.x branch, upgrade to version 1.10.8 or later. For the 1.11.x branch, upgrade to version 1.11.5 or later. As a critical security best practice and a complete mitigation for this specific vulnerability, ensure that all production and internet-facing applications are configured with `DEBUG = False` in their settings file.
How to confirm the fix worked
To confirm remediation, verify that the Django version has been upgraded by running `python -m django --version`. More importantly, audit the settings file (e.g., `settings.py`) of all deployed applications to ensure that the `DEBUG` variable is set to `False`. In a controlled, non-production test environment, you can attempt to validate the vulnerability by setting `DEBUG = True`, triggering a 500 error with a request containing an XSS payload (e.g., `?<script>alert(1)</script>`), and confirming that the script does not execute when viewing the debug page.
Typical attack path
- Attacker discovers a public-facing Django application running with `DEBUG = True`.
- Attacker crafts a request with a malicious script payload that is known to cause a server-side exception (500 error).
- Attacker sends the malicious request to the application.
- A developer or administrator reviews the server logs and accesses the technical 500 debug page to investigate the error.
- The malicious script from the attacker's request executes in the developer's browser.
- The script steals the developer's session cookie and sends it to an attacker-controlled server, enabling account takeover.
How to detect it
To detect potential exploitation attempts, review web server access logs and application logs for requests that resulted in a 500 HTTP status code. Examine the URI, headers, and POST body of these requests for common XSS payloads, such as strings containing `<script>`, `onerror=`, `onload=`, or `javascript:`. Correlating these patterns with 500 errors from a Django application is a key indicator. Monitor for subsequent anomalous activity from developer or administrator accounts, such as logins from unusual IP addresses, which could suggest a successful session hijacking attack.
- requests with HTTP 500 responses containing `<script` in the URI or body
- requests with HTTP 500 responses containing `onerror=` in the URI or body
- requests with HTTP 500 responses containing `onload=` in the URI or body
- requests with HTTP 500 responses containing `javascript:` in the URI or body
What your security team should do
- Immediately audit all web applications to identify any Django instances running in production with `DEBUG = True` and disable it.
- Upgrade all vulnerable Django applications to version 1.10.8+ or 1.11.5+.
- Implement automated checks in CI/CD pipelines to prevent code from being deployed to production with debug mode enabled.
The record
In Django 1.10.x before 1.10.8 and 1.11.x before 1.11.5, HTML autoescaping was disabled in a portion of the template for the technical 500 debug page. Given the right circumstances, this allowed a cross-site scripting attack. This vulnerability shouldn't affect most production sites since you shouldn't run with "DEBUG = True" (which makes this page accessible) in your production settings.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| PyPI | django | 1.10 | 1.10.8 |
| PyPI | django | 1.10.0 | 1.10.8 |
| PyPI | django | 1.10a1 | 1.10.8 |
| PyPI | django | 1.11.0 | 1.11.5 |
| PyPI | django | 1.11a1 | 1.11.5 |
| Alpine:v3.10 | py-django | 0 | 1.11.5-r0 |
| Alpine:v3.11 | py3-django | 0 | 1.11.5-r0 |
| Alpine:v3.12 | py3-django | 0 | 1.11.5-r0 |
| Alpine:v3.6 | py-django | 0 | 1.11.11-r0 |
| Alpine:v3.7 | py-django | 0 | 1.11.5-r0 |
| Alpine:v3.8 | py-django | 0 | 1.11.5-r0 |
| Alpine:v3.9 | py-django | 0 | 1.11.5-r0 |
| Debian:10 | python-django | 0 | 1:1.11.5-1 |
| Debian:11 | python-django | 0 | 1:1.11.5-1 |
| Debian:12 | python-django | 0 | 1:1.11.5-1 |
| Debian:13 | python-django | 0 | 1:1.11.5-1 |
| SUSE:OpenStack Cloud 6 | python-Django | 0 | 1.8.19-3.6.1 |
| SUSE:OpenStack Cloud 7 | python-Django | 0 | 1.8.19-3.4.1 |
| SUSE:Package Hub 12 | python-Django | 0 | 1.11.10-5.1 |
| SUSE:Package Hub 12 SP1 | python-Django | 0 | 1.11.15-2.1 |
| openSUSE:Tumbleweed | python-Django | 0 | 3.2.7-2.3 |
| openSUSE:Tumbleweed | python-Django | 0 | 4.2.11-2.1 |
| openSUSE:Tumbleweed | python-Django4 | 0 | 4.2.14-1.1 |
| openSUSE:Tumbleweed | python-Django6 | 0 | 6.0-1.1 |
| pypi | Django | 1.10a1 | No fix |
| pypi | Django | 1.11a1 | No fix |
Related vulnerabilities
- GHSA-8p8v-wh79-9r56 Django vulnerable to Uncontrolled Resource Consumption Also affects django
- GHSA-mjgh-79qc-68w3 Django has a Race Condition vulnerability Also affects django
- CVE-2026-25673 An issue was discovered in 6.0 before 6.0.3, 5.2 before 5.2.12, and 4.2 before 4.2.29. Also affects django
- CVE-2026-25674 An issue was discovered in 6.0 before 6.0.3, 5.2 before 5.2.12, and 4.2 before 4.2.29. Also affects django
- GHSA-6426-9fv3-65x8 Django has an SQL Injection issue Also affects django
- GHSA-gvg8-93h5-g6qq Django has an SQL Injection issue Also affects django
- GHSA-2mcm-79hx-8fxw Django has Observable Timing Discrepancy Also affects django
- GHSA-33mw-q7rj-mjwj Django has Inefficient Algorithmic Complexity Also affects django