import UBI python3.11-urllib3-1.26.12-5.el8_10

This commit is contained in:
eabdullin 2024-12-17 02:45:25 +00:00
parent 30183000e9
commit d9d58cdc12
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,94 @@
From af0e3db21fcdeaaaa5b0eb58856c776c079a01ec 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 96339e9..5d2e3be 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 ._collections import HTTPHeaderDict
from .request import RequestMethods
from .response import HTTPResponse
from .util.connection import is_connection_dropped
@@ -832,7 +833,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 ca4ec34..5f4afe1 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,
@@ -382,9 +382,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.47.0

View File

@ -8,7 +8,7 @@
Name: python%{python3_pkgversion}-%{srcname}
Version: 1.26.12
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Python HTTP library with thread-safe connection pooling and file post
License: MIT
@ -38,6 +38,12 @@ Patch2: CVE-2024-37891.patch
# CPython change: https://github.com/python/cpython/issues/96931
Patch3: fix_test_ssltransport_py311.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
Patch4: CVE-2023-45803.patch
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-rpm-macros
BuildRequires: python%{python3_pkgversion}-setuptools
@ -132,6 +138,10 @@ ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc \
%changelog
* Tue Nov 19 2024 Charalampos Stratakis <cstratak@redhat.com> - 1.26.12-5
- Security fix for CVE-2023-45803
Resolves: RHEL-66562
* Tue Oct 01 2024 Lumír Balhar <lbalhar@redhat.com> - 1.26.12-4
- Fix test_ssltransport for changes in ssl.SSLSocket in Python 3.11.3
Related: RHEL-59995