Skip to content

Commit 5803bb6

Browse files
authored
Merge pull request #9760 from hroncok/CVE-2021-28363
Update urllib3 to 1.26.4 to fix CVE-2021-28363
2 parents 5bc7b33 + 960c01a commit 5803bb6

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

news/CVE-2021-28363.vendor.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update urllib3 to 1.26.4 to fix CVE-2021-28363

src/pip/_vendor/urllib3/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file is protected via CODEOWNERS
2-
__version__ = "1.26.2"
2+
__version__ = "1.26.4"

src/pip/_vendor/urllib3/connection.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class BrokenPipeError(Exception):
6767

6868
# When it comes time to update this value as a part of regular maintenance
6969
# (ie test_recent_date is failing) update it to ~6 months before the current date.
70-
RECENT_DATE = datetime.date(2019, 1, 1)
70+
RECENT_DATE = datetime.date(2020, 7, 1)
7171

7272
_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")
7373

@@ -215,7 +215,7 @@ def putrequest(self, method, url, *args, **kwargs):
215215

216216
def putheader(self, header, *values):
217217
""""""
218-
if SKIP_HEADER not in values:
218+
if not any(isinstance(v, str) and v == SKIP_HEADER for v in values):
219219
_HTTPConnection.putheader(self, header, *values)
220220
elif six.ensure_str(header.lower()) not in SKIPPABLE_HEADERS:
221221
raise ValueError(
@@ -490,6 +490,10 @@ def _connect_tls_proxy(self, hostname, conn):
490490
self.ca_cert_dir,
491491
self.ca_cert_data,
492492
)
493+
# By default urllib3's SSLContext disables `check_hostname` and uses
494+
# a custom check. For proxies we're good with relying on the default
495+
# verification.
496+
ssl_context.check_hostname = True
493497

494498
# If no cert was provided, use only the default options for server
495499
# certificate validation

src/pip/_vendor/urllib3/exceptions.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,17 @@ class ProxySchemeUnknown(AssertionError, URLSchemeUnknown):
289289
# TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
290290

291291
def __init__(self, scheme):
292-
message = "Not supported proxy scheme %s" % scheme
292+
# 'localhost' is here because our URL parser parses
293+
# localhost:8080 -> scheme=localhost, remove if we fix this.
294+
if scheme == "localhost":
295+
scheme = None
296+
if scheme is None:
297+
message = "Proxy URL had no scheme, should start with http:// or https://"
298+
else:
299+
message = (
300+
"Proxy URL had unsupported scheme %s, should use http:// or https://"
301+
% scheme
302+
)
293303
super(ProxySchemeUnknown, self).__init__(message)
294304

295305

src/pip/_vendor/urllib3/util/retry.py

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def __init__(
253253
"Using 'method_whitelist' with Retry is deprecated and "
254254
"will be removed in v2.0. Use 'allowed_methods' instead",
255255
DeprecationWarning,
256+
stacklevel=2,
256257
)
257258
allowed_methods = method_whitelist
258259
if allowed_methods is _Default:

src/pip/_vendor/vendor.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ requests==2.25.1
1313
certifi==2020.12.05
1414
chardet==4.0.0
1515
idna==2.10
16-
urllib3==1.26.2
16+
urllib3==1.26.4
1717
resolvelib==0.5.4
1818
retrying==1.3.3
1919
setuptools==44.0.0

0 commit comments

Comments
 (0)