BIT-python-min-2026-19553: SSLContext.wrap_bio() missing validation of server_hostname parameter
ssl.SSLContext.wrapbio() didn't require the serverhostname argument to not be None if ssl.SSLContext.checkhostname was set. Due to a missing parameter check in SSLObject, if the serverhostname 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.checkhostname = True and no ValueError being raised due to misconfiguration.
If the program passes a serverhostname 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 serverhostname value to SSLContext.wrapbio(), asyncio.createconnection(), or asyncio.loop.starttls() 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.wrapsocket(), when serverhostname isn't supplied.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Pass a valid non-None and non-empty server_hostname value to these APIs when SSLContext.check_hostname is enabled, so certificate hostname verification proceeds as expected.
Python ssl APIs (SSLContext.wrap_bio(), SSLContext.wrap_socket(), asyncio.create_connection(), and asyncio.loop.start_tls()) server_hostname = valid, non-None, and non-empty string
Event History
Frequently Asked Questions
Which applications are affected?
Applications are affected if they enable SSLContext.check_hostname and call SSLContext.wrap_bio(), asyncio.create_connection(), or asyncio.loop.start_tls() without a server_hostname value, or with None or an empty string. Calls that provide a non-empty, non-None server_hostname perform hostname verification as expected.
What can be done if updating Python is not immediately possible?
Pass a valid, non-None and non-empty server_hostname value to SSLContext.wrap_bio(), asyncio.create_connection(), or asyncio.loop.start_tls(). This causes certificate hostname verification to proceed as expected and does not require a Python update or patch.
How can I identify affected code?
Review uses of SSLContext.wrap_bio(), asyncio.create_connection(), and asyncio.loop.start_tls() where SSLContext.check_hostname is enabled. Code is affected when server_hostname is omitted, None, or an empty string; code passing a valid non-empty hostname is not affected.
What changes after upgrading or applying the patch?
The corrected behavior raises ValueError for the invalid configuration instead of silently skipping hostname verification. The behavior becomes similar to SSLContext.wrap_socket().