Security advisory
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).
- Products
- Not specified
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2020-7212
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 31 Oct 2026, 11:30 UTC · Revision 1
Source evidence
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).
osv:CVE-2020-7212
Complete source record
{
"id": "0f642bd385ce72cb055edc0f3a559c32b84df7f962bcfa2bcd5458966d88857b",
"url": "https://osv.dev/vulnerability/CVE-2020-7212",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "CVE-2020-7212",
"summary": "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).",
"evidence": "osv:CVE-2020-7212",
"products": [],
"severity": "high",
"structured": {
"id": "CVE-2020-7212",
"aliases": [
"CVE-2020-7212",
"GHSA-hmv2-79q8-fv6g",
"PYSEC-2020-149"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://github.com/urllib3/urllib3",
"type": "GIT",
"events": [
{
"introduced": "49eea8082ab34094d0c53f1d26e5c588d5372d74"
},
{
"last_affected": "37ba61a8b8120cbd866d057eaa3936f4b140dee0"
},
{
"fixed": "a74c9cfbaed9f811e7563cfc3dce894928e0221a"
}
],
"database_specific": {
"extracted_events": [
{
"cpe": "cpe:2.3:a:python:urllib3:*:*:*:*:*:*:*:*",
"range": [
{
"introduced": "1.25.2"
},
{
"last_affected": "1.25.7"
}
],
"source": "CPE_RANGE"
},
{
"range": [
{
"fixed": "a74c9cfbaed9f811e7563cfc3dce894928e0221a"
}
],
"source": "REFERENCES_COMMIT"
}
]
}
}
],
"versions": [
"1.25.7",
"1.25.6",
"1.25.5",
"1.25.4",
"1.25.3",
"1.25.2"
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2020-7212.json"
}
}
],
"modified": "2026-10-20T10:54:23.662174666Z",
"provider": "osv",
"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"
],
"provider_metadata": {}
},
"related_cves": [
{
"value": "CVE-2020-7212",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 385272,
"published_at": "2020-03-06T20:15:12.707+00:00"
}