Uncontrolled Resource Consumption in urllib3
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).
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| Python (PyPI) | urllib3 | >= 1.25.2, < 1.25.8 | 1.25.8 |
References
- https://github.com/urllib3/urllib3/blob/master/CHANGES.rst
- https://pypi.org/project/urllib3/1.25.8/
- https://github.com/urllib3/urllib3/commit/a74c9cfbaed9f811e7563cfc3dce894928e0221a
- https://github.com/advisories/GHSA-hmv2-79q8-fv6g
- https://nvd.nist.gov/vuln/detail/CVE-2020-7212
- https://github.com/pypa/advisory-database/tree/main/vulns/urllib3/PYSEC-2020-149.yaml
- https://github.com/urllib3/urllib3
- https://pypi.org/project/urllib3/1.25.8
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H- Weakness (CWE)
CWE-400- Platform
- Python (PyPI)
- Package
urllib3- Disclosed
- 06.03.2020
- Updated
- 11.10.2026 11:20
Sources and licenses
OSV / GitHub Advisory Database - PYSEC-2020-149 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-hmv2-79q8-fv6g - CC BY 4.0
Vulnerability history: urllib3
All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 22
- First → latest
- 01.2017 09.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- Critical 1
- High 11
- Medium 10
Disclosures per year
- 2017: 1
- 2018: 1
- 2019: 2
- 2020: 2
- 2021: 2
- 2022: 0
- 2023: 3
- 2024: 1
- 2025: 4
- 2026: 6
-
Uncontrolled Resource Consumption in urllib3 this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.