diff options
| author | Andreas Hug <andreas.hug@moccu.com> | 2018-07-24 16:18:17 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-08-01 09:28:42 -0400 |
| commit | a656a681272f8f3734b6eb38e9a88aa0d91806f1 (patch) | |
| tree | 84b5b88a03bbee88e8a72912d5bfe29d6ccea7d2 /django/middleware/common.py | |
| parent | 7dbe7aa0b6f9d006800375cf5d8b71416869ce91 (diff) | |
Fixed CVE-2018-14574 -- Fixed open redirect possibility in CommonMiddleware.
Diffstat (limited to 'django/middleware/common.py')
| -rw-r--r-- | django/middleware/common.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py index bea3f7448a..a18fbe7b47 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -7,6 +7,7 @@ from django.core.mail import mail_managers from django.http import HttpResponsePermanentRedirect from django.urls import is_valid_path from django.utils.deprecation import MiddlewareMixin +from django.utils.http import escape_leading_slashes class CommonMiddleware(MiddlewareMixin): @@ -79,6 +80,8 @@ class CommonMiddleware(MiddlewareMixin): POST, PUT, or PATCH. """ new_path = request.get_full_path(force_append_slash=True) + # Prevent construction of scheme relative urls. + new_path = escape_leading_slashes(new_path) if settings.DEBUG and request.method in ('POST', 'PUT', 'PATCH'): raise RuntimeError( "You called this URL via %(method)s, but the URL doesn't end " |
