[Security] Bump urllib3 from 2.2.1 to 2.6.0 in /{{ cookiecutter.project_slug }}
Bumps urllib3 from 2.2.1 to 2.6.0. This update includes security fixes.
Vulnerabilities fixed
urllib3's Proxy-Authorization request header isn't stripped during cross-origin redirects When using urllib3's proxy support with
ProxyManager, theProxy-Authorizationheader is only sent to the configured proxy, as expected.However, when sending HTTP requests without using urllib3's proxy support, it's possible to accidentally configure the
Proxy-Authorizationheader even though it won't have any effect as the request is not using a forwarding proxy or a tunneling proxy. In those cases, urllib3 doesn't treat theProxy-AuthorizationHTTP header as one carrying authentication material and thus doesn't strip the header on cross-origin redirects.Because this is a highly unlikely scenario, we believe the severity of this vulnerability is low for almost all users. Out of an abundance of caution urllib3 will automatically strip the
Proxy-Authorizationheader during cross-origin redirects to avoid the small chance that users are doing this on accident.Users should use urllib3's proxy support or disable automatic redirects to achieve safe processing of the
Proxy-Authorizationheader, but we still decided to strip the header by default in order to further protect users who aren't using the correct approach.Affected usages
We believe the number of usages affected by this advisory is low. It requires all of the following to be true to be exploited:
- Setting the
Proxy-Authorizationheader without using urllib3's built-in proxy support.- Not disabling HTTP redirects.
- Either not using an HTTPS origin server or for the proxy or target origin to redirect to a malicious origin.
Remediation
- Using the
Proxy-Authorizationheader with urllib3'sProxyManager.- Disabling HTTP redirects using
redirects=Falsewhen sending requests.
... (truncated)
Patched versions: 2.2.2; 1.26.19 Affected versions: >= 2.0.0, < 2.2.2; < 1.26.19
urllib3 redirects are not disabled when retries are disabled on PoolManager instantiation urllib3 handles redirects and retries using the same mechanism, which is controlled by the
Retryobject. The most common way to disable redirects is at the request level, as follows:resp = urllib3.request("GET", "https://httpbin.org/redirect/1", redirect=False) print(resp.status) # 302However, it is also possible to disable redirects, for all requests, by instantiating a
PoolManagerand specifyingretriesin a way that disable redirects:import urllib3 http = urllib3.PoolManager(retries=0) # should raise MaxRetryError on redirect http = urllib3.PoolManager(retries=urllib3.Retry(redirect=0)) # equivalent to the above http = urllib3.PoolManager(retries=False) # should return the first response resp = http.request("GET", "https://httpbin.org/redirect/1")
... (truncated)
Patched versions: 2.5.0 Affected versions: < 2.5.0
urllib3 does not control redirects in browsers and Node.js urllib3 supports being used in a Pyodide runtime utilizing the JavaScript Fetch API or falling back on XMLHttpRequest. This means you can use Python libraries to make HTTP requests from your browser or Node.js. Additionally, urllib3 provides a mechanism to control redirects.
However, the
retriesandredirectparameters are ignored with Pyodide; the runtime itself determines redirect behavior.Affected usages
Any code which relies on urllib3 to control the number of redirects for an HTTP request in a Pyodide runtime.
Impact
Redirects are often used to exploit SSRF vulnerabilities. An application attempting to mitigate SSRF or open redirect vulnerabilities by disabling redirects may remain vulnerable if a Pyodide runtime redirect mechanism is unsuitable.
Remediation
If you use urllib3 in Node.js, upgrade to a patched version of urllib3.
Unfortunately, browsers provide no suitable way which urllib3 can use:
XMLHttpRequestprovides no control over redirects, the Fetch API returnsopaqueredirectresponses lacking data when redirects are controlled manually. Expect default browser behavior for redirects.Patched versions: 2.5.0 Affected versions: >= 2.2.0, < 2.5.0
urllib3 allows an unbounded number of links in the decompression chain
Impact
urllib3 supports chained HTTP encoding algorithms for response content according to RFC 9110 (e.g.,
Content-Encoding: gzip, zstd).However, the number of links in the decompression chain was unbounded allowing a malicious server to insert a virtually unlimited number of compression steps leading to high CPU usage and massive memory allocation for the decompressed data.
Affected usages
Applications and libraries using urllib3 version 2.5.0 and earlier for HTTP requests to untrusted sources unless they disable content decoding explicitly.
Remediation
Upgrade to at least urllib3 v2.6.0 in which the library limits the number of links to 5.
If upgrading is not immediately possible, use
preload_content=Falseand ensure thatresp.headers["content-encoding"]contains a safe number of encodings before reading the response content.Patched versions: 2.6.0 Affected versions: >= 1.24, < 2.6.0
urllib3 streaming API improperly handles highly compressed data
Impact
urllib3's streaming API is designed for the efficient handling of large HTTP responses by reading the content in chunks, rather than loading the entire response body into memory at once.
When streaming a compressed response, urllib3 can perform decoding or decompression based on the HTTP
Content-Encodingheader (e.g.,gzip,deflate,br, orzstd). The library must read compressed data from the network and decompress it until the requested chunk size is met. Any resulting decompressed data that exceeds the requested amount is held in an internal buffer for the next read operation.The decompression logic could cause urllib3 to fully decode a small amount of highly compressed data in a single operation. This can result in excessive resource consumption (high CPU usage and massive memory allocation for the decompressed data; CWE-409) on the client side, even if the application only requested a small chunk of data.
Affected usages
Applications and libraries using urllib3 version 2.5.0 and earlier to stream large compressed responses or content from untrusted sources.
stream(),read(amt=256),read1(amt=256),read_chunked(amt=256),readinto(b)are examples ofurllib3.HTTPResponsemethod calls using the affected logic unless decoding is disabled explicitly.Remediation
Upgrade to at least urllib3 v2.6.0 in which the library avoids decompressing data that exceeds the requested amount.
... (truncated)
Patched versions: 2.6.0 Affected versions: >= 1.0, < 2.6.0
Release notes
Sourced from urllib3's releases.
2.6.0
🚀 urllib3 is fundraising for HTTP/2 supporturllib3 is raising ~$40,000 USD to release HTTP/2 support and ensure long-term sustainable maintenance of the project after a sharp decline in financial support. If your company or organization uses Python and would benefit from HTTP/2 support in Requests, pip, cloud SDKs, and thousands of other projects please consider contributing financially to ensure HTTP/2 support is developed sustainably and maintained for the long-haul.
Thank you for your support.
Security
- Fixed a security issue where streaming API could improperly handle highly compressed HTTP content ("decompression bombs") leading to excessive resource consumption even when a small amount of data was requested. Reading small chunks of compressed data is safer and much more efficient now. (CVE-2025-66471 reported by
@Cycloctane, 8.9 High, GHSA-2xpw-w6gg-jr37)- Fixed a security issue where an attacker could compose an HTTP response with virtually unlimited links in the
Content-Encodingheader, potentially leading to a denial of service (DoS) attack by exhausting system resources during decoding. The number of allowed chained encodings is now limited to 5. (CVE-2025-66418 reported by@illia-v, 8.9 High, GHSA-gm62-xv2j-4w53)[!IMPORTANT]
- If urllib3 is not installed with the optional
urllib3[brotli]extra, but your environment contains a Brotli/brotlicffi/brotlipy package anyway, make sure to upgrade it to at least Brotli 1.2.0 or brotlicffi 1.2.0.0 to benefit from the security fixes and avoid warnings. Prefer usingurllib3[brotli]to install a compatible Brotli package automatically.- If you use custom decompressors, please make sure to update them to respect the changed API of
urllib3.response.ContentDecoder.Features
- Enabled retrieval, deletion, and membership testing in
HTTPHeaderDictusing bytes keys. (#3653)- Added host and port information to string representations of
HTTPConnection. (#3666)- Added support for Python 3.14 free-threading builds explicitly. (#3696)
Removals
- Removed the
HTTPResponse.getheaders()method in favor ofHTTPResponse.headers. Removed theHTTPResponse.getheader(name, default)method in favor ofHTTPResponse.headers.get(name, default). (#3622)Bugfixes
- Fixed redirect handling in
urllib3.PoolManagerwhen an integer is passed for the retries parameter. (#3649)- Fixed
HTTPConnectionPoolwhen used in Emscripten with no explicit port. (#3664)- Fixed handling of
SSLKEYLOGFILEwith expandable variables. (#3700)Misc
- Changed the
zstdextra to installbackports.zstdinstead ofzstandardon Python 3.13 and before. (#3693)- Improved the performance of content decoding by optimizing
BytesQueueBufferclass. (#3710)- Allowed building the urllib3 package with newer setuptools-scm v9.x. (#3652)
- Ensured successful urllib3 builds by setting Hatchling requirement to ≥ 1.27.0. (#3638)
2.5.0
🚀 urllib3 is fundraising for HTTP/2 supporturllib3 is raising ~$40,000 USD to release HTTP/2 support and ensure long-term sustainable maintenance of the project after a sharp decline in financial support. If your company or organization uses Python and would benefit from HTTP/2 support in Requests, pip, cloud SDKs, and thousands of other projects please consider contributing financially to ensure HTTP/2 support is developed sustainably and maintained for the long-haul.
Thank you for your support.
... (truncated)
Changelog
Sourced from urllib3's changelog.
2.6.0 (2025-12-05)
Security
- Fixed a security issue where streaming API could improperly handle highly compressed HTTP content ("decompression bombs") leading to excessive resource consumption even when a small amount of data was requested. Reading small chunks of compressed data is safer and much more efficient now. (
GHSA-2xpw-w6gg-jr37 <https://github.com/urllib3/urllib3/security/advisories/GHSA-2xpw-w6gg-jr37>__)- Fixed a security issue where an attacker could compose an HTTP response with virtually unlimited links in the
Content-Encodingheader, potentially leading to a denial of service (DoS) attack by exhausting system resources during decoding. The number of allowed chained encodings is now limited to 5. (GHSA-gm62-xv2j-4w53 <https://github.com/urllib3/urllib3/security/advisories/GHSA-gm62-xv2j-4w53>__).. caution::
If urllib3 is not installed with the optional
urllib3[brotli]extra, but your environment contains a Brotli/brotlicffi/brotlipy package anyway, make sure to upgrade it to at least Brotli 1.2.0 or brotlicffi 1.2.0.0 to benefit from the security fixes and avoid warnings. Prefer usingurllib3[brotli]to install a compatible Brotli package automatically.If you use custom decompressors, please make sure to update them to respect the changed API of
urllib3.response.ContentDecoder.Features
- Enabled retrieval, deletion, and membership testing in
HTTPHeaderDictusing bytes keys. ([#3653](https://github.com/urllib3/urllib3/issues/3653) <https://github.com/urllib3/urllib3/issues/3653>__)- Added host and port information to string representations of
HTTPConnection. ([#3666](https://github.com/urllib3/urllib3/issues/3666) <https://github.com/urllib3/urllib3/issues/3666>__)- Added support for Python 3.14 free-threading builds explicitly. (
[#3696](https://github.com/urllib3/urllib3/issues/3696) <https://github.com/urllib3/urllib3/issues/3696>__)Removals
- Removed the
HTTPResponse.getheaders()method in favor ofHTTPResponse.headers. Removed theHTTPResponse.getheader(name, default)method in favor ofHTTPResponse.headers.get(name, default). ([#3622](https://github.com/urllib3/urllib3/issues/3622) <https://github.com/urllib3/urllib3/issues/3622>__)Bugfixes
- Fixed redirect handling in
urllib3.PoolManagerwhen an integer is passed for the retries parameter. ([#3649](https://github.com/urllib3/urllib3/issues/3649) <https://github.com/urllib3/urllib3/issues/3649>__)- Fixed
HTTPConnectionPoolwhen used in Emscripten with no explicit port. ([#3664](https://github.com/urllib3/urllib3/issues/3664) <https://github.com/urllib3/urllib3/issues/3664>__)- Fixed handling of
SSLKEYLOGFILEwith expandable variables. ([#3700](https://github.com/urllib3/urllib3/issues/3700) <https://github.com/urllib3/urllib3/issues/3700>__)
... (truncated)
Commits
-
720f484Release 2.6.0 -
24d7b67Merge commit from fork -
c19571dMerge commit from fork -
816fcf0Bump actions/setup-python from 6.0.0 to 6.1.0 (#3725) -
18af0a1Improve speed ofBytesQueueBuffer.get()by using memoryview (#3711) -
1f6abacBump versions of pre-commit hooks (#3716) -
1c8fbf7Bump actions/checkout from 5.0.0 to 6.0.0 (#3722) -
7784b9eAdd Python 3.15 to CI (#3717) -
0241c9eUpdated docs to reflect change in optional zstd dependency fromzstandardt... -
7afcabbExpand environment variable of SSLKEYLOGFILE (#3705) - Additional commits viewable in compare view