Compare commits

..

No commits in common. 'c9' and 'c8-stream-3.9' have entirely different histories.

2
.gitignore vendored

@ -1 +1 @@
SOURCES/urllib3-1.26.5.tar.gz SOURCES/urllib3-1.25.10.tar.gz

@ -1 +1 @@
2870de19c1a575dab12f5d65080ed65d4957d4b2 SOURCES/urllib3-1.26.5.tar.gz 27f239655e42bc6527918c75acd6826ea52f3d11 SOURCES/urllib3-1.25.10.tar.gz

@ -1,38 +0,0 @@
From f1d40fd07f7b5d9cf846a18fb5a920b4be07dfc5 Mon Sep 17 00:00:00 2001
From: Hasan Ramezani <hasan.r67@gmail.com>
Date: Thu, 20 Jan 2022 15:56:02 +0100
Subject: [PATCH] [1.26] Add server_hostname to SSL_KEYWORDS
---
src/urllib3/poolmanager.py | 1 +
test/with_dummyserver/test_poolmanager.py | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/src/urllib3/poolmanager.py b/src/urllib3/poolmanager.py
index 3a31a285bf..ca4ec34118 100644
--- a/src/urllib3/poolmanager.py
+++ b/src/urllib3/poolmanager.py
@@ -34,6 +34,7 @@
"ca_cert_dir",
"ssl_context",
"key_password",
+ "server_hostname",
)
# All known keyword arguments that could be provided to the pool manager, its
diff --git a/test/with_dummyserver/test_poolmanager.py b/test/with_dummyserver/test_poolmanager.py
index d877cc99ac..fa07a372a9 100644
--- a/test/with_dummyserver/test_poolmanager.py
+++ b/test/with_dummyserver/test_poolmanager.py
@@ -346,6 +346,11 @@ def test_http_with_ssl_keywords(self):
r = http.request("GET", "http://%s:%s/" % (self.host, self.port))
assert r.status == 200
+ def test_http_with_server_hostname(self):
+ with PoolManager(server_hostname="example.com") as http:
+ r = http.request("GET", "http://%s:%s/" % (self.host, self.port))
+ assert r.status == 200
+
def test_http_with_ca_cert_dir(self):
with PoolManager(ca_certs="REQUIRED", ca_cert_dir="/nosuchdir") as http:
r = http.request("GET", "http://%s:%s/" % (self.host, self.port))

@ -0,0 +1,61 @@
From 2d4a3fee6de2fa45eb82169361918f759269b4ec Mon Sep 17 00:00:00 2001
From: Seth Michael Larson <sethmichaellarson@gmail.com>
Date: Wed, 26 May 2021 10:43:12 -0500
Subject: [PATCH] Improve performance of sub-authority splitting in URL
---
src/urllib3/util/url.py | 8 +++++---
test/test_util.py | 10 ++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py
index 6ff238fe3c..81a03da9e3 100644
--- a/src/urllib3/util/url.py
+++ b/src/urllib3/util/url.py
@@ -63,12 +63,12 @@
BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$")
ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$")
-SUBAUTHORITY_PAT = (u"^(?:(.*)@)?(%s|%s|%s)(?::([0-9]{0,5}))?$") % (
+_HOST_PORT_PAT = ("^(%s|%s|%s)(?::([0-9]{0,5}))?$") % (
REG_NAME_PAT,
IPV4_PAT,
IPV6_ADDRZ_PAT,
)
-SUBAUTHORITY_RE = re.compile(SUBAUTHORITY_PAT, re.UNICODE | re.DOTALL)
+_HOST_PORT_RE = re.compile(_HOST_PORT_PAT, re.UNICODE | re.DOTALL)
UNRESERVED_CHARS = set(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~"
@@ -365,7 +365,9 @@ def parse_url(url):
scheme = scheme.lower()
if authority:
- auth, host, port = SUBAUTHORITY_RE.match(authority).groups()
+ auth, _, host_port = authority.rpartition("@")
+ auth = auth or None
+ host, port = _HOST_PORT_RE.match(host_port).groups()
if auth and normalize_uri:
auth = _encode_invalid_chars(auth, USERINFO_CHARS)
if port == "":
diff --git a/test/test_util.py b/test/test_util.py
index a5b68a084b..88409e2d6c 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -438,6 +438,16 @@ def test_netloc(self, url, expected_netloc):
fragment="hash",
),
),
+ # Tons of '@' causing backtracking
+ ("https://" + ("@" * 10000) + "[", False),
+ (
+ "https://user:" + ("@" * 10000) + "example.com",
+ Url(
+ scheme="https",
+ auth="user:" + ("%40" * 9999),
+ host="example.com",
+ ),
+ ),
]
@pytest.mark.parametrize("url, expected_url", url_vulnerabilities)

@ -1,53 +0,0 @@
From 5fe72b64a10e9cb5c5e2b9de46401b6c7bb226e9 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Thu, 12 Oct 2023 14:27:36 +0200
Subject: [PATCH] CVE-2023-43804
---
src/urllib3/util/retry.py | 2 +-
test/test_retry.py | 2 +-
test/test_retry_deprecated.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/urllib3/util/retry.py b/src/urllib3/util/retry.py
index 180e82b..63c02ee 100644
--- a/src/urllib3/util/retry.py
+++ b/src/urllib3/util/retry.py
@@ -217,7 +217,7 @@ class Retry(object):
RETRY_AFTER_STATUS_CODES = frozenset([413, 429, 503])
#: Default headers to be used for ``remove_headers_on_redirect``
- DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(["Authorization"])
+ DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(["Cookie", "Authorization"])
#: Maximum backoff time.
BACKOFF_MAX = 120
diff --git a/test/test_retry.py b/test/test_retry.py
index 3e71efe..e9270bb 100644
--- a/test/test_retry.py
+++ b/test/test_retry.py
@@ -293,7 +293,7 @@ class TestRetry(object):
def test_retry_default_remove_headers_on_redirect(self):
retry = Retry()
- assert list(retry.remove_headers_on_redirect) == ["authorization"]
+ assert retry.remove_headers_on_redirect == {"authorization", "cookie"}
def test_retry_set_remove_headers_on_redirect(self):
retry = Retry(remove_headers_on_redirect=["X-API-Secret"])
diff --git a/test/test_retry_deprecated.py b/test/test_retry_deprecated.py
index eafecc4..d18f94c 100644
--- a/test/test_retry_deprecated.py
+++ b/test/test_retry_deprecated.py
@@ -295,7 +295,7 @@ class TestRetry(object):
def test_retry_default_remove_headers_on_redirect(self):
retry = Retry()
- assert list(retry.remove_headers_on_redirect) == ["authorization"]
+ assert retry.remove_headers_on_redirect == {"authorization", "cookie"}
def test_retry_set_remove_headers_on_redirect(self):
retry = Retry(remove_headers_on_redirect=["X-API-Secret"])
--
2.41.0

@ -1,94 +0,0 @@
From d71ab28f104cac824c6036fa9b35cc2e2dd19bf8 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Tue, 12 Dec 2023 11:06:20 +0100
Subject: [PATCH] Security fix for CVE-2023-45803
---
src/urllib3/_collections.py | 18 ++++++++++++++++++
src/urllib3/connectionpool.py | 5 +++++
src/urllib3/poolmanager.py | 7 +++++--
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/urllib3/_collections.py b/src/urllib3/_collections.py
index da9857e..bceb845 100644
--- a/src/urllib3/_collections.py
+++ b/src/urllib3/_collections.py
@@ -268,6 +268,24 @@ class HTTPHeaderDict(MutableMapping):
else:
return vals[1:]
+ def _prepare_for_method_change(self):
+ """
+ Remove content-specific header fields before changing the request
+ method to GET or HEAD according to RFC 9110, Section 15.4.
+ """
+ content_specific_headers = [
+ "Content-Encoding",
+ "Content-Language",
+ "Content-Location",
+ "Content-Type",
+ "Content-Length",
+ "Digest",
+ "Last-Modified",
+ ]
+ for header in content_specific_headers:
+ self.discard(header)
+ return self
+
# Backwards compatibility for httplib
getheaders = getlist
getallmatchingheaders = getlist
diff --git a/src/urllib3/connectionpool.py b/src/urllib3/connectionpool.py
index 4018321..8f9ebb5 100644
--- a/src/urllib3/connectionpool.py
+++ b/src/urllib3/connectionpool.py
@@ -36,6 +36,7 @@ from .exceptions import (
from .packages import six
from .packages.six.moves import queue
from .packages.ssl_match_hostname import CertificateError
+from ._collections import HTTPHeaderDict
from .request import RequestMethods
from .response import HTTPResponse
from .util.connection import is_connection_dropped
@@ -800,7 +801,11 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
redirect_location = redirect and response.get_redirect_location()
if redirect_location:
if response.status == 303:
+ # Change the method according to RFC 9110, Section 15.4.4.
method = "GET"
+ # And lose the body not to transfer anything sensitive.
+ body = None
+ headers = HTTPHeaderDict(headers)._prepare_for_method_change()
try:
retries = retries.increment(method, url, response=response, _pool=self)
diff --git a/src/urllib3/poolmanager.py b/src/urllib3/poolmanager.py
index 3a31a28..7d4c22c 100644
--- a/src/urllib3/poolmanager.py
+++ b/src/urllib3/poolmanager.py
@@ -4,7 +4,7 @@ import collections
import functools
import logging
-from ._collections import RecentlyUsedContainer
+from ._collections import HTTPHeaderDict, RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme
from .exceptions import (
LocationValueError,
@@ -381,9 +381,12 @@ class PoolManager(RequestMethods):
# Support relative URLs for redirecting.
redirect_location = urljoin(url, redirect_location)
- # RFC 7231, Section 6.4.4
if response.status == 303:
+ # Change the method according to RFC 9110, Section 15.4.4.
method = "GET"
+ # And lose the body not to transfer anything sensitive.
+ kw["body"] = None
+ kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change()
retries = kw.get("retries")
if not isinstance(retries, Retry):
--
2.43.0

@ -1,66 +0,0 @@
From 3606f6166c000213f1e1e9bace3c12f924dd0132 Mon Sep 17 00:00:00 2001
From: Quentin Pradet <quentin.pradet@gmail.com>
Date: Wed, 26 Jun 2024 15:56:34 +0200
Subject: [PATCH] Merge pull request from GHSA-34jh-p97f-mpxf
* [1.26] Strip Proxy-Authorization header on redirects
* Set release date
---
src/urllib3/util/retry.py | 4 +++-
test/test_retry.py | 6 +++++-
test/test_retry_deprecated.py | 6 +++++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/urllib3/util/retry.py b/src/urllib3/util/retry.py
index 63c02ee..42fa619 100644
--- a/src/urllib3/util/retry.py
+++ b/src/urllib3/util/retry.py
@@ -217,7 +217,9 @@ class Retry(object):
RETRY_AFTER_STATUS_CODES = frozenset([413, 429, 503])
#: Default headers to be used for ``remove_headers_on_redirect``
- DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(["Cookie", "Authorization"])
+ DEFAULT_REMOVE_HEADERS_ON_REDIRECT = frozenset(
+ ["Cookie", "Authorization", "Proxy-Authorization"]
+ )
#: Maximum backoff time.
BACKOFF_MAX = 120
diff --git a/test/test_retry.py b/test/test_retry.py
index e9270bb..cf60bf1 100644
--- a/test/test_retry.py
+++ b/test/test_retry.py
@@ -293,7 +293,11 @@ class TestRetry(object):
def test_retry_default_remove_headers_on_redirect(self):
retry = Retry()
- assert retry.remove_headers_on_redirect == {"authorization", "cookie"}
+ assert retry.remove_headers_on_redirect == {
+ "authorization",
+ "proxy-authorization",
+ "cookie",
+ }
def test_retry_set_remove_headers_on_redirect(self):
retry = Retry(remove_headers_on_redirect=["X-API-Secret"])
diff --git a/test/test_retry_deprecated.py b/test/test_retry_deprecated.py
index d18f94c..a107f7b 100644
--- a/test/test_retry_deprecated.py
+++ b/test/test_retry_deprecated.py
@@ -295,7 +295,11 @@ class TestRetry(object):
def test_retry_default_remove_headers_on_redirect(self):
retry = Retry()
- assert retry.remove_headers_on_redirect == {"authorization", "cookie"}
+ assert retry.remove_headers_on_redirect == {
+ "authorization",
+ "proxy-authorization",
+ "cookie",
+ }
def test_retry_set_remove_headers_on_redirect(self):
retry = Retry(remove_headers_on_redirect=["X-API-Secret"])
--
2.44.0

@ -1,12 +1,12 @@
%global srcname urllib3 %global srcname urllib3
# Tests are disabled to remove the test dependencies # When bootstrapping Python, we cannot test this yet
# Specify --with tests to run the tests on e.g. EPEL # RHEL8: Tests disabled during build due to missing dependencies
%bcond_with tests %bcond_with tests
Name: python-%{srcname} Name: python-%{srcname}
Version: 1.26.5 Version: 1.25.10
Release: 5%{?dist}.1 Release: 4%{?dist}
Summary: Python HTTP library with thread-safe connection pooling and file post Summary: Python HTTP library with thread-safe connection pooling and file post
License: MIT License: MIT
@ -14,61 +14,42 @@ URL: https://github.com/urllib3/urllib3
Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
# Unbundle ssl_match_hostname since we depend on it # Unbundle ssl_match_hostname since we depend on it
Source1: ssl_match_hostname_py3.py Source1: ssl_match_hostname_py3.py
# CVE-2021-33503 Catastrophic backtracking in URL authority parser
# Tracking bug: https://bugzilla.redhat.com/show_bug.cgi?id=1968074
# Upstream fix: https://github.com/urllib3/urllib3/commit/2d4a3fee6de2fa45eb82169361918f759269b4ec
Patch0: CVE-2021-33503.patch
BuildArch: noarch BuildArch: noarch
# Exclude i686 arch. Due to a modularity issue it's being added to the
# CVE-2023-43804 # x86_64 compose of CRB, but we don't want to ship it at all.
# Added the `Cookie` header to the list of headers to strip from # See: https://projects.engineering.redhat.com/browse/RCM-72605
# requests when redirecting to a different host. As before, different headers ExcludeArch: i686
# can be set via `Retry.remove_headers_on_redirect`.
# Tests backported only partially as we don't use the whole part of
# testing with dummyserver.
# Tracking bug: https://bugzilla.redhat.com/show_bug.cgi?id=2242493
# Upstream fix: https://github.com/urllib3/urllib3/commit/01220354d389cd05474713f8c982d05c9b17aafb
Patch1: CVE-2023-43804.patch
# CVE-2023-45803
# Remove HTTP request body when request method is changed.
# Tracking bug: https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2023-45803
# Upstream fix: https://github.com/urllib3/urllib3/commit/4e98d57809dacab1cbe625fddeec1a290c478ea9
Patch2: CVE-2023-45803.patch
# PoolManager.urlopen fails with TypeError for http connection if the PoolManager is instantiated with server_hostname
# Tracking bug: https://issues.redhat.com/browse/RHEL-39285
# Upstream fix: https://github.com/urllib3/urllib3/commit/f1d40fd07f7b5d9cf846a18fb5a920b4be07dfc5
Patch3: Add-server_hostname-to-SSL_KEYWORDS.patch
# CVE-2024-37891
# Proxy-authorization request header is not stripped during cross-origin redirects.
# Tracking bug: https://issues.redhat.com/browse/RHEL-43172
# Upstream fix: https://github.com/urllib3/urllib3/commit/40b6d1605814dd1db0a46e202d6e56f2e4c9a468
Patch4: CVE-2024-37891.patch
%description %description
Python HTTP module with connection pooling and file POST abilities. Python HTTP module with connection pooling and file POST abilities.
%package -n python3-%{srcname} %package -n python%{python3_pkgversion}-%{srcname}
Summary: Python3 HTTP library with thread-safe connection pooling and file post Summary: Python3 HTTP library with thread-safe connection pooling and file post
BuildRequires: python3-devel BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python3-setuptools BuildRequires: python%{python3_pkgversion}-rpm-macros
BuildRequires: python%{python3_pkgversion}-setuptools
%if %{with tests} %if %{with tests}
BuildRequires: python3-dateutil BuildRequires: python%{python3_pkgversion}-nose
BuildRequires: python3-six BuildRequires: python%{python3_pkgversion}-mock
BuildRequires: python3-pysocks BuildRequires: python%{python3_pkgversion}-six
BuildRequires: python3-pytest BuildRequires: python%{python3_pkgversion}-pysocks
BuildRequires: python3-pytest-freezegun BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python3-pytest-timeout BuildRequires: python%{python3_pkgversion}-tornado
BuildRequires: python3-tornado BuildRequires: python%{python3_pkgversion}-trustme
BuildRequires: python3-trustme BuildRequires: python%{python3_pkgversion}-idna
BuildRequires: python3-idna
%endif %endif
Requires: ca-certificates Requires: ca-certificates
Requires: python3-idna Requires: python%{python3_pkgversion}-idna
Requires: python3-six Requires: python%{python3_pkgversion}-six
Requires: python3-pysocks Requires: python%{python3_pkgversion}-pysocks
%description -n python3-%{srcname} %description -n python%{python3_pkgversion}-%{srcname}
Python3 HTTP module with connection pooling and file POST abilities. Python3 HTTP module with connection pooling and file POST abilities.
@ -105,11 +86,6 @@ rm -rf test/contrib/
# fail when combined with the unbundling of backports-ssl_match_hostname # fail when combined with the unbundling of backports-ssl_match_hostname
rm -f test/test_no_ssl.py rm -f test/test_no_ssl.py
# Use the standard library instead of a backport
sed -i -e 's/^import mock/from unittest import mock/' \
-e 's/^from mock import /from unittest.mock import /' \
test/*.py docs/conf.py
%build %build
%py3_build %py3_build
@ -118,8 +94,8 @@ sed -i -e 's/^import mock/from unittest import mock/' \
%py3_install %py3_install
# Unbundle the Python 3 build # Unbundle the Python 3 build
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py*
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/six.* rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/six*
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname/ rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname/
mkdir -p %{buildroot}/%{python3_sitelib}/urllib3/packages/ mkdir -p %{buildroot}/%{python3_sitelib}/urllib3/packages/
@ -133,11 +109,13 @@ ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc \
%if %{with tests} %if %{with tests}
%check %check
%pytest -v pushd test
PYTHONPATH=%{buildroot}%{python3_sitelib}:%{python3_sitelib} %{__python3} -m pytest -v
popd
%endif %endif
%files -n python3-%{srcname} %files -n python%{python3_pkgversion}-%{srcname}
%license LICENSE.txt %license LICENSE.txt
%doc CHANGES.rst README.rst CONTRIBUTORS.txt %doc CHANGES.rst README.rst CONTRIBUTORS.txt
%{python3_sitelib}/urllib3/ %{python3_sitelib}/urllib3/
@ -145,50 +123,13 @@ ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc \
%changelog %changelog
* Tue Jun 18 2024 Tomáš Hrnčiar <thrnciar@redhat.com> - 1.26.5-5.1 * Tue Jun 29 2021 Lumír Balhar <lbalhar@redhat.com> - 1.25.10-4
- Security fix for CVE-2024-37891
- Backport upstream patch to fix TypeError for http connection if the PoolManager
- is instantiated with server_hostname
Resolves: RHEL-49853
* Tue Dec 12 2023 Lumír Balhar <lbalhar@redhat.com> - 1.26.5-5
- Security fix for CVE-2023-45803
Resolves: RHEL-16874
* Thu Oct 12 2023 Lumír Balhar <lbalhar@redhat.com> - 1.26.5-4
- Security fix for CVE-2023-43804
Resolves: RHEL-12001
* Tue Feb 08 2022 Tomáš Hrnčiar <thrnciar@redhat.com> - 1.26.5-3
- Add automatically generated Obsoletes tag with the python39- prefix
for smoother upgrade from RHEL8
- Related: rhbz#1990421
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 1.26.5-2
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Jun 16 2021 Karolina Surma <ksurma@redhat.com> - 1.26.5-1
- Update to 1.26.5
- Fix for CVE-2021-33503 Catastrophic backtracking in URL authority parser - Fix for CVE-2021-33503 Catastrophic backtracking in URL authority parser
Resolves: rhbz#1972639 Resolves: rhbz#1968074
* Tue May 18 2021 Miro Hrončok <mhroncok@redhat.com> - 1.26.4-1
- Update to 1.26.4
Resolves: rhbz#1935737
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.25.10-6
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Mon Mar 08 2021 Charalampos Stratakis <cstratak@redhat.com> - 1.25.10-5
- Disable tests on RHEL9 to remove the python-tornado dependency
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.25.10-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Fri Jan 15 2021 Miro Hrončok <mhroncok@redhat.com> - 1.25.10-3 * Wed Jan 13 2021 Tomas Orsava <torsava@redhat.com> - 1.25.10-3
- Drop redundant BuildRequires for nose - Convert from Fedora to the python39 module in RHEL8
- Instead of the mock backport, use unittest.mock from the standard library - Resolves: rhbz#1877430
* Tue Jan 05 2021 Anna Khaitovich <akhaitov@redhat.com> - 1.25.10-2 * Tue Jan 05 2021 Anna Khaitovich <akhaitov@redhat.com> - 1.25.10-2
- Update RECENT_DATE dynamically - Update RECENT_DATE dynamically

Loading…
Cancel
Save