Python : Incorrect hostname verification
Classification
Overview
The HTTP clients in the httplib, urllib, urllib2, and xmlrpclib libraries in Python 2.x before 2.7.9 and 3.x before 3.4.3, when accessing a HTTPS URL, do not check the certificate against a trust store or verify that the server hostname matches a domain name in the subject’s Common Name or subjectAltName field of the X.509 certificate, which allows man-in-the-middle attackers to spoof SSL servers via an arbitrary valid certificate
The ssl.match_hostname function in Python before 2.7.9 and 3.x before 3.3.3 does not properly handle wildcards in hostnames, which might allow man-in-the-middle attackers to spoof servers via a crafted certificate.
In Django, you must correctly set the ALLOWED_HOSTS parameter when DEBUG = False. Django checks the host headers on the ALLOWED_HOSTS setting in the django.http.HttpRequest.get_host() method. This security mechanism does not allow attackers to poison the cache or emails with links to malicious hosts by sending requests with a fake HTTP Host header, which is possible even with many seemingly secure web server configurations.
References
- Vulnerability Summary for CVE-2013-7440
- Issue17997 - bugs.python.org
- Host header validation
- Vulnerability Summary for CVE-2014-9365
- Vulnerability Summary for CVE-2013-4238
- Vulnerability Summary for CVE-2013-2099
- OWASP Top 10 2017-A3-Sensitive Data Exposure
- OWASP Top 10 2017-A9-Using Components with Known Vulnerabilities
- CWE CATEGORY: OWASP Top Ten 2017 Category A6 - Security Misconfiguration
