
Proof-of-concept and remediation lab for CVE-2026-19553, demonstrating TLS hostname verification bypass in Python's SSLContext.wrap_bio() with local CA, server, and patched-version comparison.
This project demonstrates CVE-2026-19553, a TLS hostname verification vulnerability affecting Python's SSLContext.wrap_bio() method.
The objective is to investigate how a TLS handshake can succeed without verifying the server's hostname, even when hostname checking is enabled.
The project includes a locally hosted TLS server, a test certificate authority, an exploitation script, an application-level remediation, and a comparison between vulnerable and patched Python versions.
All exploitation testing is performed locally using 127.0.0.1. No external servers or production systems are targeted.
CVE-2026-19553 concerns improper hostname verification when using Python's SSLContext.wrap_bio() method.
In vulnerable Python versions, supplying server_hostname=None can allow a TLS handshake to succeed without checking the server's certificate against an expected hostname, despite check_hostname=True.
This occurs because the TLS connection is created without an expected hostname for certificate matching.
Although certificate-chain verification may still be performed, the absence of hostname verification means that a certificate issued by a trusted certificate authority could be accepted without confirming that it belongs to the intended server.
This could potentially allow server impersonation or man-in-the-middle attacks, depending on the application's trust configuration and network environment.
CVE details:
SSLContext.wrap_bio()The experiment was conducted using the following environment:
A local certificate authority (CA) was generated to sign the test server certificate.
The TLS client was configured to trust this CA so that the experiment could focus specifically on hostname verification rather than certificate-chain trust failures.
| File | Description |
|---|---|
generate_certs.py | Generates the local certificate authority and TLS server certificate |
tls_server.py | Starts the locally hosted TLS server |
exploit.py | Tests TLS connections using SSLContext.wrap_bio() |
patched_test.py | Tests actual CPython behavior on vulnerable and patched Python versions |
remediation.py | Implements application-level hostname validation and performs full TLS handshake verification |
requirements.txt | Lists the required Python dependency |
certs/ | Stores locally generated certificates and private keys |
screenshots/ | Stores evidence of the exploitation and remediation results |
.gitignore | Excludes generated certificates, private keys and temporary files from Git tracking |
The client was configured with:
context.check_hostname = True
server_hostname = None
The TLS server presented a certificate issued for attacker.test.
Observed output:
Python: 3.14.7
OpenSSL: OpenSSL 3.5.7 9 Jun 2026
server_hostname: None
check_hostname: True
verify_mode: 2
RESULT: TLS handshake successful
WARNING: Missing hostname was accepted
Result: Successful exploitation of the missing-hostname verification issue.
Although hostname verification was enabled, the TLS handshake completed without checking the server certificate against an expected hostname.
The server certificate was signed by the locally trusted CA, so certificate-chain verification could succeed even though hostname matching was not performed.
The client was configured with:
server_hostname = "localhost"
However, the TLS server certificate was issued for attacker.test.
Observed output:
RESULT: TLS connection rejected
Error: SSLCertVerificationError
certificate verify failed: Hostname mismatch,
certificate is not valid for 'localhost'.
Result: TLS connection rejected due to a hostname mismatch.
This demonstrates that hostname verification is enforced when an expected hostname is explicitly provided.
The same SSLContext.wrap_bio() configuration was tested on two Python versions using:
context.check_hostname = True
server_hostname = None
Python 3.14.7 — Vulnerable runtime
Python version: 3.14.7
RESULT: Actual runtime accepted missing hostname
WARNING: No built-in rejection observed
Python 3.14.10 — Patched runtime
Python version: 3.14.10
RESULT: Actual runtime rejected missing hostname
Error: check_hostname requires server_hostname
Result: The vulnerable runtime accepted the missing hostname, while the patched runtime rejected it.
This comparison tests TLS object creation rather than performing a complete network handshake.
An additional safeguard was implemented in remediation.py.
The secure_wrap_bio() function checks that a non-empty hostname is supplied and that hostname verification is enabled before calling SSLContext.wrap_bio().
The updated remediation test also performs a full TLS handshake to determine whether the supplied hostname matches the server certificate.
Four hostname inputs were tested:
None — Missing hostname"" — Empty hostname"localhost" — Incorrect hostname"attacker.test" — Correct hostnameObserved output:
CVE-2026-19553 - Full Remediation Test
Testing hostname: None
Application validation: REJECTED
Reason: A non-empty server_hostname is required
--------------------------------------------------
Testing hostname: ''
Application validation: REJECTED
Reason: A non-empty server_hostname is required
--------------------------------------------------
Testing hostname: 'localhost'
Application validation: PASSED
TLS handshake: REJECTED
Reason: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:
Hostname mismatch, certificate is not valid for 'localhost'.
--------------------------------------------------
Testing hostname: 'attacker.test'
Application validation: PASSED
TLS handshake: SUCCESS
--------------------------------------------------
Result: The remediation successfully demonstrated both application-level hostname validation and TLS certificate hostname verification.
When None or an empty string was supplied, the application rejected the input before creating the TLS object.
When localhost was supplied, application validation passed because a non-empty hostname was provided. However, the TLS handshake was rejected because the server certificate identified attacker.test, not localhost.
When attacker.test was supplied, application validation passed and the TLS handshake completed successfully because the hostname matched the server certificate.
These results demonstrate two separate security checks:
SSLContext.wrap_bio().This application-level mitigation is separate from the official CPython patch.
TLS hostname verification is an important security mechanism that ensures a client is communicating with its intended server.