BIT-libpython-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.
- Compensating control
Pass a valid, non-None, non-empty server_hostname value to SSLContext.wrap_bio(), asyncio.create_connection(), or asyncio.loop.start_tls() when SSLContext.check_hostname is True.
Event History
Frequently Asked Questions
Which applications are affected by this issue?
Applications are affected when they use SSLContext.wrap_bio(), asyncio.create_connection(), or asyncio.loop.start_tls() with SSLContext.check_hostname enabled but omit server_hostname or pass it as None or an empty string. Applications that pass a non-empty, non-None server_hostname value to these APIs perform hostname verification as expected.
What must an attacker be able to do to exploit this?
A user must initiate or approve the relevant network connection. Exploitation relies on the application reaching a TLS connection path where hostname verification is silently skipped because server_hostname was not validly supplied.
Is updating Python required to mitigate the problem?
No. Pass a valid, non-None, non-empty server_hostname to SSLContext.wrap_bio(), asyncio.create_connection(), or asyncio.loop.start_tls() to ensure certificate hostname verification proceeds.
What changes after upgrading or applying the patch?
The patched behavior raises ValueError for the invalid configuration instead of silently skipping hostname verification. This is similar to the behavior of SSLContext.wrap_socket().