diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2021-11-29 11:52:03 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-12-07 06:28:08 +0100 |
| commit | d4dcd5b9dd9e462fec8220e33e3e6c822b7e88a6 (patch) | |
| tree | 662b56e783c369cb07b42065c8ff49eac4acd5c0 /django/urls | |
| parent | 628b6a686974698cbf820bad72f10dad133174ec (diff) | |
Fixed #30530, CVE-2021-44420 -- Fixed potential bypass of an upstream access control based on URL paths.
Thanks Sjoerd Job Postmus and TengMA(@te3t123) for reports.
Diffstat (limited to 'django/urls')
| -rw-r--r-- | django/urls/resolvers.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py index 6ea18dd22f..110ad87cdb 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -165,7 +165,11 @@ class RegexPattern(CheckURLMixin): self.converters = {} def match(self, path): - match = self.regex.search(path) + match = ( + self.regex.fullmatch(path) + if self._is_endpoint and self.regex.pattern.endswith('$') + else self.regex.search(path) + ) if match: # If there are any named groups, use those as kwargs, ignoring # non-named groups. Otherwise, pass all non-named arguments as @@ -255,7 +259,7 @@ def _route_to_regex(route, is_endpoint=False): converters[parameter] = converter parts.append('(?P<' + parameter + '>' + converter.regex + ')') if is_endpoint: - parts.append('$') + parts.append(r'\Z') return ''.join(parts), converters |
