Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upfails to verify ssl cert hostname for cached certs #1783
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ecdsa
Jun 3, 2016
Member
I fail to understand how this differs from #1782.
if a server uses self-signed certificate, then there's no point verifying the hostname.
you seem to expect Electrum to use only CA signed certificates, which is not the case.
|
I fail to understand how this differs from #1782. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
joeyh
Jun 3, 2016
I think I was wrong about this one.
cert_path = os.path.join(self.config_path, 'certs', self.host)
s = ssl.wrap_socket(s,
ssl_version=ssl.PROTOCOL_SSLv23,
cert_reqs=ssl.CERT_REQUIRED,
ca_certs= (temporary_path if is_new else cert_path),
do_handshake_on_connect=True)
So, cert_path points at the single cached cert for the host,
and only that one pinned cert will be accepted, not any others in
~/.electrum/certs/
see shy jo
joeyh
commented
Jun 3, 2016
|
I think I was wrong about this one.
So, cert_path points at the single cached cert for the host, see shy jo |
joeyh commentedMay 3, 2016
For some reason, rather than using the hostname validation built into ssl, (eg, SSLContext.check_hostname), electrum contains its own implementation of hostname validation, in check_host_name. I don't know if that implementation is secure, but I noticed that it's not always called when connecting to a server.
Specifically, check_host_name is only called when there's no cached cert file for a server.
If there's a cached cert file for a server, electrum sets ca_certs to point to cert_path, which contains all the cached certs. And it neglects to verify that the hostname of the server it connected to matches the cert used by that server.
So, this attack seems to be possible:
You need to toss all this manual and insecure ssl code and use ssl.create_default_context() which handles all these details securely.