CVE-2026-19553
Missing server_hostname in wrap_bio() bypasses hostname verification despite check_hostname=True.
- CVSS 7.6
- CWE-297
- Authentication, Authorization, and Session Management
- Local
ssl.SSLContext.wrap_bio() didn't require the server_hostname argument to not be None if ssl.SSLContext.check_hostname was set. Due to a missing parameter check in SSLObject, if the server_hostname argument isn't supplied then hostname verification would be silently skipped. This defect could lead to programs where certificate hostname verification *appeared* to be succeeding with SSLContext.check_hostname = True and no ValueError being raised due to misconfiguration. If the program passes a server_hostname value that isn't an empty string or None to any of these APIs then certificate hostname verification proceeds as expected and the program is not affected by this vulnerability. Mitigating this vulnerability doesn't require updating Python or applying the patch. To mitigate, pass a valid non-None and non-empty server_hostname value to SSLContext.wrap_bio(), asyncio.create_connection(), or asyncio.loop.start_tls() and certificate hostname verification will proceed as expected. Upgrading to the latest version of Python or applying the patch only changes the behavior from silently skipping hostname verification to raising a ValueError, similar to SSLContext.wrap_socket(), when server_hostname isn't supplied.
- CWE
- CWE-297
- CVSS base score
- 7.6
- Published
- 2026-09-30
- OWASP
- A02 Cryptographic Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Authentication, Authorization, and Session Management
- Subcategory
- Insecure Authentication Mechanisms
- Accessibility scope
- Local
- Impact
- Information Disclosure
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Upgrade Python to a version where the fix is included (e.g., Python 3.12.0 or later / 3.11.6 or later).
Vulnerable code sample
import ssl
import socket
def fetch_data(host, port):
ctx = ssl.create_default_context()
ctx.check_hostname = True
# VULNERABLE: missing server_hostname disables hostname verification
ssl_obj = ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO())
sock = socket.create_connection((host, port))
ssl_obj.do_handshake()
# ... exchange data ...
sock.close()Patched code sample
import ssl
import socket
def fetch_data(host, port):
ctx = ssl.create_default_context()
ctx.check_hostname = True
# FIX: provide server_hostname to enforce verification
ssl_obj = ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), server_hostname=host)
sock = socket.create_connection((host, port))
ssl_obj.do_handshake()
# ... exchange data ...
sock.close()Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- gh-156793: Validate SSLContext.wrap_bio() parameters like wrap_socket() (#158503) (python/cpython)
Lib/ssl.py,Lib/ssl.py · SSLObject._create,Lib/ssl.py · SSLSocket._create - [3.10] gh-156793: Validate SSLContext.wrap_bio() parameters like wrap_socket() (GH-158503) (#158533) (python/cpython)
Lib/ssl.py · SSLObject._create - [3.15] gh-156793: Validate SSLContext.wrap_bio() parameters like wrap_socket() (GH-158503) (#158511) (python/cpython)
Lib/ssl.py · SSLSocket._create
Cite this entry
@misc{vaitp:cve202619553,
title = {{Missing server_hostname in wrap_bio() bypasses hostname verification despite check_hostname=True.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-19553},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-19553/}}
}
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 ::
