diff options
| author | Marius Bakke <marius@gnu.org> | 2020-12-08 22:48:19 +0100 |
|---|---|---|
| committer | Marius Bakke <marius@gnu.org> | 2020-12-08 22:57:53 +0100 |
| commit | f936a300b48955faecce028ac9ac509b1b83906c (patch) | |
| tree | 9bbd4b1c1c02bc89a10f5b4f77b06a7d37173073 /gnu | |
| parent | 6d9b23cbf2a799b50aacde8d31ef4c3e45160856 (diff) | |
gnu: Python: Fix CVE-2020-26116.
* gnu/packages/patches/python-CVE-2020-26116.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
* gnu/packages/python.scm (python-3.8)[source](patches): Add it.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/patches/python-CVE-2020-26116.patch | 47 | ||||
| -rw-r--r-- | gnu/packages/python.scm | 1 |
3 files changed, 49 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 7f0b69cacf9..897de3eaf91 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -1515,6 +1515,7 @@ dist_patch_DATA = \ | |||
| 1515 | %D%/packages/patches/python-3-fix-tests.patch \ | 1515 | %D%/packages/patches/python-3-fix-tests.patch \ |
| 1516 | %D%/packages/patches/python-3.8-fix-tests.patch \ | 1516 | %D%/packages/patches/python-3.8-fix-tests.patch \ |
| 1517 | %D%/packages/patches/python-CVE-2018-14647.patch \ | 1517 | %D%/packages/patches/python-CVE-2018-14647.patch \ |
| 1518 | %D%/packages/patches/python-CVE-2020-26116.patch \ | ||
| 1518 | %D%/packages/patches/python-aionotify-0.2.0-py3.8.patch \ | 1519 | %D%/packages/patches/python-aionotify-0.2.0-py3.8.patch \ |
| 1519 | %D%/packages/patches/python-argcomplete-1.11.1-fish31.patch \ | 1520 | %D%/packages/patches/python-argcomplete-1.11.1-fish31.patch \ |
| 1520 | %D%/packages/patches/python-axolotl-AES-fix.patch \ | 1521 | %D%/packages/patches/python-axolotl-AES-fix.patch \ |
diff --git a/gnu/packages/patches/python-CVE-2020-26116.patch b/gnu/packages/patches/python-CVE-2020-26116.patch new file mode 100644 index 00000000000..dc0571e9646 --- /dev/null +++ b/gnu/packages/patches/python-CVE-2020-26116.patch | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | Fix CVE-2020-26116: | ||
| 2 | |||
| 3 | https://cve.circl.lu/cve/CVE-2020-26116 | ||
| 4 | https://bugs.python.org/issue39603 | ||
| 5 | |||
| 6 | Taken from upstream (sans test and NEWS update): | ||
| 7 | https://github.com/python/cpython/commit/668d321476d974c4f51476b33aaca870272523bf | ||
| 8 | |||
| 9 | diff --git a/Lib/http/client.py b/Lib/http/client.py | ||
| 10 | --- a/Lib/http/client.py | ||
| 11 | +++ b/Lib/http/client.py | ||
| 12 | @@ -147,6 +147,10 @@ | ||
| 13 | # _is_allowed_url_pchars_re = re.compile(r"^[/!$&'()*+,;=:@%a-zA-Z0-9._~-]+$") | ||
| 14 | # We are more lenient for assumed real world compatibility purposes. | ||
| 15 | |||
| 16 | +# These characters are not allowed within HTTP method names | ||
| 17 | +# to prevent http header injection. | ||
| 18 | +_contains_disallowed_method_pchar_re = re.compile('[\x00-\x1f]') | ||
| 19 | + | ||
| 20 | # We always set the Content-Length header for these methods because some | ||
| 21 | # servers will otherwise respond with a 411 | ||
| 22 | _METHODS_EXPECTING_BODY = {'PATCH', 'POST', 'PUT'} | ||
| 23 | @@ -1087,6 +1091,8 @@ def putrequest(self, method, url, skip_host=False, | ||
| 24 | else: | ||
| 25 | raise CannotSendRequest(self.__state) | ||
| 26 | |||
| 27 | + self._validate_method(method) | ||
| 28 | + | ||
| 29 | # Save the method for use later in the response phase | ||
| 30 | self._method = method | ||
| 31 | |||
| 32 | @@ -1177,6 +1183,15 @@ def _encode_request(self, request): | ||
| 33 | # ASCII also helps prevent CVE-2019-9740. | ||
| 34 | return request.encode('ascii') | ||
| 35 | |||
| 36 | + def _validate_method(self, method): | ||
| 37 | + """Validate a method name for putrequest.""" | ||
| 38 | + # prevent http header injection | ||
| 39 | + match = _contains_disallowed_method_pchar_re.search(method) | ||
| 40 | + if match: | ||
| 41 | + raise ValueError( | ||
| 42 | + f"method can't contain control characters. {method!r} " | ||
| 43 | + f"(found at least {match.group()!r})") | ||
| 44 | + | ||
| 45 | def _validate_path(self, url): | ||
| 46 | """Validate a url for putrequest.""" | ||
| 47 | # Prevent CVE-2019-9740. | ||
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index 43704bccae2..533b2bdefff 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm | |||
| @@ -370,6 +370,7 @@ data types.") | |||
| 370 | (uri (string-append "https://www.python.org/ftp/python/" | 370 | (uri (string-append "https://www.python.org/ftp/python/" |
| 371 | version "/Python-" version ".tar.xz")) | 371 | version "/Python-" version ".tar.xz")) |
| 372 | (patches (search-patches | 372 | (patches (search-patches |
| 373 | "python-CVE-2020-26116.patch" | ||
| 373 | "python-3-fix-tests.patch" | 374 | "python-3-fix-tests.patch" |
| 374 | "python-3.8-fix-tests.patch" | 375 | "python-3.8-fix-tests.patch" |
| 375 | "python-3-deterministic-build-info.patch" | 376 | "python-3-deterministic-build-info.patch" |
