diff options
| author | Andreas Hug <andreas.hug@moccu.com> | 2018-07-24 16:18:17 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-07-31 10:37:29 -0400 |
| commit | 6fffc3c6d420e44f4029d5643f38d00a39b08525 (patch) | |
| tree | 31633bc12b5f6705f19e8e998773fceba820ab78 /django/middleware/common.py | |
| parent | af344691114e4a68334c30543bfb838996328212 (diff) | |
[2.0.x] 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 d8cfb9a8b0..ea5e536655 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -11,6 +11,7 @@ from django.utils.cache import ( cc_delim_re, get_conditional_response, set_response_etag, ) from django.utils.deprecation import MiddlewareMixin, RemovedInDjango21Warning +from django.utils.http import escape_leading_slashes class CommonMiddleware(MiddlewareMixin): @@ -88,6 +89,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 " |
