News for hackers. Stuff that matters.
Re:Emacs and TLS by wyuenho on Thursday July 19, 2018 @11:56PM (#17572329)
I'm the new guy mentioned in the article. This article is a bit late to the party and misses a lot of details that I've discovered since June.

One of the reasons prompted this giant thread on the emacs-devel mailing list is when I was updating my Emacs config to try out Gnus for email and newsgroup, I discovered that no one seems to know exactly what a good TLS Emacs config should look like and that Emacs comes with horrible defaults. In addition, I was shocked that I've been exposed to a dozen TLS vulns that might cause arbitrary code execution the whole time since package.el became a part of Emacs back in circa-2013. After stuffing myself with about a dozen RFCs and many dozen more papers and Chrome and Firefox blog posts, here's what I found very concerning:

1. The initial "a bit concerning" and "very concerning" qualifiers I originally posted aren't as clear cut anymore, most of the 2 dozen failing badssl tests are actually quite bad.

2. NSM has got half a foot in the 2010s and half a foot in the 2000s. The latest stable version of Emacs (26.1) only checks for SHA1 end-certificate, usage of SSL, DH < 1024 bits and a noop RC4 cipher check (GnuTLS actually calls it ARCFOUR).

3. The half-done pinning mechanism does Trust on First Use while the user can't even see the entire cert chain or the end cert.

4. Only one fingerprint per host for TOFU, where Google low balances at least between 2 end-certs AFAIK.

5. Excessive and theatrical prompts for any URL that has not been visited on a security level called 'paranoid.

6. Multiple prompts for different problems found for the same TLS handshake.

7. Setting one option in a configuration group called GnuTLS to true bypasses NSM entirely. i.e. no cipher suite checks and happily accepts any 256-bit DH key exchange attempts.

8. No attempt to do any OCSP or Certificate Transparency revocation checking.

9. 4 packages intermingled with each other all securing some network connections badly with no documented relationships between them.

10. Virtually no one who has commit access to the Emacs repo understands TLS.

11. RMS prefixes every one of his email with:

  [[[ To any NSA and FBI agents reading my email: please consider    ]]]
  [[[ whether defending the US Constitution against all enemies,     ]]]
  [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
while Emacs's network security settings is basically saying please come fuck me.

The good news is, a few of these problems are already fixed on master and I've pushed a branch called "netsec" to the Emacs repo last week that fixes most of the rest. OCSP is coming this weekend. CT is going to wait quite a bit longer as GnuTLS has no plan to support it anytime soon. I have hope to make at least some of these security fixes to Emacs 26.2 or 26.3 in the short term. Medium term plan is to lobby for requiring TLS for all email protocols because RFC 8314. The long plan is obviously support TLS 1.3 for Emacs 27, and possibly HTTP2.

Re:Emacs and TLS by cjohansson on Friday July 20, 2018 @01:54AM (#17572806)
Thanks for your efforts, really appreciate it. I use Emacs daily so it's critical for me that it's secure
Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @07:13AM (#17574017)
Don't thank me yet, a lot of these haven't made into master, thank me later if my lobbying effort is successful. :)
Re:Emacs and TLS by etu on Friday July 20, 2018 @02:03AM (#17572839)
Question: Wouldn't it just be easier for Emacs to link to libcurl which has pretty much reasonable defaults (afaik, correct me if I'm wrong). The result would be that Emacs wouldn't need to link to a specific TLS library or have to maintain this. libcurl's API has a good reputation for not breaking :-)

Also big thanks for putting this work into Emacs. I use Emacs for hours at least every work day and many non-workdays as well.

Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @03:17AM (#17573079)
I thought about linking in curl, but curl doesn't seem to offer any help in making OCSP requests separately, it only has support for OCSP stapling. Not that not having OCSP by itself is a major issue, but not having OCSP, CT and a reliable and complete CRL set to check for certificate revocations is. Since GnuTLS is a readily available, and has APIs that make OCSP requests and verify OCSP responses, and Emacs itself can already open network sockets, in the end I've decided to stick to a bunch of Lisp and a couple of simple C functions for GnuTLS.
Re:Emacs and TLS by __david__ on Friday July 20, 2018 @03:20AM (#17573091)
Emacs uses TLS for more than just HTTP. SMTP+STARTLS for instance…
Re:Emacs and TLS by oblio on Friday July 20, 2018 @06:29AM (#17573826)
Re:Emacs and TLS by __david__ on Friday July 20, 2018 @01:11PM (#17576875)
Fair enough, but does it do nntp, irc, pop, imap, jabber, etc? Emacs (for better or worse) has a complete network API so people can implement all of these things, and it doesn't want to be limited by a high-level library that only supports some small subset (however large that subset is).
Re:Emacs and TLS by oblio on Friday July 20, 2018 @02:31PM (#17577569)
Re:Emacs and TLS by simcop2387 on Friday July 20, 2018 @03:23AM (#17573100)
As far as I know you can't use libcurl to talk to smtp, or other protocols like that. They need generic socket support.
Re:Emacs and TLS by oblio on Friday July 20, 2018 @06:30AM (#17573832)
I see SMTP here: https://curl.haxx.se/libcurl/c/smtp-mail.html

And on their page they have a zillion protocols: https://curl.haxx.se/

Maybe it would be worth trying out.

Re:Emacs and TLS by tialaramex on Friday July 20, 2018 @03:11AM (#17573058)
Briefly (?):

As the Fedora bug notes, Default TLS security policies for the Web PKI belong at the OS level, where they can be set by a small number of people who are really thinking about these problems, once. Microsoft has done this (not very well, but they've done it) in modern SChannel .NET support, it is finally relatively easy to write code which says "I don't know, please have the usual amount of security" rather than "I'm an expert, enable this protocol version, these exact ciphersuites, and use this key" or as it more commonly the case "Here's something I pasted from a 2010 Stack Overflow post". As much as possible, and despite all insistence to the contrary by individual developers, these preferences shouldn't live in some effectively unmaintained code in each individual component.

1. In particular if you don't actually care about the identity claimed in the certificate, you shouldn't bother verifying anything at all since obviously bad guys can trivially obtain a cert for some identity.

This was once a VERY common problem, and it's still seen in plenty of places (e.g. one of the toy operating systems doesn't check at all, so the whole OS is wide open, package updates, web browser, the whole thing - another has told users any time there's a problem to switch verification off manually, so I would expect few have it left switched on by now)

2a. Although it feels as though turning min-prime bits up to 2048 would fix things, in practice interoperability is very poor. You might get away with this, in some cases, for say IMAP and SMTP submission with TLS, but it's unlikely to be satisfactory on the general web. Try asking for Elliptic Curves instead.

2b. Everybody called it ARCFOUR (Alleged RC4) for legal reasons, it's fine, don't worry about _that_.

3. I sympathise here, in principle the user ought to have examined the cert, or at least key, they're trusting. But realistically users don't do this, so the security penalty is very small indeed. Examining the entire chain is largely futile, a lot more work and an even smaller number of users would gain anything from it.

8. There isn't really such a thing as "Certificate Transparency revocation checking" and revocation is largely a dead letter for big public CAs in the Web PKI. Almost certainly a bad guy able to attack you using a real cert isn't going to be prevented in their attack by revocation, they will block the signal and you'll fail open, because as we saw in every other item, users switch off any annoying fail-closed machinery.

10. This isn't great, but the idea behind SSL/TLS is that this ends up just being a drop-in replacement for the socket layer. With the exception of some scary features like TLS 1.3's Zero RTT no TLS expertise is needed, and the correct approach if you have no TLS expertise in the Emacs developer team is to just never use those scary features, they're supposed to be gated so that you can't use them by accident.

Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @03:41AM (#17573170)
What I'm working on is only tangentially related to that Fedora bug. Essentially, what the user is seeing in the GnuTLS debug log will supposedly be checked by NSM. I wasn't even aware of that bug report before I emailed emacs-devel. I'm glad I didn't tho, as that'll only add to the confusion.

Emacs's use of GnuTLS already delegates something to the OS, namely getting the system's root CA certs. As for the rest, I lobbied leaving GnuTLS defaults alone instead of intentionally lowering it to accept 256 bit DHE primes only to be warned by NSM later. Also, the default cipher suite other than DHE prime bits is already left alone OTTB.

But.... Emacs being all about freedom and infinitely hackable, the philosophy (philosophers?) demand that we let users to be able to configure the lower bound of acceptable TLS security in 2 different places, because someone somewhere requested it at one time, therefore his or her need trumps everyone else's default security or requests to have a consistent UI for TLS configuration. This is the context behind that fixation quote Lars wrote. Of course, I disagree strongly. The good news is, I've already returned all GnuTLS knobs to their defaults in my branch, and Lars has fixed the docs so people know they probably shouldn't touch those GnuTLS settings unless they want to bypass NSM completely, say running a elisp script for example.

I'm not going to respond to the rest of your points, they require a fair bit of context to understand why I think they are problems. I'll probably explain it in a blog some time this weekend.

Re:Emacs and TLS by oblio on Friday July 20, 2018 @06:34AM (#17573852)
> One of the toy operating systems doesn't check at all, so the whole OS is wide open, package updates, web browser, the whole thing - another has told users any time there's a problem to switch verification off manually, so I would expect few have it left switched on by now

Could you say which OSes?

Re:Emacs and TLS by tialaramex on Saturday July 21, 2018 @03:58PM (#17583567)
Sure, Haiku doesn't check, the Amiga systems advise people to switch off verification.
Re:Emacs and TLS by waddlesplash on Sunday July 22, 2018 @03:42PM (#17588510)
Huh? Haiku has had certificate verification for a long time, and the issues related to false-negative verifications got straightened out in 2012 or so; the web browser has always checked even before that, and for the package manager all builds past last December have had HTTPS downloads by default.
Re:Emacs and TLS by sillysaurus3 on Friday July 20, 2018 @12:43AM (#17572532)
Your point #11 is a bit distasteful.

Beyond that, npm is far more vulnerable. But it rarely matters. The reason is culture and community.

Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @12:57AM (#17572590)
I appreciate you announcing your preference of taste, but honestly, if you don't have anything of substance to add to the conversation, please don't pollute the thread.
Re:Emacs and TLS by sillysaurus3 on Friday July 20, 2018 @01:16AM (#17572667)
I'm a former pentester. I used to do this kind of work for a living. Secondly, the Snowden leaks were one of the most important events in modern history, and you're on here using them as a cheap way to push your own agenda. Thirdly, RMS hasn't been an active emacs developer for quite awhile, but you're still trying to criticize him.

To bring this back to the topic at hand: npm as an ecosystem is far more vulnerable than the points you mention. It's worth considering why people do not routinely pwn those who use npm. The fact that you are vulnerable does not mean it's a good idea to try to throw an entire ecosystem under the bus.

Re:Emacs and TLS by 0xcde4c3db on Friday July 20, 2018 @09:46AM (#17574924)
> Secondly, the Snowden leaks were one of the most important events in modern history, and you're on here using them as a cheap way to push your own agenda. Thirdly, RMS hasn't been an active emacs developer for quite awhile, but you're still trying to criticize him.

I don't see where you got any of that. I read point #11 as citing RMS in his capacity as an authority on GNU goals and principles, a capacity in which he still contributes guidance to Emacs and other GNU projects.

Maybe there's some context missing. GNU is an unapologetically political project; decisions are meant to be made not solely in pursuit of some narrow definition of technical superiority or correctness, but being mindful of their effects on the free software movement and human societies in general. From that perspective, it's completely reasonable to be surprised if a GNU project appears to be out of alignment with a major sociopolitical concern of RMS. For example, if GCC 9.0 were released under the original BSD license, people would be surprised and concerned for fundamentally similar reasons.

Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @01:20AM (#17572680)
What's my agenda exactly and why do you think I'm criticizing RMS? Is that quote my words? And what does being a former pentester have to do with anything you said? Which ecosystem am I throwing under the bus?
Re:Emacs and TLS by sillysaurus3 on Friday July 20, 2018 @02:00AM (#17572831)
The quality of HN is more important than winning. Let's have a conversation worth reading.

The reason I laid out some creds is because you seemed to ignore the substantive part of my comment, twice now.

It is tradition in the security field to make every security incident seem like a very big deal. (See tptacek's comment on cloudflare's memory leak, for example.) But just because there exist vulnerabilities, it does not mean that (a) anyone has exploited them or (b) that you are in any kind of danger.

I was shocked that I've been exposed to a dozen TLS vulns that might cause arbitrary code execution the whole time since package.el became a part of Emacs back in circa-2013.

This sentence makes it sound like anyone who has used emacs in any way since 2013 has been in immediate risk of having their computer taken over. Maybe that's true. But even if it were true, what precisely would the steps be to make this attack happen? Have you proved that it can be done?

EDIT: The main point I'd like to get across is that it's worth fixing security problems, but it's important to maintain a spirit of cooperation rather than accusation. Everyone has security issues. Even (perhaps especially) the big names that you wouldn't expect to. That's why people pay pentesters a lot of money -- we're effective at making sure no one else finds them before we do. But emacs doesn't have the resources to get a pentest, and out of all the security vulnerabilities they could possibly have, a few TLS flaws wouldn't even be marked as medium severity unless there were a direct way to take over a user's computer via the flaw.

Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @02:39AM (#17572966)
I'm not trying to win anything, I'm trying to find out where that dismissive tone came from, and see if there's any merit.

Back to topic:

While I agree that being vulnerable is not the same as being attacked, I still have a hard time understanding why you seem to be downplaying the significance.

First of all, I don't have to prove anything, all the papers that describe actual explotable TLS vulns over HTTP and SMTP/IMAP equally applies to Emacs if you've ever downloaded something over HTTPS or login to a server say Github via an API package like ghub.el. Email is worse with STARTTLS, although the attributes are different. SMTP/IMAP connections tend to be much shorter and less frequent, so your area of exposure may be smaller> But since emails tend to contain a lot of vital PII, the actual harm is probably greater than knowing your session cookie for a blog. Losing email credentials is also quite devastating.

Second of all, TLS is mostly used to guard against all kinds of MITM attacks. There are some kinds of MITM attacks easier to carry out than others, and they don't have to be targeted. Logging into your email account using a coffee shop's wifi without checking for known vulns before tranmission of TLS records doesn't sound very comforting to me.

Security, most of the time is about prevention rather than mitigation after the fact, just like you would wear a seat belt even though your likelihood of dying in a car crash isn't very high. Am I supposed to be not shocked to discover my car comes with a seat belt made out of a thin piece of printer paper?

P.S Since we are putting out credentials, I used to work at Cloudflare, not that I was in any security or systems engineering capacity, but I have also been quite interested in security issues. I guess that makes me a "security-hobbyist".

//edit after your edit

You probably should stop accusing me of accusing anybody, that's the exact opposite of what I have done. Please read the last link in the article (https://lwn.net/Articles/759460/).

Re:Emacs and TLS by sillysaurus3 on Friday July 20, 2018 @10:48AM (#17575423)
First of all, I don't have to prove anything

Yes, you do. That's pentesting 101.

Think of it this way. Would it be reasonable for pentesters to say "You're critically vulnerable. But I haven't verified this"?

More times than I can count, when I went back to verify whether I was correct, I wasn't. For subtle reasons. If you haven't put in the work, you don't know whether you are right.

Security, most of the time is about prevention rather than mitigation after the fact, just like you would wear a seat belt even though your likelihood of dying in a car crash isn't very high. Am I supposed to be not shocked to discover my car comes with a seat belt made out of a thin piece of printer paper?

You have never worked in security. The fact that you're shocked at this shows how green you are. I don't mean that in a dismissive or insulting way, but if you'd just go do a stint as a pentester for a year, or talk to some pentesters in the field, you'll quickly stop being shocked at this.

You have a responsibility as someone who is presenting security issues to know what you're talking about. Most people listen to whoever talks the most confidently. And the bare minimum work is proving that the exploits you're presenting are actually applicable to the situation at hand.

Most people don't know security, and very few people will check your work to ensure it's correct. That means when some hobbyist steps up and starts yelling about theoretical issues, it's important to step in and say "Actually, these issues haven't been demonstrated."

What if it takes $100M to MITM someone? Would you say it's still worth being shocked that you're theoretically vulnerable to this? What is the precise cost of someone who actually wanted to MITM someone else using emacs? Have you done the math?

This isn't me downplaying the significance. This is me saying "Do the work." And if you haven't, then you should classify the vulns as low severity. That's what we did whenever we didn't know for a fact that you could own someone's app/box.

Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @03:14PM (#17577991)
You seem to be singularly focused on pentesting, whatever that means to you, and I'm mostly concerned with leakage of information. Being able to prove whether I can pwn Emacs or not is irrelevent. For my purpose, all I have to establish is if Emacs is treated as a TLS client on internet. This is trivial.

> You have never worked in security. The fact that you're shocked at this shows how green you are. I don't mean that in a dismissive or insulting way, but if you'd just go do a stint as a pentester for a year, or talk to some pentesters in the field, you'll quickly stop being shocked at this.

Does the fact that you are numbed to snafus like this justify the terrible state of network security of a continuously maintained 30+ year old editor? I expected more from the countless number of Emacs hackers came before me.

I urge to you go thru the mailing list thread, but if you don't want to, I understand as it's rather long, but please don't assume you know what I've done or haven't done or how much I understand these issues, or my intentions. We've never met, never conversed before, you don't know anything about me.

Re:Emacs and TLS by belorn on Friday July 20, 2018 @07:07AM (#17573992)
The RMS quote should be seen in the light of the usual message when security researcher talk about the NSA. That is to say if you need protection against state level attackers, relying on a single layer of security technology is insufficient and should always be considered as an exploitable vulnerability that will be broken at some time in the future. Imploring the state actors to act in the same moral way as Snowden is here a last line of defense.

In the context of TLS in Emacs, I don't see how it is a very concerning point in similar style as failing badssl tests. The implied claim that RMS is writing his footer because he thinks the emacs security is faulty is not supported. As such the RMS part of #11 is not supported and do not contribute to the TLS implementation and configuration discussion in regards to Emacs.

Re:Emacs and TLS by wyuenho on Friday July 20, 2018 @07:22AM (#17574062)
I agree with your first paragraph, but I didn't claim RMS thinks Emacs security is faulty. In fact, RMS doesn't seem to be aware of the problems of Emacs' network security. That RMS quote is there to point out the irony that RMS cares enough about security and privacy to prefix all of his emails with that preamble, but not enough to alarm emacs-devs about it. It's well-known that RMS has not been active in Emacs' development for many years now, the responsibility is not on him anymore.