00:00:00.000,00:00:05.005 >>Hello, hello everyone! So um, welcome to this year’s email security talk at um, Defcon. So 00:00:07.207,00:00:12.513 uh, my name is Jens Müller. I’m a PhD student at [00:11] data security at University of Bochum 00:00:12.513,00:00:18.252 in Germany and uh, this is joint work with the University of Applied Sciences in Münster, uh, 00:00:18.252,00:00:25.225 on covert content attacks targeting PGP and S/MIME based encryption and digital 00:00:25.225,00:00:30.230 signatures. Okay, so um, what happened in the world of email security last year. EFAIL 00:00:33.100,00:00:37.537 happened, some of you may remember it. It was one of the most important attacks of last 00:00:37.537,00:00:43.277 year, uh. Why was EFAIL so important? Because it was one of those attacks that come with a 00:00:43.277,00:00:49.983 logo. Okay, and besides some clickbaiting headlines we’ve seen in the press actually, it 00:00:49.983,00:00:55.822 uh, was a real world crypto issue targeting the cipher modes of operation in modes of PGP and 00:00:55.822,00:01:00.761 S/MIME, with a lot of things not fixed until today. So, when we did EFAIL last year, we also 00:01:03.830,00:01:08.835 stumbled across some minor bugs in email clients. So we thought there’d be minor bugs, but then 00:01:11.038,00:01:16.043 we looked deeper and uh, then we found out, whoa, that's actually totally ARC standard behavior of 00:01:19.112,00:01:24.151 email, and that’s what I’m going to talk about today. So we are not going to be doing any masks, 00:01:24.151,00:01:29.156 not, no crypto, but super practical uh, and super simple attacks encryption and digital 00:01:31.224,00:01:37.798 signatures in the context of email. Okay, so here’s an outline of the talk. First I’m 00:01:37.798,00:01:40.067 going to give you a short introduction on email and PGP and S/MIME, um then I’m going to 00:01:40.067,00:01:45.072 come to the attacks on encryption and digital signatures, and evaluation on 24 00:01:50.243,00:01:55.582 widely used email clients. Um, and finally I’m going to show some countermeasures so 00:01:55.582,00:02:02.089 developers of email clients can protect their customers from those attacks. Okay let’s start 00:02:02.089,00:02:07.094 with technology’s promise. So, in the 90s, we’ve heard, um, representation of the cyber 00:02:10.831,00:02:17.471 movement, cyberpunk movement claiming like, strong crypto is mathematically unbreakable, use 00:02:17.471,00:02:23.744 it, encryption for the masses. And they were right, yes, of course we should use it. Um, and 00:02:23.744,00:02:28.682 then we’ve heard other actors like government people, they didn’t believe in mass 00:02:28.682,00:02:35.389 encryption at that time, but they uh, like to sing about, well in the year 2000, everybody 00:02:35.389,00:02:42.029 will use like digital signatures to sign their business contracts and things like that, which also 00:02:42.029,00:02:48.568 didn’t really happen. But, um, well it’s based on the same idea that they are mathematically 00:02:48.568,00:02:53.573 hard to solve uh, problems. Okay? Um, so now let me ask the ‘what if’ question. What if 00:02:56.543,00:03:01.481 those claims could be bypassed with a single reply to a benign looking email. And, that’s what 00:03:03.617,00:03:10.157 today’s talk is going to be about. Ok, to fully understand let me give you a brief history 00:03:10.157,00:03:16.730 lesson on email. So, in the beginning there was ASCII text messages okay? And it was good, 00:03:16.730,00:03:21.735 okay. We had a great signal to noise ratio, no spam basically, and until today emails consist 00:03:24.037,00:03:29.743 of like, header, which contains uh, information about maybe send or receive, subject and so on, 00:03:29.743,00:03:36.450 and a body containing the actual message. And because email was, back in the time, transferred, 00:03:36.450,00:03:43.023 usually over unencrypted, insecure channels. Um, people began to think about privacy, 00:03:43.023,00:03:49.262 okay, so Phil Zimmermann came up with this great idea of traditional PGP, PGP inline back 00:03:49.262,00:03:54.267 then. So, which basically leaves the header as this, but encrypts the text message body using 00:03:57.604,00:04:02.542 public key crypto, and was good back at the time, okay. And then people came around and thought, 00:04:04.778,00:04:09.683 well we want to do more. We want not only to send text messages over email, we also want to send 00:04:09.683,00:04:14.588 like, binary data, binary files and so on, therefore, multipurpose internet mail 00:04:14.588,00:04:21.128 extensions was born. So with MIME email, you can for example send an email that contains, of 00:04:21.128,00:04:26.133 multiple parts of multiple data formats. Okay. Like for example you could have a mixed multipart 00:04:28.301,00:04:34.040 message uh with multiple parts that are separated by some boundary, and in this example we 00:04:34.040,00:04:39.045 have two plain text to ASCII text messages, okay, resulting in a structure like this. But 00:04:42.516,00:04:47.954 you could also of course for example use, uh, or create an HTML email with a pdf 00:04:47.954,00:04:52.959 attachment, okay. So MIME, MIME is how modern email is used today. Okay, and then uh, based 00:04:55.529,00:05:01.401 on the MIME standard, people came around with yet another, um standard for email end to end 00:05:01.401,00:05:07.307 encryption, which is S/MIME, you probably have heard about it. Um, similar to PGP, but more 00:05:07.307,00:05:12.245 used in like, corporate environments. So, um, S/MIME defines a content-type of 00:05:12.245,00:05:17.250 application/pkcs7-mime and then encrypts and base 64 encodes the body of the email which could by 00:05:20.921,00:05:25.926 itself be a complete MIME structure. Okay so how do you um, encrypt your emails in uh 00:05:28.828,00:05:35.569 2019? So we still have those two competing standards, like PGP which is more used by 00:05:35.569,00:05:40.574 journalists, activists, hackers; by us, and S/MIME which is more used in business environments or 00:05:42.709,00:05:47.914 like by universities who can afford running a central certificate authority. And 00:05:47.914,00:05:54.254 besides the trust model, actually both standards use more or less the same crypto, which 00:05:54.254,00:05:58.258 is, which has a lot of flaws and is old crypto but it’s not, I’m not going to talk about crypto 00:05:58.258,00:06:03.230 today, because the attacks I’m going to present now are basically independent of the 00:06:03.230,00:06:08.235 actual encryption scheme okay. Let it be PGP, or S/MIME, or whatever. At least um, unless 00:06:10.270,00:06:15.275 um, something must be used in the context of email then we can probably um, apply them. Okay so 00:06:17.277,00:06:22.983 let me come to the attacks on encryption so, our attacker model is super simple. The 00:06:22.983,00:06:29.222 eavesdropper Eve has somehow captured ciphertext between two communication parties. It’s 00:06:29.222,00:06:34.928 quite a strong attacker model, obviously, but the only reason why you use end to end email 00:06:34.928,00:06:41.801 encryption is that an insecure communication channel of course is presumed, right? So, um, what 00:06:41.801,00:06:48.008 Eve now can do is the captured ciphertext email is she can modify the outer structure of 00:06:48.008,00:06:53.380 the email. We do not do any ciphertext modifications, any bit flipping today, but we 00:06:53.380,00:06:59.786 modify the, the outer MIME structure, okay. And then she can resend that modified email 00:06:59.786,00:07:05.692 to the victim which can either be the original sender or the original recipient of the 00:07:05.692,00:07:11.298 message because emails are usually encrypted with the uh, public key of both of them so 00:07:11.298,00:07:18.238 both of them should be able to decrypt the email later. Okay both of them can be misused as a 00:07:18.238,00:07:23.243 decryption oracle. Um so, here is an outline of the attack. The attacker Eve, um sends a benign 00:07:27.814,00:07:32.819 looking uh email message that is visible to Johnny. And then she um, appends some um, something 00:07:36.089,00:07:41.094 we call um, um, covert content like the hidden ciphertext part okay, which Johnny cannot really 00:07:44.297,00:07:50.837 see but his email client can parse it. So for reasons we will see later, if Johnny replies to 00:07:50.837,00:07:56.409 that uh message, um to that harmlessly looking message he will leak the plain text to the 00:07:56.409,00:08:01.348 attacker. Okay, how do we do that in practice. So assume this is um, a captured S/MIME email 00:08:05.618,00:08:10.623 from Alice to Johnny. Now what could Eve possibly do with that email. So of course she can 00:08:12.959,00:08:18.965 simply change the from address to her own address so replies go to here, okay. And then what she 00:08:18.965,00:08:23.970 can do is she can use this ciphertext part and wrap it into her own specially crafted MIME 00:08:26.373,00:08:33.012 structure. Okay for example she can prepend some ASCII text resulting in a MIME tree like 00:08:33.012,00:08:38.017 this. So an email client would then of course parse that message and see there’s an 00:08:40.653,00:08:45.692 encrypted part and decrypted. Okay that’s what email clients do. So this uh this message 00:08:45.692,00:08:52.065 would be shown in Thunderbird like this. You have the attacker’s part and the original 00:08:52.065,00:08:56.703 ciphertext which got translated to the plain text which got decrypted by the email client, 00:08:56.703,00:09:03.610 okay. You see what I’m pointing you to, what happens if we reply to that message, okay? If Johnny 00:09:03.610,00:09:09.783 replies to that message he will also leak the secret message, he will also leak the plain text. 00:09:09.783,00:09:14.788 But Johnny is not the practiced guy on planned errors, but Johnny is not super dumb either. 00:09:14.788,00:09:19.793 He sees that something fishy is going on. But all we need now is some way to hide the existence 00:09:22.595,00:09:27.901 of the second part. So what we can simply do is some obfuscation like, add a lot of 00:09:27.901,00:09:32.472 new lines. Um, and if Johnny is in a hurry he may already reply to that message, okay, and 00:09:32.472,00:09:38.311 thereby leak the ciphertext if he doesn’t scroll down. We could also hide it with some some 00:09:38.311,00:09:43.316 lower communication, um history, things like that. We could also use HTML and simply common dot 00:09:45.618,00:09:51.257 the second part. So if Johnny replies to that email he sees nothing but a benign looking 00:09:51.257,00:09:56.262 message and thereby leaks the plain text. So, if email clients do try to account for those 00:09:59.833,00:10:06.706 attacks and enforce a strong isolation between multiple MIME parts, well we can simply break 00:10:06.706,00:10:11.711 that isolation using content IDs which allow you to reference one MIME part to another part which 00:10:13.813,00:10:20.520 in an ARC standard so it’s supported by most email clients. Okay, you may say, well that’s 00:10:20.520,00:10:26.326 HTML issues. But um, there are lots of other possibilities like for example we could also define 00:10:26.326,00:10:31.998 the second part as an attachment, use unicode tricks and coding tricks and so on. So, 00:10:31.998,00:10:37.604 the take away here is that it’s not an HTML issue okay? The issue is MIME repping. Why is it 00:10:37.604,00:10:43.042 possible to use the encrypted part and complete a different context and then it’s only 00:10:43.042,00:10:49.616 engineering to hide it basically. Okay, so um, I hope I can give you a demo for that 00:10:49.616,00:10:54.621 one. I need some help here. Thank you Okay so um, in this example we have um, captured an 00:11:35.828,00:11:40.833 S/MIME message um from the manager to Johnny. Um but it could also be PGP MIME or or PGP 00:11:43.036,00:11:49.108 inline or whatever. Now Eve can, of course modify the subject of that email and also change the 00:11:49.108,00:11:54.781 from address and what she does now is she wraps, simply wraps that encrypted part into her own 00:11:54.781,00:12:01.387 MIME structure. In this example we have some HTML message uh, before the actual ciphertext 00:12:01.387,00:12:06.392 part, and in this example we use some iframe to basically hide the second part. Okay, um, so uh 00:12:09.562,00:12:15.735 let’s send that email to poor Johnny, and what Johnny’s email client in this example uh, Apple 00:12:15.735,00:12:22.375 Mail, does is, it will only of course display the first part because of that iframe. So it 00:12:22.375,00:12:26.245 will only display something like ‘Hello Johnny I’m interested in your research, could me, could 00:12:26.245,00:12:29.849 you tell me blah blah blah’ and because Johnny is a nice guy he replies to the email. Okay, he 00:12:29.849,00:12:36.389 uses email as a communication medium. And in the reply to Eve, uh you do not see anything 00:12:36.389,00:12:43.229 visible, but if you look at, if she looks at the source code she will see that in the corroded 00:12:43.229,00:12:48.234 reply message, not only the visible part, but also the invisible part containing the uh 00:12:52.305,00:12:57.310 ciphertext once coded. Okay, so um, the takeaway here is that um, you cannot only um, leak one 00:13:03.449,00:13:09.188 single ciphertext okay? So the NSA could for example, have captured hundreds of emails um, 00:13:09.188,00:13:14.160 over years, and then she wraps all of them into one specially crafted email, resends that 00:13:14.160,00:13:20.933 email to the victim, and with one single reply, hundreds of plain texts would be leaked. 00:13:20.933,00:13:26.439 Okay, so um, we thought maybe we could adapt those attacks maybe to digital signatures. SO the 00:13:26.439,00:13:33.379 um, the authen is pretty much the same, we um have some benign looking message, and in this 00:13:33.379,00:13:38.851 case, what we want to do is we want to misuse the email client of Johnny, not as a decryption 00:13:38.851,00:13:44.757 oracle, but as a signing oracle, okay. We want to obtain a validly signed, uh message that 00:13:44.757,00:13:50.229 displays, ‘I hereby declare war’. Okay, Johnny is commander in chief in this example and we 00:13:50.229,00:13:56.769 want to start forced flex warfare. Okay if Johnny replies to that message, he will sign, 00:13:56.769,00:14:01.708 he will quote and sign therefor both parts and for for, with some tricks, in a second, we can 00:14:04.310,00:14:10.983 resent that signed message to a third party like some army general who will then only see a 00:14:10.983,00:14:16.355 displayed string which is signed by Johnny and says ‘I hereby declare war.’ So hopefully the 00:14:16.355,00:14:21.828 army commander, the general will give some phone call to Johnny before starting that war. 00:14:21.828,00:14:28.668 Alright. Okay, um, how can we do that in practice? Um, well we can use HTML email and have um 00:14:28.668,00:14:35.541 two strings; uh a malicious one and um a benign one, and we can wrap the malicious message into 00:14:35.541,00:14:41.781 some div class, and all we need now is some css conditional rules to, based on some 00:14:41.781,00:14:46.786 conditions, hide the first text or the second text, okay. So, for example we can do this using 00:14:49.422,00:14:54.427 the media CSS conditional rule. So based on the screen size, for example, so the certain text is 00:14:56.462,00:15:01.400 hidden on mobile devices but hidden on desktop devices. Okay, so um, if this email um, opened 00:15:03.770,00:15:08.775 by Johnny, in most email clients so, what will be shown is a benign looking message. Hits the 00:15:10.843,00:15:17.650 reply, Johnny actually uses this technology, he believes in PGP and S/MIME, definitely signs all 00:15:17.650,00:15:23.723 of his outgoing messages, okay, because he does not want to be impersonated. But the signed 00:15:23.723,00:15:29.929 message, um, on a desktop device with another screen size would of course um have a completely 00:15:29.929,00:15:34.934 different string being displayed okay. Okay so now we can like target the device type. Okay, 00:15:37.136,00:15:42.308 like like you know mobile, desktop, maybe that’s not too interesting. But we can also 00:15:42.308,00:15:47.413 target um, each and every email client. Alright, so using the supports conditional rule in 00:15:47.413,00:15:53.252 CSS, we could um be fingerprinted um all major clients, um, and show, can show 00:15:53.252,00:15:59.992 a certain string on certain email clients. Um and also we can go down further and target 00:15:59.992,00:16:04.931 certain user accounts only, which is, what I’m hopefully going to show you um, now. Okay 00:16:16.909,00:16:23.716 so um, in this example we have um, only two parties like um, Eve directly in person, it’s the 00:16:23.716,00:16:28.754 managers, or it’s an email from the manager to Johnny, it directly spoofs the um from 00:16:28.754,00:16:35.094 address um, to make things a bit easier in this example, and what you can see here is something is 00:16:35.094,00:16:40.700 s code based on the mods document url prefix. If it starts with imap colon double 00:16:40.700,00:16:47.340 slash manager, at something, a certain text is shown, okay? So let’s send that message from the 00:16:47.340,00:16:53.779 manager to poor Johnny. So as you can see there is uh just some harmlessly looking um 00:16:53.779,00:17:00.119 message um, well, ‘what’s up Johnny’ from the manager well whatever Johnny replies, ‘ Yeah 00:17:00.119,00:17:05.391 I’m fine blah blah.’ And I said that Johnny believes in PGP and S/MIME, he he uses actually this 00:17:05.391,00:17:10.730 technology he always signs his outgoing messages okay. And now if this message received by the 00:17:10.730,00:17:15.835 manager, a completely different string is shown like, ‘I hereby quit my job’ but it’s validly 00:17:15.835,00:17:20.840 signed by Johnny. Okay, that’s HTML tricks. For signatures, that’s HTML tricks, but, anyway 00:17:24.176,00:17:30.883 um, if we define digital signatures as mathematically unbreakable and unforgable, such 00:17:30.883,00:17:35.888 simple, stupid tricks shouldn’t be working, right? Okay, so now let me come to evaluation of 00:17:38.858,00:17:44.897 those attacks. So um, we tested 24 widely used uh email clients. Basically every client that 00:17:44.897,00:17:49.902 supports PGP or S/MIME or both, and regarding being misused as a decryption oracle, um, uh, a lot 00:17:54.106,00:17:59.745 of email clients including uh thunderbird and Apple Mail for example, are vulnerable and all 00:17:59.745,00:18:04.684 Linux based email clients. And um my guess here is actually that email clients where the um, 00:18:06.786,00:18:12.525 the developers actually read the RFCs and tried to a standard compatible email client, they 00:18:12.525,00:18:17.530 are more vulnerable than those who maybe just had a quick hack for a PGP plugin. And regarding 00:18:19.865,00:18:25.104 signatures, it’s kind of even worse, i mean uh basically every email client that supports HTML 00:18:25.104,00:18:31.143 can be at least tricked to uh display a certain message only in this client and things like 00:18:31.143,00:18:35.715 that. It’s hard to counter against. Also the signature issues are not fixed until 00:18:35.715,00:18:40.720 today. Okay so now let me come to some uh some countermeasures. Well, you may say, let’s accept 00:18:44.991,00:18:51.597 ASCII text only, let’s finally get rid of HTML email. I’m totally on your side. Let’s 00:18:51.597,00:18:58.437 start get another ASCII written campaign, but, it will not solve the decryption issues, okay. 00:18:58.437,00:19:03.743 Because the problem is MIME repping. Okay, we could also use some unicode tricks and other 00:19:03.743,00:19:07.880 tricks to hide the second part. It will not unfortunately solve the decryption oracle tricks. 00:19:07.880,00:19:12.885 Um, we could say do not decrypt unless the email is validly signed; doesn’t work either in 00:19:15.287,00:19:21.527 the context of email um because attackers can simply strip the signatures on their own, under 00:19:21.527,00:19:26.532 their own identity. So what a lot of email clients did as a countermeasure is they warned 00:19:28.701,00:19:35.074 the user if the email is partly encrypted. Um, I think that’s a bad idea, because it delegates 00:19:35.074,00:19:40.513 the security decisions back to the user which which I don’t want. So what I would prefer is 00:19:40.513,00:19:46.218 like having an all or nothing decryption. Email clients should not decrypt my email unless the 00:19:46.218,00:19:51.223 whole um message was encrypted within one single MIME plop, one single element, okay. Yeah, uh 00:19:55.261,00:20:01.167 also we could of course think about other cryptographic countermeasures, um, one thing 00:20:01.167,00:20:06.238 regarding all or nothing encryption, it will break some, it may break some PGP inline 00:20:06.238,00:20:11.143 emails. It will break, definitely emails, some emails uh composed by KMail which 00:20:11.143,00:20:15.314 allows you to encrypt only the attachment and things like that, but it’s a tradeoff between, you 00:20:15.314,00:20:20.086 know, compatibility and security. Okay also we could think about cryptographic 00:20:20.086,00:20:24.990 countermeasures like why is it even possible to use the ciphertext from one email and 00:20:24.990,00:20:30.262 years later, use it in a completely different context and in a completely different email. 00:20:30.262,00:20:34.900 Modern online protocols they would have a binding of the ciphertext to the current 00:20:34.900,00:20:39.905 communication session, right. Um, in email, this still seems hard to do. Okay, regarding 00:20:42.074,00:20:47.079 signatures, uh you may say let’s drop simply support for CSS. I’m on your side, yes. Um, I think 00:20:49.515,00:20:55.588 uh, unfortunately a lot of people want to have fancy formatting and that they’ve, 00:20:55.588,00:21:01.660 which is done by CSS, so so it may not be realistic for many email clients. Um, but email 00:21:01.660,00:21:06.565 client vendors um and and implement this, but what they can at least do is only reply 00:21:06.565,00:21:11.570 with ASCII text or remove CSS styles from replies so they cannot be misused as uh signing 00:21:13.873,00:21:18.878 oracles anymore. Okay, so um, let me come to a conclusion. Um, so crypto is great okay? But 00:21:24.717,00:21:30.523 sometimes super simple bypasses exist. Sometimes we don’t have to break them off and in this 00:21:30.523,00:21:36.695 example the bypass has existed for for decades okay. And the vast majority of these tested 00:21:36.695,00:21:41.967 clients are vulnerable to either being misused as decryption oracles or signing oracles or 00:21:41.967,00:21:47.273 both, um, and PGP and S/MIME there are more or less equally affected, okay, because we do 00:21:47.273,00:21:53.445 not target the underlying cryptography, we target standard email features. So this brings 00:21:53.445,00:22:00.352 me to the final question. Is it even possible to build security on top of email. I think this is 00:22:00.352,00:22:05.357 very very challenging, okay. And this talk is just one of many examples um where things fail. 00:22:08.260,00:22:13.265 Okay so um, we reported um all these issues to affected vendors in uh until February and uh most 00:22:16.068,00:22:22.208 of the decryption oracle are fixed now, uh, the signing issues are not fixed. Anyway we 00:22:22.208,00:22:28.314 are going full disclosure now so if you want to test if your client is still vulnerable, um, 00:22:28.314,00:22:34.620 you can use the test cases on github. Okay thank you guys and enjoy this great conference. 00:22:34.620,00:22:38.324 [Applause]