import python3-3.6.8-48.el8_7.1
This commit is contained in:
parent
93994c4d72
commit
d01f487196
130
SOURCES/00386-cve-2021-28861.patch
Normal file
130
SOURCES/00386-cve-2021-28861.patch
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Miss Islington (bot)"
|
||||||
|
<31488909+miss-islington@users.noreply.github.com>
|
||||||
|
Date: Wed, 22 Jun 2022 15:05:00 -0700
|
||||||
|
Subject: [PATCH] 00386: CVE-2021-28861
|
||||||
|
|
||||||
|
Fix an open redirection vulnerability in the `http.server` module when
|
||||||
|
an URI path starts with `//` that could produce a 301 Location header
|
||||||
|
with a misleading target. Vulnerability discovered, and logic fix
|
||||||
|
proposed, by Hamza Avvan (@hamzaavvan).
|
||||||
|
|
||||||
|
Test and comments authored by Gregory P. Smith [Google].
|
||||||
|
(cherry picked from commit 4abab6b603dd38bec1168e9a37c40a48ec89508e)
|
||||||
|
|
||||||
|
Upstream: https://github.com/python/cpython/pull/93879
|
||||||
|
Tracking bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2120642
|
||||||
|
|
||||||
|
Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
||||||
|
---
|
||||||
|
Lib/http/server.py | 7 +++
|
||||||
|
Lib/test/test_httpservers.py | 53 ++++++++++++++++++-
|
||||||
|
...2-06-15-20-09-23.gh-issue-87389.QVaC3f.rst | 3 ++
|
||||||
|
3 files changed, 61 insertions(+), 2 deletions(-)
|
||||||
|
create mode 100644 Misc/NEWS.d/next/Security/2022-06-15-20-09-23.gh-issue-87389.QVaC3f.rst
|
||||||
|
|
||||||
|
diff --git a/Lib/http/server.py b/Lib/http/server.py
|
||||||
|
index 60a4dadf03..ce05be13d3 100644
|
||||||
|
--- a/Lib/http/server.py
|
||||||
|
+++ b/Lib/http/server.py
|
||||||
|
@@ -323,6 +323,13 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
|
||||||
|
return False
|
||||||
|
self.command, self.path, self.request_version = command, path, version
|
||||||
|
|
||||||
|
+ # gh-87389: The purpose of replacing '//' with '/' is to protect
|
||||||
|
+ # against open redirect attacks possibly triggered if the path starts
|
||||||
|
+ # with '//' because http clients treat //path as an absolute URI
|
||||||
|
+ # without scheme (similar to http://path) rather than a path.
|
||||||
|
+ if self.path.startswith('//'):
|
||||||
|
+ self.path = '/' + self.path.lstrip('/') # Reduce to a single /
|
||||||
|
+
|
||||||
|
# Examine the headers and look for a Connection directive.
|
||||||
|
try:
|
||||||
|
self.headers = http.client.parse_headers(self.rfile,
|
||||||
|
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
|
||||||
|
index 66e937e04b..5a0a7c3f74 100644
|
||||||
|
--- a/Lib/test/test_httpservers.py
|
||||||
|
+++ b/Lib/test/test_httpservers.py
|
||||||
|
@@ -324,7 +324,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
- BaseTestCase.setUp(self)
|
||||||
|
+ super().setUp()
|
||||||
|
self.cwd = os.getcwd()
|
||||||
|
basetempdir = tempfile.gettempdir()
|
||||||
|
os.chdir(basetempdir)
|
||||||
|
@@ -343,7 +343,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
- BaseTestCase.tearDown(self)
|
||||||
|
+ super().tearDown()
|
||||||
|
|
||||||
|
def check_status_and_reason(self, response, status, data=None):
|
||||||
|
def close_conn():
|
||||||
|
@@ -399,6 +399,55 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
||||||
|
self.check_status_and_reason(response, HTTPStatus.OK,
|
||||||
|
data=support.TESTFN_UNDECODABLE)
|
||||||
|
|
||||||
|
+ def test_get_dir_redirect_location_domain_injection_bug(self):
|
||||||
|
+ """Ensure //evil.co/..%2f../../X does not put //evil.co/ in Location.
|
||||||
|
+
|
||||||
|
+ //netloc/ in a Location header is a redirect to a new host.
|
||||||
|
+ https://github.com/python/cpython/issues/87389
|
||||||
|
+
|
||||||
|
+ This checks that a path resolving to a directory on our server cannot
|
||||||
|
+ resolve into a redirect to another server.
|
||||||
|
+ """
|
||||||
|
+ os.mkdir(os.path.join(self.tempdir, 'existing_directory'))
|
||||||
|
+ url = f'/python.org/..%2f..%2f..%2f..%2f..%2f../%0a%0d/../{self.tempdir_name}/existing_directory'
|
||||||
|
+ expected_location = f'{url}/' # /python.org.../ single slash single prefix, trailing slash
|
||||||
|
+ # Canonicalizes to /tmp/tempdir_name/existing_directory which does
|
||||||
|
+ # exist and is a dir, triggering the 301 redirect logic.
|
||||||
|
+ response = self.request(url)
|
||||||
|
+ self.check_status_and_reason(response, HTTPStatus.MOVED_PERMANENTLY)
|
||||||
|
+ location = response.getheader('Location')
|
||||||
|
+ self.assertEqual(location, expected_location, msg='non-attack failed!')
|
||||||
|
+
|
||||||
|
+ # //python.org... multi-slash prefix, no trailing slash
|
||||||
|
+ attack_url = f'/{url}'
|
||||||
|
+ response = self.request(attack_url)
|
||||||
|
+ self.check_status_and_reason(response, HTTPStatus.MOVED_PERMANENTLY)
|
||||||
|
+ location = response.getheader('Location')
|
||||||
|
+ self.assertFalse(location.startswith('//'), msg=location)
|
||||||
|
+ self.assertEqual(location, expected_location,
|
||||||
|
+ msg='Expected Location header to start with a single / and '
|
||||||
|
+ 'end with a / as this is a directory redirect.')
|
||||||
|
+
|
||||||
|
+ # ///python.org... triple-slash prefix, no trailing slash
|
||||||
|
+ attack3_url = f'//{url}'
|
||||||
|
+ response = self.request(attack3_url)
|
||||||
|
+ self.check_status_and_reason(response, HTTPStatus.MOVED_PERMANENTLY)
|
||||||
|
+ self.assertEqual(response.getheader('Location'), expected_location)
|
||||||
|
+
|
||||||
|
+ # If the second word in the http request (Request-URI for the http
|
||||||
|
+ # method) is a full URI, we don't worry about it, as that'll be parsed
|
||||||
|
+ # and reassembled as a full URI within BaseHTTPRequestHandler.send_head
|
||||||
|
+ # so no errant scheme-less //netloc//evil.co/ domain mixup can happen.
|
||||||
|
+ attack_scheme_netloc_2slash_url = f'https://pypi.org/{url}'
|
||||||
|
+ expected_scheme_netloc_location = f'{attack_scheme_netloc_2slash_url}/'
|
||||||
|
+ response = self.request(attack_scheme_netloc_2slash_url)
|
||||||
|
+ self.check_status_and_reason(response, HTTPStatus.MOVED_PERMANENTLY)
|
||||||
|
+ location = response.getheader('Location')
|
||||||
|
+ # We're just ensuring that the scheme and domain make it through, if
|
||||||
|
+ # there are or aren't multiple slashes at the start of the path that
|
||||||
|
+ # follows that isn't important in this Location: header.
|
||||||
|
+ self.assertTrue(location.startswith('https://pypi.org/'), msg=location)
|
||||||
|
+
|
||||||
|
def test_get(self):
|
||||||
|
#constructs the path relative to the root directory of the HTTPServer
|
||||||
|
response = self.request(self.base_url + '/test')
|
||||||
|
diff --git a/Misc/NEWS.d/next/Security/2022-06-15-20-09-23.gh-issue-87389.QVaC3f.rst b/Misc/NEWS.d/next/Security/2022-06-15-20-09-23.gh-issue-87389.QVaC3f.rst
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..029d437190
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/Misc/NEWS.d/next/Security/2022-06-15-20-09-23.gh-issue-87389.QVaC3f.rst
|
||||||
|
@@ -0,0 +1,3 @@
|
||||||
|
+:mod:`http.server`: Fix an open redirection vulnerability in the HTTP server
|
||||||
|
+when an URI path starts with ``//``. Vulnerability discovered, and initial
|
||||||
|
+fix proposed, by Hamza Avvan.
|
1381
SOURCES/00387-cve-2020-10735-prevent-dos-by-very-large-int.patch
Normal file
1381
SOURCES/00387-cve-2020-10735-prevent-dos-by-very-large-int.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,95 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Miss Islington (bot)"
|
||||||
|
<31488909+miss-islington@users.noreply.github.com>
|
||||||
|
Date: Mon, 7 Nov 2022 19:22:14 -0800
|
||||||
|
Subject: [PATCH] 00394: CVE-2022-45061: CPU denial of service via inefficient
|
||||||
|
IDNA decoder
|
||||||
|
|
||||||
|
gh-98433: Fix quadratic time idna decoding.
|
||||||
|
|
||||||
|
There was an unnecessary quadratic loop in idna decoding. This restores
|
||||||
|
the behavior to linear.
|
||||||
|
|
||||||
|
(cherry picked from commit a6f6c3a3d6f2b580f2d87885c9b8a9350ad7bf15)
|
||||||
|
|
||||||
|
Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
|
||||||
|
Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
||||||
|
---
|
||||||
|
Lib/encodings/idna.py | 32 +++++++++----------
|
||||||
|
Lib/test/test_codecs.py | 6 ++++
|
||||||
|
...2-11-04-09-29-36.gh-issue-98433.l76c5G.rst | 6 ++++
|
||||||
|
3 files changed, 27 insertions(+), 17 deletions(-)
|
||||||
|
create mode 100644 Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst
|
||||||
|
|
||||||
|
diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py
|
||||||
|
index ea4058512f..bf98f51336 100644
|
||||||
|
--- a/Lib/encodings/idna.py
|
||||||
|
+++ b/Lib/encodings/idna.py
|
||||||
|
@@ -39,23 +39,21 @@ def nameprep(label):
|
||||||
|
|
||||||
|
# Check bidi
|
||||||
|
RandAL = [stringprep.in_table_d1(x) for x in label]
|
||||||
|
- for c in RandAL:
|
||||||
|
- if c:
|
||||||
|
- # There is a RandAL char in the string. Must perform further
|
||||||
|
- # tests:
|
||||||
|
- # 1) The characters in section 5.8 MUST be prohibited.
|
||||||
|
- # This is table C.8, which was already checked
|
||||||
|
- # 2) If a string contains any RandALCat character, the string
|
||||||
|
- # MUST NOT contain any LCat character.
|
||||||
|
- if any(stringprep.in_table_d2(x) for x in label):
|
||||||
|
- raise UnicodeError("Violation of BIDI requirement 2")
|
||||||
|
-
|
||||||
|
- # 3) If a string contains any RandALCat character, a
|
||||||
|
- # RandALCat character MUST be the first character of the
|
||||||
|
- # string, and a RandALCat character MUST be the last
|
||||||
|
- # character of the string.
|
||||||
|
- if not RandAL[0] or not RandAL[-1]:
|
||||||
|
- raise UnicodeError("Violation of BIDI requirement 3")
|
||||||
|
+ if any(RandAL):
|
||||||
|
+ # There is a RandAL char in the string. Must perform further
|
||||||
|
+ # tests:
|
||||||
|
+ # 1) The characters in section 5.8 MUST be prohibited.
|
||||||
|
+ # This is table C.8, which was already checked
|
||||||
|
+ # 2) If a string contains any RandALCat character, the string
|
||||||
|
+ # MUST NOT contain any LCat character.
|
||||||
|
+ if any(stringprep.in_table_d2(x) for x in label):
|
||||||
|
+ raise UnicodeError("Violation of BIDI requirement 2")
|
||||||
|
+ # 3) If a string contains any RandALCat character, a
|
||||||
|
+ # RandALCat character MUST be the first character of the
|
||||||
|
+ # string, and a RandALCat character MUST be the last
|
||||||
|
+ # character of the string.
|
||||||
|
+ if not RandAL[0] or not RandAL[-1]:
|
||||||
|
+ raise UnicodeError("Violation of BIDI requirement 3")
|
||||||
|
|
||||||
|
return label
|
||||||
|
|
||||||
|
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
|
||||||
|
index 56485de3f6..a798d1f287 100644
|
||||||
|
--- a/Lib/test/test_codecs.py
|
||||||
|
+++ b/Lib/test/test_codecs.py
|
||||||
|
@@ -1640,6 +1640,12 @@ class IDNACodecTest(unittest.TestCase):
|
||||||
|
self.assertEqual("pyth\xf6n.org".encode("idna"), b"xn--pythn-mua.org")
|
||||||
|
self.assertEqual("pyth\xf6n.org.".encode("idna"), b"xn--pythn-mua.org.")
|
||||||
|
|
||||||
|
+ def test_builtin_decode_length_limit(self):
|
||||||
|
+ with self.assertRaisesRegex(UnicodeError, "too long"):
|
||||||
|
+ (b"xn--016c"+b"a"*1100).decode("idna")
|
||||||
|
+ with self.assertRaisesRegex(UnicodeError, "too long"):
|
||||||
|
+ (b"xn--016c"+b"a"*70).decode("idna")
|
||||||
|
+
|
||||||
|
def test_stream(self):
|
||||||
|
r = codecs.getreader("idna")(io.BytesIO(b"abc"))
|
||||||
|
r.read(3)
|
||||||
|
diff --git a/Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst b/Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..5185fac2e2
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst
|
||||||
|
@@ -0,0 +1,6 @@
|
||||||
|
+The IDNA codec decoder used on DNS hostnames by :mod:`socket` or :mod:`asyncio`
|
||||||
|
+related name resolution functions no longer involves a quadratic algorithm.
|
||||||
|
+This prevents a potential CPU denial of service if an out-of-spec excessive
|
||||||
|
+length hostname involving bidirectional characters were decoded. Some protocols
|
||||||
|
+such as :mod:`urllib` http ``3xx`` redirects potentially allow for an attacker
|
||||||
|
+to supply such a name.
|
@ -14,7 +14,7 @@ URL: https://www.python.org/
|
|||||||
# WARNING When rebasing to a new Python version,
|
# WARNING When rebasing to a new Python version,
|
||||||
# remember to update the python3-docs package as well
|
# remember to update the python3-docs package as well
|
||||||
Version: %{pybasever}.8
|
Version: %{pybasever}.8
|
||||||
Release: 48%{?dist}
|
Release: 48%{?dist}.1
|
||||||
License: Python
|
License: Python
|
||||||
|
|
||||||
|
|
||||||
@ -695,6 +695,76 @@ Patch378: 00378-support-expat-2-4-5.patch
|
|||||||
# Tracker bug: https://bugzilla.redhat.com/show_bug.cgi?id=2075390
|
# Tracker bug: https://bugzilla.redhat.com/show_bug.cgi?id=2075390
|
||||||
Patch382: 00382-cve-2015-20107.patch
|
Patch382: 00382-cve-2015-20107.patch
|
||||||
|
|
||||||
|
# 00386 #
|
||||||
|
# CVE-2021-28861
|
||||||
|
#
|
||||||
|
# Fix an open redirection vulnerability in the `http.server` module when
|
||||||
|
# an URI path starts with `//` that could produce a 301 Location header
|
||||||
|
# with a misleading target. Vulnerability discovered, and logic fix
|
||||||
|
# proposed, by Hamza Avvan (@hamzaavvan).
|
||||||
|
#
|
||||||
|
# Test and comments authored by Gregory P. Smith [Google].
|
||||||
|
#
|
||||||
|
# Upstream: https://github.com/python/cpython/pull/93879
|
||||||
|
# Tracking bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2120642
|
||||||
|
Patch386: 00386-cve-2021-28861.patch
|
||||||
|
|
||||||
|
# 00387 #
|
||||||
|
# CVE-2020-10735: Prevent DoS by very large int()
|
||||||
|
#
|
||||||
|
# gh-95778: CVE-2020-10735: Prevent DoS by very large int() (GH-96504)
|
||||||
|
#
|
||||||
|
# Converting between `int` and `str` in bases other than 2
|
||||||
|
# (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10 (decimal) now
|
||||||
|
# raises a `ValueError` if the number of digits in string form is above a
|
||||||
|
# limit to avoid potential denial of service attacks due to the algorithmic
|
||||||
|
# complexity. This is a mitigation for CVE-2020-10735
|
||||||
|
# (https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735).
|
||||||
|
#
|
||||||
|
# This new limit can be configured or disabled by environment variable, command
|
||||||
|
# line flag, or :mod:`sys` APIs. See the `Integer String Conversion Length
|
||||||
|
# Limitation` documentation. The default limit is 4300
|
||||||
|
# digits in string form.
|
||||||
|
#
|
||||||
|
# Patch by Gregory P. Smith [Google] and Christian Heimes [Red Hat] with feedback
|
||||||
|
# from Victor Stinner, Thomas Wouters, Steve Dower, Ned Deily, and Mark Dickinson.
|
||||||
|
#
|
||||||
|
# Notes on the backport to Python 3.6 in RHEL:
|
||||||
|
#
|
||||||
|
# * Use "Python 3.6.8-48" version in the documentation, whereas this
|
||||||
|
# version will never be released
|
||||||
|
# * Only add _Py_global_config_int_max_str_digits global variable:
|
||||||
|
# Python 3.6 doesn't have PyConfig API (PEP 597) nor _PyRuntime.
|
||||||
|
# * sys.flags.int_max_str_digits cannot be -1 on Python 3.6: it is
|
||||||
|
# set to the default limit. Adapt test_int_max_str_digits() for that.
|
||||||
|
# * Declare _PY_LONG_DEFAULT_MAX_STR_DIGITS and
|
||||||
|
# _PY_LONG_MAX_STR_DIGITS_THRESHOLD macros in longobject.h but only
|
||||||
|
# if the Py_BUILD_CORE macro is defined.
|
||||||
|
# * Declare _Py_global_config_int_max_str_digits in pydebug.h.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# gh-95778: Mention sys.set_int_max_str_digits() in error message (#96874)
|
||||||
|
#
|
||||||
|
# When ValueError is raised if an integer is larger than the limit,
|
||||||
|
# mention sys.set_int_max_str_digits() in the error message.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# gh-96848: Fix -X int_max_str_digits option parsing (#96988)
|
||||||
|
#
|
||||||
|
# Fix command line parsing: reject "-X int_max_str_digits" option with
|
||||||
|
# no value (invalid) when the PYTHONINTMAXSTRDIGITS environment
|
||||||
|
# variable is set to a valid limit.
|
||||||
|
Patch387: 00387-cve-2020-10735-prevent-dos-by-very-large-int.patch
|
||||||
|
|
||||||
|
# 00394 #
|
||||||
|
# CVE-2022-45061: CPU denial of service via inefficient IDNA decoder
|
||||||
|
#
|
||||||
|
# gh-98433: Fix quadratic time idna decoding.
|
||||||
|
#
|
||||||
|
# There was an unnecessary quadratic loop in idna decoding. This restores
|
||||||
|
# the behavior to linear.
|
||||||
|
Patch394: 00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decoder.patch
|
||||||
|
|
||||||
# (New patches go here ^^^)
|
# (New patches go here ^^^)
|
||||||
#
|
#
|
||||||
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
||||||
@ -1037,6 +1107,9 @@ git apply %{PATCH351}
|
|||||||
%patch377 -p1
|
%patch377 -p1
|
||||||
%patch378 -p1
|
%patch378 -p1
|
||||||
%patch382 -p1
|
%patch382 -p1
|
||||||
|
%patch386 -p1
|
||||||
|
%patch387 -p1
|
||||||
|
%patch394 -p1
|
||||||
|
|
||||||
# Remove files that should be generated by the build
|
# Remove files that should be generated by the build
|
||||||
# (This is after patching, so that we can use patches directly from upstream)
|
# (This is after patching, so that we can use patches directly from upstream)
|
||||||
@ -1962,6 +2035,10 @@ fi
|
|||||||
# ======================================================
|
# ======================================================
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Dec 21 2022 Charalampos Stratakis <cstratak@redhat.com> - 3.6.8-48.1
|
||||||
|
- Security fixes for CVE-2020-10735, CVE-2021-28861 and CVE-2022-45061
|
||||||
|
Resolves: rhbz#1834423, rhbz#2120642, rhbz#2144072
|
||||||
|
|
||||||
* Thu Oct 20 2022 Charalampos Stratakis <cstratak@redhat.com> - 3.6.8-48
|
* Thu Oct 20 2022 Charalampos Stratakis <cstratak@redhat.com> - 3.6.8-48
|
||||||
- Release bump
|
- Release bump
|
||||||
Resolves: rhbz#2136436
|
Resolves: rhbz#2136436
|
||||||
|
Loading…
Reference in New Issue
Block a user