Uncontrolled Resource Consumption in urllib3
Published 30 Apr 2021 · Updated 18 Nov 2024
Is your project on an affected urllib3?
Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- >=1.25.2 <1.25.8
- Fixed in
- 1.25.8
pip install 'urllib3>=1.25.8'Details
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).
Is GHSA-hmv2-79q8-fv6g in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected urllib3, and gives you the command that fixes it.
More advisories for urllib3
- MediumCVE-2026-97688urllib3: Chunked Deflate streaming can enter an infinite loop · 30 Sept 2026
- HighCVE-2026-97689urllib3: HTTPResponse.stream()/read_chunked() buffers an unbounded chunk-size line into memory · 30 Sept 2026
- HighCVE-2026-97687urllib3: HTTPS proxy TLS configuration may be ignored or overridden · 30 Sept 2026
- HighCVE-2026-44432urllib3: Decompression-bomb safeguards bypassed in parts of the streaming API · 11 May 2026
- HighCVE-2026-44431urllib3: Sensitive headers forwarded across origins in proxied low-level redirects · 11 May 2026
- HighCVE-2026-21441Decompression-bomb safeguards bypassed when following HTTP redirects (streaming API) · 7 Jan 2026
References
- Advisorynvd.nist.gov/vuln/detail/CVE-2020-7212
- Linkgithub.com/urllib3/urllib3/commit/a74c9cfbaed9f811e7563cfc3dce894928e0221a
- Advisorygithub.com/advisories/GHSA-hmv2-79q8-fv6g
- Linkgithub.com/pypa/advisory-database/tree/main/vulns/urllib3/PYSEC-2020-149.yaml
- Packagegithub.com/urllib3/urllib3
- Linkgithub.com/urllib3/urllib3/blob/master/CHANGES.rst
- Linkpypi.org/project/urllib3/1.25.8
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.