diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-06-13 10:57:29 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-01 08:40:19 +0200 |
| commit | 32124fc41e75074141b05f10fc55a4f01ff7f050 (patch) | |
| tree | d1399e3b88ea69544991003323f7d9e2b8757b2c /django | |
| parent | 58553bb297aaef83009f6e36d889e17c4160d397 (diff) | |
[1.11.x] Fixed CVE-2019-12781 -- Made HttpRequest always trust SECURE_PROXY_SSL_HEADER if set.
An HTTP request would not be redirected to HTTPS when the
SECURE_PROXY_SSL_HEADER and SECURE_SSL_REDIRECT settings were used if
the proxy connected to Django via HTTPS.
HttpRequest.scheme will now always trust the SECURE_PROXY_SSL_HEADER if
set, rather than falling back to the request scheme when the
SECURE_PROXY_SSL_HEADER did not have the secure value.
Thanks to Gavin Wahl for the report and initial patch suggestion, and
Shai Berger for review.
Backport of 54d0f5e62f54c29a12dd96f44bacd810cbe03ac8 from master.
Diffstat (limited to 'django')
| -rw-r--r-- | django/http/request.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/django/http/request.py b/django/http/request.py index 9ffcd23fbd..b573cdb180 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -199,13 +199,14 @@ class HttpRequest(object): def scheme(self): if settings.SECURE_PROXY_SSL_HEADER: try: - header, value = settings.SECURE_PROXY_SSL_HEADER + header, secure_value = settings.SECURE_PROXY_SSL_HEADER except ValueError: raise ImproperlyConfigured( 'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.' ) - if self.META.get(header) == value: - return 'https' + header_value = self.META.get(header) + if header_value is not None: + return 'https' if header_value == secure_value else 'http' return self._get_scheme() def is_secure(self): |
