CVE-2019-12781: Django - HTTP Request Not Redirected to HTTPS
Summary
CVE-2019-12781: An issue was discovered in Django 1.11 before 1.11.22, 2.1 before 2.1.10, and 2.2 before 2.2.3. Affects django across 3 version ranges.
>= 1.11, < 1.11.22
>= 2.1, < 2.1.10
>= 2.2, < 2.2.3
Fixed in 1.11.22, 2.1.10 or 2.2.3, depending on the release line you run. How to fix ↓
Also tracked for
- py-django · Alpine:v3.10
The same CVE-2019-12781 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Django is a popular Python web framework used for building web applications. It provides a set of tools and libraries to simplify the development process. The framework allows developers to create secure and scalable web applications with ease. However, Django versions 1.11 before 1.11.22, 2.1 before 2.1.10, and 2.2 before 2.2.3 are vulnerable to an issue where an HTTP request is not redirected to HTTPS when certain settings are used. This vulnerability arises when the SECURE_PROXY_SSL_HEADER and SECURE_SSL_REDIRECT settings are enabled, and the proxy connects to Django via HTTPS. The incorrect behavior of the django.http.HttpRequest.scheme method allows the HTTP request to bypass the intended redirection to HTTPS.
Vulnerability Detail
The vulnerability in Django allows an attacker to bypass the intended redirection from HTTP to HTTPS. This means that even if the SECURE_PROXY_SSL_HEADER and SECURE_SSL_REDIRECT settings are enabled, an HTTP request can still be processed without being redirected to the secure HTTPS protocol. This can lead to potential security risks, as sensitive information transmitted over HTTP may be intercepted or modified by attackers. It is important to note that this vulnerability only affects Django applications that use these specific settings and are accessed through a proxy via HTTPS.
How To Fix
Latest published version: 6.1.2 as of 22 Oct 2026
pip install --upgrade "django==6.1.2"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
>= 1.11, < 1.11.221.11.22pip install --upgrade "django==1.11.22" -
>= 2.1, < 2.1.102.1.10pip install --upgrade "django==2.1.10" -
>= 2.2, < 2.2.32.2.3pip install --upgrade "django==2.2.3"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If upgrading Django is not immediately possible, a workaround can be implemented by manually checking the request scheme and redirecting to HTTPS if the scheme is not already secure. Here is an example of how this can be done in Django:
from django.http import HttpResponsePermanentRedirect
def redirect_to_https(request):
if not request.is_secure():
url = request.build_absolute_uri(request.get_full_path())
secure_url = url.replace('http://', 'https://')
return HttpResponsePermanentRedirect(secure_url)
return None
This code snippet checks if the request is not secure (HTTP) and then builds a new URL with the 'https://' scheme. It then returns an HTTP 301 permanent redirect response to the secure URL. This workaround can be added to the Django application's views or middleware to enforce HTTPS redirection.
Conclusion
The vulnerability in Django versions 1.11 before 1.11.22, 2.1 before 2.1.10, and 2.2 before 2.2.3 allows an HTTP request to bypass the intended redirection to HTTPS when certain settings are used. This can lead to potential security risks, as sensitive information transmitted over HTTP may be intercepted or modified by attackers. It is crucial to upgrade Django to the latest secure version or implement the provided workaround to mitigate the risk of this vulnerability. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for django →
FAQ
Django versions 1.11 before 1.11.22, 2.1 before 2.1.10, and 2.2 before 2.2.3 are affected by this vulnerability.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock file, and Vulert will analyze it for any open-source vulnerabilities, including this one.
The vulnerability allows an attacker to bypass the intended redirection from HTTP to HTTPS, potentially exposing sensitive information transmitted over HTTP to interception or modification. This can lead to data breaches, unauthorized access, and other security incidents.
Yes, a workaround is available. By manually checking the request scheme and redirecting to HTTPS if necessary, you can enforce the redirection even if the vulnerability is present. Refer to the 'workaround' section for a code example.
To fix this vulnerability, it is recommended to upgrade Django to version 1.11.22, 2.1.10, or 2.2.3, depending on the version being used. These versions include the necessary fixes to ensure proper redirection from HTTP to HTTPS.
Related vulnerabilities
Recent vulnerabilities recorded for django.