CVE-2020-7212: urllib3 Denial of Service Vulnerability

urllib3 Updated 02 Oct 2025

Summary

06/03/2020
Yes i
High
7.5

CVE-2020-7212: 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. Affects urllib3 across 2 version ranges.

>= 1.25.2, < 1.25.8 < a74c9cfbaed9f811e7563cfc3dce894928e0221a

Fixed in a74c9cfbaed9f811e7563cfc3dce894928e0221a. How to fix ↓

Also tracked for

The same CVE-2020-7212 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

urllib3 is a powerful HTTP client library for Python, providing a simple and intuitive API for making HTTP requests. It is widely used in various Python applications and frameworks. However, versions 1.25.2 through 1.25.7 of urllib3 are vulnerable to a denial of service (CPU consumption) attack due to an inefficient algorithm in the _encode_invalid_chars function of the util/url.py module. This vulnerability can be exploited by an attacker to cause excessive CPU usage, leading to service degradation or unavailability.

Vulnerability Detail

The _encode_invalid_chars function in urllib3's util/url.py module suffers from an inefficient algorithm. The percent_encodings array, which contains all matches of percent encodings, is not deduplicated. As a result, for a URL of length N, the size of percent_encodings may be up to O(N). The next step, which involves normalizing existing percent-encoded bytes, also takes up to O(N) for each step. Consequently, the total time complexity of the _encode_invalid_chars function is O(N^2). If percent_encodings were deduplicated, the time complexity would be reduced to O(kN), where k is at most 484 ((10+6*2)^2). This vulnerability can be exploited by an attacker to consume excessive CPU resources, potentially leading to a denial of service condition.

How To Fix

Latest published version: 2.8.0 as of 23 Oct 2026

pip install --upgrade "urllib3==2.8.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

a74c9cfbaed9f811e7563cfc3dce894928e0221a

This is the first release that contains the fix.

pip install --upgrade "urllib3==a74c9cfbaed9f811e7563cfc3dce894928e0221a"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. It is strongly advised to upgrade urllib3 to the latest version as soon as possible.

Conclusion

The urllib3 library versions 1.25.2 through 1.25.7 are vulnerable to a denial of service attack due to an inefficient algorithm. It is crucial to upgrade urllib3 to version 1.25.8 or later to mitigate this vulnerability. Failure to do so may result in excessive CPU consumption, leading to service degradation or unavailability. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for urllib3 →

Share this vulnerability

FAQ

urllib3 is a Python library that provides a high-level interface for making HTTP requests. It is commonly used in Python applications and frameworks to handle HTTP communication.

This vulnerability allows an attacker to consume excessive CPU resources, potentially leading to a denial of service condition. This can result in service degradation or unavailability.

Versions 1.25.2 through 1.25.7 of urllib3 are affected by this vulnerability.

No, there is no known workaround for this vulnerability. It is recommended to upgrade urllib3 to the latest version.

You can update urllib3 to the latest version by running the command 'pip install --upgrade urllib3'.

Related vulnerabilities

Recent vulnerabilities recorded for urllib3.

How To Fix

Latest published version: 2.8.0 as of 23 Oct 2026

pip install --upgrade "urllib3==2.8.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

a74c9cfbaed9f811e7563cfc3dce894928e0221a

This is the first release that contains the fix.

pip install --upgrade "urllib3==a74c9cfbaed9f811e7563cfc3dce894928e0221a"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback