Improper Handling of Unicode Encoding in Python
Summary
CVE-2019-9636: Python 2.7.x through 2.7.16 and 3.x through 3.7.2 is affected by: Improper Handling of Unicode Encoding (with an incorrect netloc) during NFKC normalization. Affects python2 across 2 version ranges.
< 2.7.16-r1
< c2f86d86e6c8f5fd1ef602128b537a48f3f5c063
Fixed in 2.7.16-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 is widely used for web development, data analysis, and automation tasks. The vulnerability, CVE-2019-9636, affects Python versions 2.7.x through 2.7.16 and 3.x through 3.7.2. It specifically targets the urllib.parse.urlsplit and urllib.parse.urlparse components, which are responsible for parsing URLs. The vulnerability arises from an improper handling of Unicode encoding, specifically when dealing with an incorrect netloc during NFKC normalization.
Vulnerability Detail
The vulnerability allows for information disclosure, potentially exposing sensitive data such as credentials and cookies. When a specially crafted URL is incorrectly parsed, it can lead to the retrieval of cached data against a given hostname and send that information to a different host. This can result in unauthorized access and potential misuse of sensitive data. The impact of this vulnerability is significant, as it can compromise the security and integrity of affected systems.
How To Fix
Minimum fixed version
2.7.16-r1
This is the first release that contains the fix.
sudo apk add --upgrade python2
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a workaround, it is advised to sanitize and validate user input before passing it to the affected components. This can help prevent the exploitation of the vulnerability. Here is an example of how to sanitize a URL using the urllib.parse module in Python:
import urllib.parse
url = 'https://example.com/';
Sanitize and validate the URL
sanitized_url = urllib.parse.quote(url, safe=':/')
Use the sanitized URL in further processing
print(sanitized_url)
Conclusion
The vulnerability CVE-2019-9636 in Python's urllib.parse.urlsplit and urllib.parse.urlparse components can lead to information disclosure and potential unauthorized access to sensitive data. It is crucial to update to the fixed Python versions mentioned in the 'how_to_fix' section to mitigate this vulnerability. Additionally, sanitizing and validating user input can serve as a temporary workaround. For further assistance and support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for python2 →
FAQ
The vulnerability can lead to information disclosure, potentially exposing sensitive data such as credentials and cookies. It can be exploited to retrieve cached data against a given hostname and send it to a different host.
Python versions 2.7.x through 2.7.16 and 3.x through 3.7.2 are affected.
Update your Python installation to one of the fixed versions mentioned in the 'how_to_fix' section.
Yes, you can sanitize and validate user input before passing it to the affected components to mitigate the vulnerability. Refer to the 'workaround' section for an example.
You can find more information about this vulnerability, including its technical details and the fixed versions, in the provided CVE-2019-9636.json file.
References
Related vulnerabilities
Recent vulnerabilities recorded for python2.