CVE-2015-2674
SSL.wrap_socket with CERT_NONE in Python allows MITM attacks to spoof TLS servers
- CVSS 5.9
- CWE-295 Improper Certificate Validation
- Cryptographic
- Remote
Restkit allows man-in-the-middle attackers to spoof TLS servers by leveraging use of the ssl.wrap_socket function in Python with the default CERT_NONE value for the cert_reqs argument.
- CVSS base score
- 5.9
- Published
- 2017-08-09
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Cryptographic
- Subcategory
- Improper SSL/TLS Certificate Validation
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Affected component
- Restkit
- Fixed by upgrading
- Yes
Solution
Update Restkit to a version that addresses the vulnerability.
Vulnerable code sample
import ssl
import socket
# Create a secure socket without proper certificate verification
def create_insecure_socket(host, port):
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.verify_mode = ssl.CERT_NONE # This allows for certificate verification to be bypassed
with socket.create_connection((host, port)) as sock:
with context.wrap_socket(sock, server_hostname=host) as insecure_sock:
return insecure_sock
# Example usage
insecure_socket = create_insecure_socket('example.com', 443)Patched code sample
import ssl
import socket
# Create a secure socket with proper certificate verification
def create_secure_socket(host, port):
context = ssl.create_default_context() # Create a context that verifies certificates
# Alternatively, you can specify ssl.CERT_REQUIRED for strict verification
# context.verify_mode = ssl.CERT_REQUIRED
with socket.create_connection((host, port)) as sock:
with context.wrap_socket(sock, server_hostname=host) as secure_sock:
return secure_sock
# Example usage
secure_socket = create_secure_socket('example.com', 443)Cite this entry
@misc{vaitp:cve20152674,
title = {{SSL.wrap_socket with CERT_NONE in Python allows MITM attacks to spoof TLS servers}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2017},
note = {VAITP Python Vulnerability Dataset, entry CVE-2015-2674},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2015-2674/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
