CVE-2020-14422: Improper Hash Value Computation in Python's ipaddress Module
Summary
CVE-2020-14422: Lib/ipaddress.py in Python through 3.8.3 improperly computes hash values in the IPv4Interface and IPv6Interface classes, which might allow a remote attacker to cause a denial of service if an application is affected by t... Affects python3 across 2 version ranges.
< 3.7.7-r1
< 426b022776672fdf3d71ddd98d89af341c88080f
Fixed in 3.7.7-r1. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
Python is a popular programming language known for its simplicity and versatility. It provides a built-in module called 'ipaddress' that allows developers to manipulate and handle IP addresses and networks. However, a vulnerability has been discovered in this module that affects Python versions up to 3.8.3. The vulnerability lies in the improper computation of hash values in the IPv4Interface and IPv6Interface classes. This flaw can be exploited by a remote attacker to cause a denial of service (DoS) attack if an application is impacted by the performance of a dictionary containing IPv4Interface or IPv6Interface objects. The attacker can create numerous dictionary entries, overwhelming the application's resources.
Vulnerability Detail
The vulnerability, identified as CVE-2020-14422, originates from the incorrect hash value computation in Python's ipaddress module. This flaw allows a remote attacker to exploit the performance of a dictionary containing IPv4Interface or IPv6Interface objects, potentially leading to a DoS attack. By creating a large number of dictionary entries, the attacker can exhaust the application's resources and disrupt its normal functioning. The vulnerability affects Python versions up to 3.8.3.
How To Fix
Minimum fixed version
3.7.7-r1
This is the first release that contains the fix.
sudo apk add --upgrade python3
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a workaround, developers can implement their own hash functions for the IPv4Interface and IPv6Interface classes, ensuring that the computation is performed correctly. Here is an example of a custom hash function for the IPv4Interface class:
import ipaddress
class CustomIPv4Interface(ipaddress.IPv4Interface):
def __hash__(self):
return hash((self._ip, self.network.prefixlen))
Conclusion
The vulnerability CVE-2020-14422 in Python's ipaddress module allows a remote attacker to perform a denial of service attack by exploiting the improper hash value computation. To mitigate this vulnerability, it is crucial to update to the fixed Python versions mentioned earlier. Implementing custom hash functions can serve as a temporary workaround. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for python3 →
FAQ
The vulnerability allows a remote attacker to cause a denial of service (DoS) attack by overwhelming an application's resources. This can lead to service disruption and potential downtime.
Python versions up to 3.8.3 are affected by this vulnerability.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply upload your manifest file (e.g., package-lock.json) and the tool will analyze it for any open-source vulnerabilities, including CVE-2020-14422.
Yes, developers can implement their own hash functions for the IPv4Interface and IPv6Interface classes to ensure correct computation. However, it is recommended to update to the fixed Python versions mentioned earlier.
You can find more information about this vulnerability, including technical details and the fix, in the official CVE-2020-14422 JSON report: https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2020-14422.json
References
Related vulnerabilities
Recent vulnerabilities recorded for python3.