Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efail.de: are astroid users affected? #499

Closed
hugoroy opened this issue May 14, 2018 · 22 comments
Closed

Efail.de: are astroid users affected? #499

hugoroy opened this issue May 14, 2018 · 22 comments
Labels

Comments

@hugoroy
Copy link
Contributor

hugoroy commented May 14, 2018

https://efail.de/

Maybe, if the users chooses to show HTML emails by default?

@mxmehl
Copy link
Contributor

mxmehl commented May 14, 2018

Probably one also has to enable loading external images by default to be vulnerable. But I'm not sure about this as Thunderbird doesn't display external images by default either but seems to be affected.

@gauteh
Copy link
Member

gauteh commented May 14, 2018

As far as I can understand at this point you should not be vulnerable as long as you don't activate the HTML part (with the "potentially sketchy" warning there) and don't allow remote images to be displayed.

The attack requires that the attacker can access the original e-mail, so it is obviously doesn't matter for unencrypted emails since they would be directly available anyway.

Further, it is not clear yet whether you are vulnerable or not: each HTML part is not just appended sequentially, but inside other HTML tags. We need to look into whether this might be exploited somehow through the example <img src=" procedure. The HTML is not validated before rendered (hence the "potentially sketchy" warning).

Showing HTML emails by default will make this worse. If remote content (like images) can be loaded.

@hugoroy
Copy link
Contributor Author

hugoroy commented May 14, 2018 via email

@gauteh
Copy link
Member

gauteh commented May 14, 2018

I'm looking at mailpile.is analysis, if we look at the five points:

  1. Mailpile does not display HTML content by default
  2. Before displaying HTML, Mailpile cleans up malformed and incomplete tags.
  3. When displaying HTML, Mailpile does not load remote content by default.
  4. Mailpile respects the GnuPG error messages which warn of invalid data.
  5. Mailpile never sends auto-replies to incoming mail.

Astroid adheres to points 1, 3, 5, and should show a warning on 4 (though I haven't tested this). Fixing 2 is tricky and hard to know if is completely safe, and is one reason for 1 and 3.

@gauteh
Copy link
Member

gauteh commented May 14, 2018

A couple of things we can do:

  • Use https://github.com/htacg/tidy-html5 to sanitize HTML (aka 2).
  • Use html-tidy to remove any remote assets except images (won't really fix this issue, but will make things safer in other respects). Note that these are not loaded unless remote image loading is allowed, and still the page would have to be reloaded.
  • Not display GPG HTML parts if decryption results in integrity error (aka 4).
  • Allow to turn off GPG

@c-alpha
Copy link
Member

c-alpha commented May 18, 2018

<opinion>Kind of sad how people, who dub themselves as researchers/scientists, apparently couldn't resist the temptation of encouraging "generous interpretations" of their results for the sake of seeing their names in the news.</opinion>

But back to business...

Independent of any fixes, I think it would be useful to add astroid to the list of mail clients for VU#122919, which is the report underlying (and referenced by) both "scoop CVEs".

Actually, two vulnerabilities are described:

  1. The "CBC/CFB Gadget Attack" is an attempt to circumvent the encryption and packaging itself. It is not new, and has never been considered a severe risk. In order to work, it requires access to either the victim's secret key, or sufficient quantities of plaintext (which in practice amounts to the same). IMO, we can ignore this, since neither can we solve it, nor is it a promising scenario for an attacker.

  2. The "Direct Exfiltration" attack needs three convenience features in mail clients to be successful: hiding of the multipart structure, caching of the passphrase, and proactive fetching of remote content, including JS execution. Only if both convenience features are in place, an attack can be successful. If there is no passphrase caching, the user could become skeptical if he had to enter his passphrase several times to decrypt a "can we meet at 9pm" three-liner. If the multipart structure were shown, the user could become skeptical if there are more message parts than expected. Finally, if there's no JS execution and no retrieval of remote content, the attack fails.

What could also help to make users skeptical, would be to display all recipients and key ids of an encrypted block when prompting for the passphrase. Since the "direct exfiltration" attack uses an encrypted email sent by the victim in the past as a hidden message part, the list of recipients for that may not match the recipients list of the forged email.

So what could we do for astroid?

  • I personally don't see HMTL sanitization as a promising option. It could keep us in a false sense of safety. IMO it will not be possible for a software to distinguish between "good" and "bad" HTML. Since the HTML sanitization takes HTML as input, and produces HTML as output, which is then considered "safe", this could invite further attacks which exploit bugs in the sanitization code.
  • Not loading remote assets, and not executing any scripts (JS or other) would seem a very good option to me. It is a straightforward feature, and implementations are hence very unlikely to have sufficient bugs to make an attack look promising. The "don't load remote content" switch is off by default (afair), so to that end, we should be fine. How easy it would be to add a 'never execute any scripts in HTML" switch, I wouldn't dare to predict.
  • Listing any and all recipients when prompting for the decryption passphrase would allow for easy common sense sanity checks by users. Of course an attacker can put the same recipients in the message header as were used by the victim when encrypting his original message, but that would require the attacker to do two things: (a) to use a modified SMTP server which only sends to the victim, but not to other recipients, and (b) to employ more social engineering since the contents of the forged message will need to make sense to the victim in the light of the recipients list. Not that this would be impossible, but I think it raises the bar quite a bit for the attacker.
  • displaying the entire message structure before any non-plaintext parts are rendered would also seem useful to enable users' common sense sanity checks. I know that astroid already does that for multipart/alternative, but I haven't tried it with more complex message structures, so can't really gauge how good we are in this respect.
    As a long time Mulberry user, I came to like the way it's done there. The first plaintext part is always displayed. If the message has more parts, a message parts toolbar is shown right above the text area, and its collapsed by default:
    opera snapshot_2018-05-18_181450_www mulberrymail com
    When the user clicks on the disclosure triangle, the toolbar is expanded to show the message's structure:
    opera snapshot_2018-05-18_181519_www mulberrymail com
    Again, an attacker can of course employ further camouflage tactics to make the message appear to have a flat structure, but to cause am HTML rendering engine to misbehave in favour of the attacker, but again this raises the bar for the attacker.

Overall, I very much concur with @gauteh's assessment that HTML sanitization would not seem a promising way forward.

Additionally, I would be of the opinion that some new UI features (see bullets above) could help end-user awareness.

@gauteh
Copy link
Member

gauteh commented May 22, 2018

Good points.

Showing encryption keys would not completely fix the issue anyway since the keys could be set to 0x0 (see #313 and #497). The passphrase is also not astroid, but part of the gnupg / keyring configuration pinetry configuration.

I am leaning towards putting each sub-part in an iframe with very strict restrictions. This was the plan to do for HTML parts anyway, but we could just as well do it for all parts. As you say, sanitizing the HTML is error prone, but could perhaps still be used to aid in viewing poor HTML. Normally this should be shown without any borders so that it would look more or less like it does already.

Remote assets are by default not loaded.

While I think the message structure is nice to have, I don't see that it has a lot of use. I'd not be against adding some kind of alternative view here if someone wants to step up to the challenge. The tree-structure is already readily available in the Astroid code. For me it seems that it would perhaps clutter the reading experience, and have somewhat limited use.

gauteh added a commit to gauteh/astroid that referenced this issue May 23, 2018
@gauteh
Copy link
Member

gauteh commented May 23, 2018

#503 adds a configuration option for optionally disabling GPG (default enabled). It is not yet confirmed that the attack works on Astroid, nor is it I think likely, but if you want to be completely sure disable GPG.

@c-alpha
Copy link
Member

c-alpha commented May 24, 2018

Showing encryption keys would not completely fix the issue anyway since the keys could be set to 0x0 (see #313 and #497).

I think I imagined displaying sth. along the lines of "I'm now going to decrypt a chunk, which is encrypted for email-address (key-id), email-address (key-id), ...". Since the attack uses an old email I have sent in the past, that would give me an opportunity to think, when a seemingly harmless message (e.g. invitation to a meeting) contains stuff addressed to unrelated people. Of course an attacker could craft a message content that could make sense given the recipients, but that would have two preconditions: (a) the attacker would need to get the email addresses from the public key ids in the chunk (not everybody uploads theirs to a keyserver), in order to be able to (b) figure out what my relationships with these recipients are today, and what type of message content could therefore make sense to me.

Doesn't prevent anything technically, but raises the bar quite a bit.

The passphrase is also not astroid, but part of the gnupg / keyring configuration pinetry configuration.

Yes, of course. But if I would get information like the message I outlined above in astroid, immediately before the pinentry dialogue appears, I would get a chance to click "cancel" in the pinentry dialogue if something doesn't look right.

I am leaning towards putting each sub-part in an iframe with very strict restrictions. This was the plan to do for HTML parts anyway, but we could just as well do it for all parts. As you say, sanitizing the HTML is error prone, but could perhaps still be used to aid in viewing poor HTML.

I think sanitizing HTML would even create a new area of potential vulnerabilities. Most of today's code that renders HTML should be assumed to be fairly well tried & tested. Using the WebView provided by the platform should hence be a pretty safe bet, IMO. Well, at least as safe as one can practically get.

The HTML sanitization code on the other hand, would be a new thing that processes the HTLM and reacts to it. It has been (and probably will remain) much less tested and scrutinised than typical WebViews etc. It would hence seem quite probable to me that the HMTL sanitiser will have bugs, and that maliciously crafted (or simply randomly erroneous) HTML could cause it to do unexpected things. yet another source of buffer overflows, causing privilege escalations, etc. In that light, I think that I would even be against having any HTML sanitization. If a mainstream WebView can't make it readable, how much more can any HTML sanitization salvage? Also, sanitizing HTML is DWIM (do what I mean), i.e. can have surprising results.

[...]
While I think the message structure is nice to have, I don't see that it has a lot of use. I'd not be against adding some kind of alternative view here if someone wants to step up to the challenge. The tree-structure is already readily available in the Astroid code. For me it seems that it would perhaps clutter the reading experience, and have somewhat limited use.

I don't think I was asking for an alternative view. maybe everything is already in place; I just hgaven't had the opportunity to test how astroid shows a complex MIME message.

My idea was to show the message's structure, so that the user could apply common sense if he wanted to. Example: I get an email which says "can we meet for coffee at 3?". In the first scenario, the attacker has not invested a lot of effort, and it contains a multipart/alternative part with plaintext and HTML versions of the meeting request, and a third part which is HTML, and 32kB in size. The extra part with unusual size would seem odd, and the user could decide to not open it.

If the attacker chooses to invest more effort, invisible HTML with my old encrypted message, could be embedded in an HTML-only message. In this case, showing the message structure would not help, of course.

Again doesn't prevent anything technically, but raises the bar.

@gauteh
Copy link
Member

gauteh commented May 27, 2018 via email

@gauteh gauteh mentioned this issue May 27, 2018
34 tasks
@c-alpha
Copy link
Member

c-alpha commented Jun 7, 2018 via email

@gauteh
Copy link
Member

gauteh commented Jun 8, 2018 via email

@gauteh gauteh mentioned this issue Jun 8, 2018
@c-alpha
Copy link
Member

c-alpha commented Jun 8, 2018 via email

@gauteh
Copy link
Member

gauteh commented Jun 12, 2018 via email

@c-alpha
Copy link
Member

c-alpha commented Jun 12, 2018

[...]

though I have never received an GPG email with remote-content. And I
do not see how anyone in their right mind would send something like
that.

I had very similar thoughts when writing my comment yesterday. But
then I thought of a calendar invite, which I did receive encrypted
once. It had HTML content with accept/decline buttons for the
appointment. So I think there are a select,few valid use cases
involving accessing remote resources, BUT never without expressed user
intent.

Do you mean that these buttons are images or that some URL is opened
when you click them?

They are not images, but trigger HTTP requests. The actual format of CalDAV transactions can be seen in the examples in RFC 6638, appendix B. Since these cannot directly be generated from an HTML message without JavaScript, the accept/decline buttons trigger GET requests over https to URLs on the calendar server of the meeting organiser, with parameters containing a hash or two of sorts identifying the meeting and attendee, and the attendee's decision.

When I invite myself to an event on my icloud.com - for instance - I get an HTML email like this:
screen shot 2018-06-12 at 14 43 44

You see an ICS attachment (bottom left), and three convenience buttons. The <a> link behind the "accept" button for example is:

https://www.icloud.com/calendar/eventreply/en-gb/?t=2_GI3TIMBYG44DCMJSG42DAOBXHBA7JTCOPYPGOMM4CTDYFNSC2HAZQIR3R6EPLQBSIH66TIQMLBEC6&p=&cc=DE#reply=accept

When I click that, it is opened in the browser, and the response page is this:

Something like this, combined with a corporate email gateway that encrypts outgoing emails for everyone whose public key is available, will lead to an encrypted message where the resulting cleartext is HTML containing links to external stuff.

[...]

How would the UX be "convoluted"? I open the message, I see some
readable parts of the message (which were not encrypted), and a
placeholder block showing a closed padlock and "encrypted part". Then,
the passphrase prompt pops up. Would work for me at least?

That could work, but it would probably be quite annoying since in most
encrypted emails the entire message is encrypted and you would always
just have to do something manually to decrypt the message every time.

Agreed.

I think we should ban inline PGP from astroid altogether, btw (see here and here). Although PGP/MIME is known to be unsupported by some older email clients, I'd value the privacy and security improvements of PGP/MIME and consider them to be more important than compatibility with clients that have limited MIME compatibility.

I am more in favour of trying to secure against this attack using separate
iframes (especially for the encrypted parts, since the efail attack
isn't really relevant for non-encrypted emails).

Fully agree.

@gauteh
Copy link
Member

gauteh commented Jun 12, 2018 via email

@c-alpha
Copy link
Member

c-alpha commented Jun 12, 2018 via email

@gauteh
Copy link
Member

gauteh commented Jun 12, 2018 via email

@c-alpha
Copy link
Member

c-alpha commented Jun 12, 2018 via email

@gauteh
Copy link
Member

gauteh commented Jun 12, 2018 via email

gauteh added a commit to gauteh/astroid that referenced this issue Jun 21, 2018
gauteh added a commit to gauteh/astroid that referenced this issue Jun 21, 2018
@gauteh
Copy link
Member

gauteh commented Jun 24, 2018

#455 now uses IFRAMEs for showing all parts. Both HTML and TEXT. It is now also possible to toggle between the parts without re-opening the message, configuration options allow you to configure default part other than plain and also to show html part if that is the only part.

gauteh added a commit to gauteh/astroid that referenced this issue Jun 24, 2018
@c-alpha
Copy link
Member

c-alpha commented Jul 23, 2018

Apologies for the aftermath, but this just in. Apple have declared victory on efail by "improving isolation of MIME" in their mail apps in macOS High Sierra 10.13.5, Security Update 2018-003.

Mail
Available for: macOS High Sierra 10.13.4
Impact: An attacker may be able to exfiltrate the contents of
S/MIME-encrypted e-mail
Description: An issue existed in the handling of encrypted Mail. This
issue was addressed with improved isolation of MIME in Mail.
CVE-2018-4227: Damian Poddebniak of Münster University of Applied
Sciences, Christian Dresen of Münster University of Applied Sciences
, Jens Müller of Ruhr University Bochum, Fabian Ising of Münster
University of Applied Sciences, Sebastian Schinzel of Münster
University of Applied Sciences, Simon Friedberger of KU Leuven, Juraj
Somorovsky of Ruhr University Bochum, Jörg Schwenk of Ruhr
University Bochum

In that light, I would think it's safe to claim that android is not vulnerable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants