[00:00.000 --> 00:07.560] Hello everyone. So, um, welcome to this year's email security talk at, um, DefCon. So, uh, my [00:07.560 --> 00:11.320] name is Jens Muller. I'm a PhD student at the Jeffrey Network Data Security at the [00:11.320 --> 00:15.800] University of, uh, Bochum in Germany. And, uh, this is joint work with the University of [00:15.800 --> 00:22.680] Applied Sciences in Münster, uh, on covert content attacks targeting PGP and asthma [00:22.680 --> 00:29.980] based encryption and digital signatures. Okay, so, um, what happened in the world of, uh, [00:30.000 --> 00:36.180] email security last year? E-fail happened. Some of you may remember it. It was one of the [00:36.180 --> 00:41.660] most important attacks of last year. Uh, why was E-fail so important? Because it was one of [00:41.660 --> 00:48.280] those attacks that come with a logo. Okay, and besides some click baiting headlines we've [00:48.280 --> 00:53.420] seen in the press, actually E-fail was a real world crypto issue targeting the cipher [00:53.420 --> 00:59.980] modes of operation in those PGP and asthma with a lot of things not fixed until today. So, [00:59.980 --> 01:08.360] when we did E-fail last year, we also stumbled across some minor bugs in, in email clients. [01:08.360 --> 01:13.900] So we thought it would be minor bugs, but then we looked deeper and, uh, then we found out, [01:13.900 --> 01:20.800] whoa, that's actually totally RFC standard, uh, behavior of email. And that's what I'm going [01:20.800 --> 01:27.780] to talk about today. So we are not going to do any math, not, no crypto, but super practical, [01:27.780 --> 01:33.160] uh, and super simple attacks against encryption and digital signatures in the context of [01:33.160 --> 01:38.940] email. Okay, so here's an outline of the talk. First I'm going to give you a short [01:38.940 --> 01:45.380] introduction on, uh, email and PGP and asthma. Um, then I'm going to come to the attacks on [01:45.380 --> 01:50.900] encryption and digital signatures and an evaluation of those attacks on 24 widely used [01:50.900 --> 01:56.560] email clients. Uh, and finally I'm going to show some count images so developers of email [01:56.560 --> 02:02.440] clients can protect, um, their customers from those attacks. Okay, let's start with [02:02.440 --> 02:11.420] technology's promise. So in the 90s we've heard, um, representatives of the cyber movement, [02:11.420 --> 02:17.820] cyberpunk movement claiming, like, strong crypto is mathematically unbreakable, use it, [02:17.820 --> 02:23.760] encryption for the masses. And they were right, of course, yes, we should use it. Um, and [02:23.760 --> 02:28.660] then we've heard other actors like government people, they didn't believe in mass [02:28.660 --> 02:36.820] encryption at that time, but they, uh, like to think about, well, in the year 2000 everybody [02:36.820 --> 02:41.520] will use, like, digital signatures to sign their business contracts and things like that. [02:41.520 --> 02:47.980] Which also didn't really happen, but, um, well it's based on the same idea that they're [02:47.980 --> 02:54.620] mathematically hard to solve, uh, problems, okay? Um, so, now let me ask the what if [02:54.620 --> 03:01.520] question. What if those claims could be bypassed with a single reply to a benign looking [03:01.520 --> 03:08.740] email? And that's what today's talk is going to be about. Okay, to fully understand, let me [03:08.740 --> 03:14.520] give you a brief history lesson on email. So, in the beginning there was ASCII text [03:14.520 --> 03:20.640] messages, okay? And it was good, okay? With a great signal to noise ratio, no spam, [03:20.640 --> 03:26.620] basically, and until today emails consist of, like, a header which contains, uh, [03:26.620 --> 03:31.100] information about maybe sender, recipient, subject, and so on, and a body containing the [03:31.100 --> 03:39.000] actual message. And because email back in the time was transferred usually over unencrypted [03:39.000 --> 03:44.920] insecure channels, um, people began to think about privacy, okay? So, Phil Zimmerman came [03:44.920 --> 03:51.560] up with this great idea of traditional PGP, PGP inline back then. So, which basically [03:51.560 --> 03:59.500] leaves the header as it is, but encrypts the text message body using public key crypto. And [03:59.500 --> 04:05.600] was good back at the time, okay? And then people came around and thought, well, we want to [04:05.600 --> 04:10.020] do more. We want not only to send text messages over email, we also want to send, like, [04:10.020 --> 04:15.600] binary data, binary files, and so on. Therefore, multipurpose in-chain mail extensions was [04:15.600 --> 04:21.520] born. So, with MIME email, you can, for example, send an email that contains of multiple [04:21.520 --> 04:28.260] parts of multiple data formats, okay? Like, for example, you could have a mixed multi-part [04:28.260 --> 04:33.920] message, uh, with multiple parts that are separated by some boundary, and in this example [04:33.920 --> 04:41.600] we have two plain text, two ASCII text messages. Okay, resulting in a structure like this. [04:42.100 --> 04:47.860] But you could also, of course, for example, use, uh, create an HTML email with a PDF [04:47.860 --> 04:55.460] attachment, okay? So, MIME, MIME is how modern email is used today. Okay, and then, um, based [04:55.460 --> 05:01.140] on the MIME standard, people came around with yet another, um, standard for email end to [05:01.140 --> 05:07.160] end encryption, which is S-MIME. You probably have heard about it, um, similar to PGP, but [05:07.160 --> 05:12.280] more used in, like, corporate environments. So, um, S-MIME defines the content type of [05:12.280 --> 05:20.280] application, PQSS7, MIME, and then encrypts and Base64 encodes the body of the email, which [05:20.280 --> 05:27.840] could, by itself, be a complete MIME structure. Okay, so how do you, um, encrypt your [05:27.840 --> 05:34.420] emails in, uh, 2019? So, we still have those two competing standards, like PGP, which is [05:34.420 --> 05:41.000] more used by journalists, activists, hackers, by us, and S-MIME, which is more used in [05:41.000 --> 05:46.260] business environments, or, like, by universities, you can afford running a central certificate [05:46.260 --> 05:53.020] authority. And besides the, the trust model, actually, both standards use more or less the [05:53.020 --> 05:57.000] same crypto, which is, which has a lot of flaws, and it's all crypto, but it's not, I'm not [05:57.000 --> 06:01.560] going to talk about crypto today, because the attacks I'm going to present now are [06:01.560 --> 06:07.040] basically independent of the actual encryption scheme, okay? Let it be PGP, or S-MIME, or [06:07.040 --> 06:13.300] whatever. At least, um, unless, um, so they must be used in the context of email, then we can [06:13.300 --> 06:20.760] probably, uh, apply them. Okay, so let me come to the attacks on encryption. So, our attacker [06:20.760 --> 06:27.140] model is super simple. The ETH trap, or ETH, has somehow captured ciphertext between two [06:27.140 --> 06:32.480] communication parties. It's quite a strong attacker model, obviously, but the only reason [06:32.480 --> 06:37.780] why you use end-to-end email encryption is that an insecure communication channel, of [06:37.780 --> 06:45.280] course, is presumed, right? So, um, what ETH now can do with the, uh, captured ciphertext email [06:45.280 --> 06:51.720] is she can modify the outer structure of the email. We do not do any ciphertext modifications, [06:51.720 --> 06:57.340] any bit-flipping today, but we modify the, the outer MIME structure, okay? And then she can [06:57.340 --> 07:03.840] re-send that modified email to the victim, which can either be the original sender, or the [07:03.840 --> 07:10.100] original recipient of the message, because emails are usually encrypted with the, uh, [07:10.100 --> 07:15.220] public key of both of them, so both of them should be able to decrypt the email later. Okay, [07:15.220 --> 07:23.620] both of them can be misused as decryption oracle. Um, so, here's an outline of the attack. [07:23.780 --> 07:31.720] The attacker ETH, um, sends a benign-looking, uh, email message that is visible to Johnny. [07:31.740 --> 07:40.720] And then she, um, appends some, um, something we call, um, um, covert content, like the [07:40.720 --> 07:46.640] hidden ciphertext part, okay? Which Johnny cannot really see, but Johnny's email client can [07:46.640 --> 07:53.060] parse it. So, for reasons we will see later, if Johnny replies to that, uh, message, um, to [07:53.060 --> 07:59.140] that harmless-looking message, he will leak the plain text to the attacker. Okay, how do we [07:59.140 --> 08:07.560] do that in practice? So, assume this is, um, a captured SMIME email from Alice to Johnny. [08:07.560 --> 08:13.960] Now, what could ETH possibly do with that email? So, of course, she can simply change the [08:13.960 --> 08:19.700] from address to her own address, so replies go to her, okay? And then what she can do is she [08:19.700 --> 08:27.520] can use this ciphertext part and wrap it into her own specially-crafted MIME structure. [08:27.740 --> 08:35.880] Okay, for example, she can prepend some ASCII text, resulting in a MIME tree like this. So, [08:35.880 --> 08:41.400] um, an email client would then, of course, parse that message and see this encrypted part [08:41.400 --> 08:46.040] and decrypt it, okay? That's what email clients do. So, this, uh, this message would be [08:46.040 --> 08:52.700] shown in Thunderbird like this. You have the attacker's part and the original ciphertext [08:52.700 --> 08:58.680] which got translated to the plain text, which got decrypted by the email client, okay? You [08:58.680 --> 09:03.660] see what I'm pointing you to. What happens if we reply to that message, okay? If Johnny [09:03.660 --> 09:09.220] replies to that message, he will also leak the secret message, he will leak the plain text. [09:09.820 --> 09:15.000] Well, Johnny is not the brightest guy on planet Earth, but Johnny is not super dumb either. He [09:15.000 --> 09:22.900] sees that something fishy is going on. But all we need now is some way to hide the existence of [09:22.900 --> 09:29.160] the second part. So, what we can simply do is some obfuscation, like add a lot of new lines, [09:29.160 --> 09:33.620] um, and if Johnny's in a hurry, he may already reply to that message, okay? Uh, and thereby [09:33.620 --> 09:38.600] leak the ciphertext if it doesn't scroll down. We could also hide it with some longer [09:38.600 --> 09:45.260] communication, um, history, or things like that. We could also use HTML and simply comment [09:45.260 --> 09:50.600] out the second part. So, if Johnny replies to that email, he sees nothing but a benign [09:50.600 --> 09:59.140] looking message and thereby leaks the plain text. So, if email clients do try to, uh, [09:59.160 --> 10:05.740] counter those attacks and enforce a strong isolation between multiple MIME parts, well, we [10:05.740 --> 10:11.960] can simply break that isolation using content ideas which allow you to refer from one MIME [10:11.960 --> 10:17.840] part to another part, which is in an RC standard. So, it's supported by most email clients. [10:18.880 --> 10:24.620] Okay, you may say, well, that's HTML issues, but, um, there are lots of other possibilities, [10:24.620 --> 10:29.180] like, for example, we could also define the second part as an attachment, use unicode [10:29.180 --> 10:35.460] tricks, encoding tricks, and so on. So, the takeaway here is that it's not an HTML issue, [10:35.460 --> 10:40.640] okay? The issue is MIME wrapping. Why is it possible to use the encrypted part in a [10:40.640 --> 10:46.880] completely different context, um, and then it's only engineering, um, to hide it, basically. [10:46.880 --> 11:11.450] Okay, so, um, I hope I can give you a demo for that one. I need some help here. Okay, so, [11:11.470 --> 11:35.740] can you sync the screens? Thank you. Okay, so, um, in this example we have, um, a captured, um, [11:35.740 --> 11:42.620] as my message, um, from the manager to Johnny, um, but it could also be PGP MIME or, or PGP [11:42.620 --> 11:48.480] inline or whatever. Now, Eve can, of course, modify the subject of that email and also [11:48.480 --> 11:53.240] change the from address. And what she does now is she wraps, simply wraps that encrypted [11:53.240 --> 11:59.820] part into her own MIME structure. In this example we have some HTML message, um, before the [11:59.820 --> 12:06.440] actual ciphertext part. And in this example we use some iframe to basically hide the second [12:06.440 --> 12:14.240] part. Okay, um, so, uh, let's send that email to poor Johnny. And what Johnny's email client, [12:14.240 --> 12:20.480] in this example, uh, Apple Mail, does is it will only, of course, display the first part [12:20.480 --> 12:25.040] because of the iframe. So it will only display something like, hello Johnny, I'm interested in [12:25.040 --> 12:28.180] your research, could me, could you tell me, blah, blah, blah. And because Johnny's a nice [12:28.180 --> 12:33.040] guy, he replies to that email, okay? He uses email as a communication medium. And in the [12:33.040 --> 12:39.100] reply to Eve, uh, you will not see anything visible, but if you look at the, if Eve looks at [12:39.100 --> 12:45.820] the source code, she will see that in the coded, uh, reply message, not only the visible [12:45.820 --> 12:57.760] part, but also the invisible part containing the, uh, ciphertext was, uh, coded. Okay, so, [12:57.760 --> 13:05.320] um, the takeaway here is that, um, you cannot only, um, leak one single ciphertext, okay? So [13:05.320 --> 13:10.880] the NSA could, for example, have captured hundreds of emails, um, over years. And then she [13:10.880 --> 13:15.580] wraps all of them into one specially crafted email, resends that email to the victim, and [13:15.580 --> 13:22.420] with one single reply, hundreds of plain text would be leaked. Okay, so, um, we thought, can [13:22.420 --> 13:28.240] we adapt those attacks maybe to digital signatures? So the, um, the outline is pretty much [13:28.240 --> 13:34.500] the same. Again, we, um, have some benign looking message, and in this case, what we want to [13:34.500 --> 13:40.220] do is we want to misuse the email client of Johnny, not as a decryption oracle, but as a [13:40.220 --> 13:45.240] signing oracle, okay? We want to obtain a validly signed, uh, message that displays [13:45.240 --> 13:50.580] I hereby declare war. Okay, Johnny is the commander-in-chief in this example, and we want to [13:50.580 --> 13:56.960] start false flag warfare. Okay, if Johnny replies to that message, he will sign, he will [13:56.960 --> 14:03.400] quote and sign, therefore, both parts. And for, for, with some tricks we will see, uh, in a [14:03.400 --> 14:09.840] second, we can resend that signed message to a third party, like to some army general, who [14:09.840 --> 14:14.180] will then only see a displayed string, which is signed by Johnny and says, I hereby [14:14.180 --> 14:20.140] declare war. So, hopefully, the army commander general will give some phone call to Johnny [14:20.140 --> 14:26.080] before actually starting that war, right? Okay, um, how can we do that in practice? Um, well, [14:26.080 --> 14:32.880] we can use HTML email and, um, have two strings, uh, a malicious one and, um, a benign one, and [14:32.880 --> 14:39.200] we can wrap the malicious message into some div class, and all we need now is some CSS [14:39.200 --> 14:47.100] conditional rules to, based on some conditions, hide the first text or the second text, okay? So, [14:47.100 --> 14:53.340] for example, we can do this using the media CSS conditional rule. So, based on the screen [14:53.340 --> 14:58.940] size, for example, so, the certain text is hidden, maybe on mobile devices, but shown on [14:58.940 --> 15:08.940] desktop devices. Okay, so, um, if this email is, um, opened by Johnny, in most email clients, [15:09.480 --> 15:15.700] a benign looking message, he has to reply. Johnny actually, uh, uses this technology, believes [15:15.700 --> 15:20.680] in PGP and SMAM, therefore he signs all his outgoing messages, okay? Because he does not want [15:20.680 --> 15:27.640] to be impersonated. But the signed message, um, on a desktop device, with another screen [15:27.640 --> 15:34.480] size, would, of course, um, have a completely different string being displayed, okay? Okay, [15:34.480 --> 15:39.240] so, now we can target, like, the device type, okay? Like, like, you know, mobile, desktop, [15:39.240 --> 15:45.340] maybe that's not too interesting. But we can also target, um, each and every email client. So, [15:45.340 --> 15:50.780] using the supports, uh, conditional rule in CSS, we could be, um, fingerprinted, um, all [15:50.780 --> 15:56.840] major email clients, um, and show, can show a certain string only on certain email clients. Um, [15:56.840 --> 16:02.820] and also we can go down further and target certain user accounts only, which is what I'm [16:02.820 --> 16:19.550] hopefully going to show you, um, now. Okay, so, um, in this example we have, um, only two [16:19.550 --> 16:25.810] parties, like, um, Eve directly impersonates the manager, so it's an email from the manager to [16:25.810 --> 16:31.490] Johnny. Eve directly spoofs the, the, um, from address, um, to make things a bit easier in [16:31.490 --> 16:37.830] this example. And what you can see here is some CSS code based on the mods document URL [16:37.830 --> 16:43.390] prefix. If it starts with IMAP colon double slash manager at something, a certain text is [16:43.390 --> 16:51.470] shown, okay? So, let's send that message from the manager to poor Johnny. So, as you can see, [16:51.470 --> 16:57.670] there's, uh, just some harmlessly looking message, um, and, well, what's up Johnny from the [16:57.670 --> 17:02.530] manager, well, whatever, Johnny replies, yeah, I'm fine, blah, blah. And as said, Johnny [17:02.530 --> 17:06.750] believes in PGP and S-MIME, he, he uses actually this technology, he always signs his [17:06.750 --> 17:11.770] outgoing messages, okay? And now if this message is received by the manager, a completely [17:11.770 --> 17:16.710] different string is shown, like, like, I hereby quit my job, but it's validly signed by [17:16.710 --> 17:26.130] Johnny. Okay, that's HTML tricks. For signatures, that's HTML tricks, but anyway, um, if we [17:26.130 --> 17:31.250] define digital signatures as mathematically unbreakable and unfortunate, such simple [17:31.250 --> 17:38.190] stupid tricks shouldn't be working, right? Okay, so, now, now, let me come to an [17:38.190 --> 17:43.730] evaluation of those attacks. So, um, we tested, uh, 24 widely used, uh, email clients, [17:43.730 --> 17:49.830] basically every client that supports either PGP or S-MIME or both. And regarding being [17:49.830 --> 17:57.130] misused as a decryption oracle, um, a lot of email clients, including, uh, Thunderbird and [17:57.130 --> 18:02.530] Apple Mail, for example, are vulnerable, and all Linux-based email clients. And, uh, my [18:02.530 --> 18:08.230] guess here is actually that email clients where the, um, the developers actually read the [18:08.230 --> 18:13.350] RFCs and tried to implement a standard compatible email client, they are more vulnerable [18:13.750 --> 18:20.570] than those who maybe just had a quick hack for a PGP plugin. And, uh, regarding signatures, [18:20.570 --> 18:25.350] it's kind of even worse, I mean, basically every email client that supports HTML, uh, can [18:25.350 --> 18:30.730] be at least tricked to, uh, display a certain, uh, message only in this client and things [18:30.730 --> 18:35.690] like that. It's hard to counter against. Also, the signature issues are not fixed until [18:35.690 --> 18:44.390] today. Okay, so, now, let me come to some, uh, some counter measures. Well, you may say, [18:44.390 --> 18:50.010] let's accept ASCII text only. Let's finally get rid of HTML email. I'm totally on your [18:50.010 --> 18:56.810] side. Let's start getting another ASCII ribbon campaign. But, it will not solve the [18:56.810 --> 19:02.190] decryption issues, okay? Because it's, um, the problem is mime-wrapping, okay? We could [19:02.190 --> 19:06.350] also use some Unicode tricks and other tricks to hide the second part. It will not, [19:06.350 --> 19:11.470] unfortunately, solve the decryption oracle tricks. Um, we could say, what about do not [19:11.470 --> 19:16.730] decrypt unless the email is validly signed? Doesn't work either in the context of email, [19:16.730 --> 19:21.950] um, because attackers can simply strip the signatures and resign on their own, on their own [19:21.950 --> 19:28.570] identity. So, what a lot of email clients now did as a counter measure is they warned the [19:28.570 --> 19:35.070] user if the email is partly encrypted. Um, I think that's a bad idea. Because it delegates [19:35.070 --> 19:40.510] security decisions back to the user, which, which I don't want. So, what I would prefer is [19:40.510 --> 19:45.730] like having an all or nothing decryption. Email clients should not decrypt my email unless [19:45.730 --> 19:52.210] the whole, um, message was encrypted within one single mime blob, one single element, okay? [19:54.010 --> 20:00.390] Yeah. Uh, also we could, of course, think about other cryptographic counter measures. Um, [20:00.390 --> 20:04.670] one thing maybe regarding all or nothing encryption, it will break some, it will, may [20:04.670 --> 20:10.390] break some PGP inline emails. It will break, definitely, emails, some emails composed by [20:10.390 --> 20:14.470] K-mail, which allows you to encrypt only the attachment and things like that. But it's a [20:14.470 --> 20:19.510] tradeoff between, you know, compatibility and security. Okay, also we could think about [20:19.510 --> 20:24.170] cryptographic counter measures, like, why is it even possible to use the ciphertext from one [20:24.170 --> 20:29.230] email and years later, use it in a completely different context in a completely different [20:29.230 --> 20:34.570] email? Modern online protocols, they would, you have a binding of the ciphertext to the [20:34.570 --> 20:39.630] current communication session, right? Um, in here, email, this, this still seems hard, hard [20:39.630 --> 20:46.350] to do. Okay, regarding signatures, you may say, let's drop simply support for CSS. I'm on [20:46.350 --> 20:53.130] your side, yeah? Um, I think, unfortunately, a lot of, like, a lot of people want to have [20:53.130 --> 20:59.210] fancy formatting and, and, which is done by CSS, so, so it may not be realistic for, for [20:59.210 --> 21:04.750] many email clients. So, um, but email client vendors, um, and, and implementers, what they [21:04.750 --> 21:11.090] can at least do is only reply with ASCII text or remove CSS styles from replies so they [21:11.090 --> 21:20.530] cannot be misused as, uh, signing oracles anymore. Okay, so, um, let me come to a [21:20.530 --> 21:27.890] conclusion. Um, so crypto is great, okay? But sometimes super simple bypasses exist. Sometimes [21:27.890 --> 21:33.350] we don't have to break the mass, um, and in, in this example, this bypasses existed for, for [21:33.350 --> 21:38.790] decades, okay? And the vast majority of detested clients are vulnerable to either being [21:38.790 --> 21:44.410] misused as decryption oracles or, or signing oracles or both. Um, and, and PGP and [21:44.410 --> 21:49.070] SRAM, they are more or less equally affected, okay? Because we do not target the underlying [21:49.070 --> 21:54.670] cryptography. We target standard email features. So, um, this brings me to the final [21:54.670 --> 22:01.010] question. Is it even possible to build security on top of email? I think this is very, very [22:01.010 --> 22:08.650] challenging, okay? And this talk is just one of many examples, um, where things fail. Okay, [22:08.650 --> 22:16.050] so, um, we reported, um, all those issues to affected vendors in, uh, until February and, uh, [22:16.050 --> 22:22.510] most of the decryption oracle issues are fixed now. Uh, the signing issues are not fixed. Um, [22:22.510 --> 22:27.050] anyway, we are going full disclosure now, so if you want to test if your client is still [22:27.050 --> 22:33.410] vulnerable, um, you can use the test cases on, on GitHub. Okay, thank you guys, and enjoy [22:33.410 --> 22:34.930] this great conference.