Skip to content

Upgrading urllib3 0.2 to 1

Breaking0.2 โ†’ 1.26.20Breaking3Security13Platform1Deprecated6New7Changed8Fixed22Other16

BreakingUpgrade verdict

3 breaking changes and a platform requirement change and 13 security fixes.

  • Remove "!" character from the unreserved characters in IPv6 Zone ID parsing (.
  • Removed deprecated HTTPResponse.getheaders() calls in urllib3.contrib module.
  • Removed the <4 in the Requires-Python packaging metadata field.
  • Removed support for Python 3.5.
Top 5 of 23 that need code or config changes

Requires Python !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7 from 1.26.19 (none stated before).

Breaking3
Remove "!" character from the unreserved characters in IPv6 Zone ID parsing (.
Removed deprecated HTTPResponse.getheaders() calls in urllib3.contrib module.
HTTPResponse.getheaders()urllib3.contrib
Removed the <4 in the Requires-Python packaging metadata field.
Requires-Python
Security13
Adds the Proxy-Authorization header to the list of headers stripped from requests when redirecting to a different host.
Proxy-AuthorizationRetry.remove_headers_on_redirect
urllib3's Proxy-Authorization request header isn't stripped during cross-origin redirects
Medium ยท CVSS 4.4
Made body stripped from HTTP requests changing the request method to GET after HTTP 303 "See Other" redirect responses.
Medium ยท CVSS 4.2
Added the Cookie header to the list of headers to strip from requests when redirecting to a different host.
CookieRetry.remove_headers_on_redirectHigh ยท CVSS 8.1
An issue was discovered in urllib3 before 1.26.5. When provided with a URL containing many @ characters in the authority component, the authority regular expression exhibits catastrophic backtracking, causing a denial of service if a URL were passed as a parameter or redirected to via an HTTP redirect.
The urllib3 library 1.26.x before 1.26.4 for Python omits SSL certificate validation in some cases involving HTTPS to HTTPS proxies. The initial connection to the HTTPS proxy (if an SSLContext isn't given via proxy_config) doesn't verify the hostname of the certificate. This means certificates for different servers that still validate properly with the default urllib3 SSLContext will be silently accepted.
urllib3 before 1.25.9 allows CRLF injection if the attacker controls the HTTP request method, as demonstrated by inserting CR and LF control characters in the first argument of putrequest(). NOTE: this is similar to CVE-2020-26116.
The _encode_invalid_chars function in util/url.py in the urllib3 library 1.25.2 through 1.25.7 for Python allows a denial of service (CPU consumption) because of an inefficient algorithm. The percent_encodings array contains all matches of percent encodings. It is not deduplicated. For a URL of length N, the size of percent_encodings may be up to O(N). The next step (normalize existing percent-encoded bytes) also takes up to O(N) for each step, so the total time is O(N^2). If percent_encodings were deduplicated, the time to compute _encode_invalid_chars would be O(kN), where k is at most 484 ((10+6*2)^2).
In the urllib3 library through 1.24.1 for Python, CRLF injection is possible if the attacker controls the request parameter.
urllib3 before 1.24.2 does not remove the authorization HTTP header when following a cross-origin redirect (i.e., a redirect that differs in host, port, or scheme). This can allow for credentials in the authorization header to be exposed to unintended hosts or transmitted in cleartext. NOTE: this issue exists because of an incomplete fix for CVE-2018-20060 (which was case-sensitive).
Medium ยท CVSS 6.1
The urllib3 library before 1.24.2 for Python mishandles certain cases where the desired set of CA certificates is different from the OS store of CA certificates, which results in SSL connections succeeding in situations where a verification failure is the correct outcome. This is related to use of the ssl_context, ca_certs, or ca_certs_dir argument.
urllib3 before version 1.23 does not remove the Authorization HTTP header when following a cross-origin redirect (i.e., a redirect that differs in host, port, or scheme). This can allow for credentials in the Authorization header to be exposed to unintended hosts or transmitted in cleartext.
Versions 1.17 and 1.18 of the Python urllib3 library suffer from a vulnerability that can cause them, in certain configurations, to not correctly validate TLS certificates. This places users of the library with those configurations at risk of man-in-the-middle and information leakage attacks. This vulnerability affects users using versions 1.17 and 1.18 of the urllib3 library, who are using the optional PyOpenSSL support for TLS instead of the regular standard library TLS backend, and who are using OpenSSL 1.1.0 via PyOpenSSL. This is an extremely uncommon configuration, so the security impact of this vulnerability is low.
Platform1
Removed support for Python 3.5.
Deprecated6
Deprecated the HTTPResponse.getheaders() and HTTPResponse.getheader() methods.
HTTPResponse.getheaders()HTTPResponse.getheader()
Deprecated the urllib3[secure] extra and the urllib3.contrib.pyopenssl module.
urllib3[secure]urllib3.contrib.pyopenssl
Deprecated the Retry.MAX_BACKOFF class property in favor of Retry.DEFAULT_MAX_BACKOFF to better match the rest of the default parameter names.
Retry.MAX_BACKOFFRetry.DEFAULT_MAX_BACKOFF
Deprecated the urllib3.contrib.ntlmpool module. urllib3 is not able to support it properly due to reasons listed in this issue.
urllib3.contrib.ntlmpool
Deprecated negotiating TLSv1 and TLSv1.1 by default.
ssl_version=ssl.PROTOCOL_TLSv1_1DeprecationWarning
Deprecated Retry options Retry.DEFAULT_METHOD_WHITELIST, Retry.DEFAULT_REDIRECT_HEADERS_BLACKLIST and Retry(method_whitelist=...) in favor of Retry.DEFAULT_ALLOWED_METHODSโ€ฆ
RetryRetry.DEFAULT_METHOD_WHITELISTRetry.DEFAULT_REDIRECT_HEADERS_BLACKLISTRetry(method_whitelist=...)Retry.DEFAULT_ALLOWED_METHODSRetry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT