Issue1174

Title https in hg less secure than expected
Priority bug Status chatting
Superseder Nosy List HenrykGerlach, ThomasAH, ThurnerRupert, alexis, brendan, djc, gamehack, hlavki, jglick, jorendorff, mnordhoff, mpm, pmezard, unlink
Assigned To Topics http_proto, patch, security, ui

Created on 2008-06-11.11:24:15 by HenrykGerlach, last changed 2008-10-06.11:45:13 by djc.

Files
File name Uploaded Type Edit Remove
https-warning2.patch HenrykGerlach, 2008-06-12.14:06:31 text/x-diff
https_warning.patch HenrykGerlach, 2008-06-11.18:23:14 text/x-patch
Messages
msg7319 (view) Author: djc Date: 2008-10-06.11:45:13
Copying nosy from issue643.
msg6259 (view) Author: HenrykGerlach Date: 2008-06-12.14:06:31
@mpm: It took me a second to follow your reasoning: Since all available clients
implement https weakly, it's the server's responsibility whether it offers https
access. I can live with that line.

I still believe we should issue a warning in the client to make the users aware
of the problem. https_warning2.patch does this and adds some documentation to
the pull command to point out the issue.

@mnordhoff: Sounds promising.
msg6256 (view) Author: djc Date: 2008-06-12.10:54:12
Add nosy from issue630, which is about the same thing.
msg6253 (view) Author: mnordhoff Date: 2008-06-11.23:38:22
Python's stdlib doesn't have any way to verify SSL certs. However, Python 2.6
will gain the 'ssl' module, which does support it, and it's been backported all
the way back to Python 2.3.5. Maybe hg could start to use it.

http://pypi.python.org/pypi/ssl/
http://docs.python.org/dev/library/ssl.html
msg6251 (view) Author: mpm Date: 2008-06-11.19:35:59
I don't think this is the right approach, sorry.

The risk and responsibility is almost entirely on the server side. So any config
burden should be there as well.
msg6249 (view) Author: HenrykGerlach Date: 2008-06-11.18:23:14
Attached is a patch how I would issue such a warning.

It asks users of the https scheme if they want to proceed.
In non-interactive mode hg aborts.
Additionally the config option "use_insecure_https" can be set to always proceed.

Note that the patch breaks existing scripts using https (which you may want to
avoid). On the other hand I think people should be aware of the issue.

The patch still misses the docs and we have to decide which section the
use_insecure_https-option belongs to (XXX=ui?).

I don't expect much from the httplib in the near future, since the issue is know
for a longtime (at least they have a warning in their docs):
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6b71417b251ce68d/3366c0161cf72598?lnk=gst&q=https#3366c0161cf72598

As for using "openssl s_client", the openssl man-page states:
"It’s [s_client] intended for testing purposes only."
So I'm not sure if we want to rely on that.
msg6247 (view) Author: mpm Date: 2008-06-11.15:34:03
Correct on all counts. If you have suggestions on where to best document the
problem, I'd like to hear them.

It may be possible to make a quick hack around the problem by opening a pipe to
'openssl s_client -connect server:port' and using that for communications. This
is pretty analogous to what we do for ssh, actually.
msg6246 (view) Author: HenrykGerlach Date: 2008-06-11.11:24:14
As far as I understand:
Using the https protocol in hg is less secure than users are used to (from
browsers), since it does not rule out a man in the middle attack.

Usually the client can check, that he really talks to the server by making sure,
that his certificate is signed by a trusted CA. Hg does not make these checks.

Https in hg is still "more secure", than plain http since a man in the middle
attack requires more effort (though it's usually feasable).

A short solution would be to save the fingerprint of the certificate in the
.hgrc the first time the server is contacted and check against it in future
tries (similar to what ssh does). Unfortunally the python httplib does not seem
to be able to produce these fingerprints (which is IMHO a serious shortcomming
that should be fixed upstream).

So for now, I personally would like to have a warning displayed when the user
uses https, along the lines:
 "the https implementation in hg is less secure than you might expect, please
consider using ssh".

I didn't try to do a proof of concept man in the middle attack, so I might be
missing something.
History
Date User Action Args
2008-10-15 07:27:35hlavkiunlinkissue643 superseder
2008-10-06 11:45:13djcsetnosy: + hlavki, ThurnerRupert, jglick
messages: + msg7319
2008-10-06 11:44:38djclinkissue643 superseder
2008-09-03 00:49:09tonfasettopic: + patch
nosy: mpm, ThomasAH, brendan, alexis, pmezard, gamehack, jorendorff, HenrykGerlach, djc, mnordhoff, unlink
2008-09-03 00:49:01tonfasettopic: + ui
nosy: mpm, ThomasAH, brendan, alexis, pmezard, gamehack, jorendorff, HenrykGerlach, djc, mnordhoff, unlink
2008-07-09 21:45:58unlinksetnosy: + unlink
2008-06-12 14:06:35HenrykGerlachsetfiles: + https-warning2.patch
nosy: mpm, ThomasAH, brendan, alexis, pmezard, gamehack, jorendorff, HenrykGerlach, djc, mnordhoff
messages: + msg6259
2008-06-12 10:54:13djcsetnosy: + jorendorff, djc, brendan, alexis, ThomasAH, pmezard, gamehack
messages: + msg6256
2008-06-12 10:53:28djclinkissue630 superseder
2008-06-11 23:38:23mnordhoffsetnosy: + mnordhoff
messages: + msg6253
2008-06-11 19:36:00mpmsetmessages: + msg6251
2008-06-11 18:23:15HenrykGerlachsetfiles: + https_warning.patch
messages: + msg6249
2008-06-11 15:34:09mpmsetstatus: unread -> chatting
nosy: + mpm
messages: + msg6247
2008-06-11 11:24:15HenrykGerlachcreate