<<

Efail: Breaking S/MIME and OpenPGP using Exfiltration Channels Damian Poddebniak and Christian Dresen, Münster University of Applied Sciences; Jens Müller, Ruhr University Bochum; Fabian Ising and Sebastian Schinzel, Münster University of Applied Sciences; Simon Friedberger, NXP Semiconductors, Belgium; Juraj Somorovsky and Jörg Schwenk, Ruhr University Bochum ://www.usenix.org/conference/usenixsecurity18/presentation/poddebniak

This paper is included in the Proceedings of the 27th USENIX Security Symposium. August 15–17, 2018 • Baltimore, MD, USA ISBN 978-1-939133-04-5

Open access to the Proceedings of the 27th USENIX Security Symposium is sponsored by USENIX. Efail: Breaking S/MIME and OpenPGP using Exfiltration Channels

Damian Poddebniak1, Christian Dresen1, Jens Muller¨ 2, Fabian Ising1, Sebastian Schinzel1, Simon Friedberger3, Juraj Somorovsky2, and Jorg¨ Schwenk2 1Munster¨ University of Applied Sciences 2Ruhr University Bochum 3NXP Semiconductors, Belgium

Abstract is designed to protect user data in such scenarios. With end-to-end encryption, the email infrastructure becomes OpenPGP and S/MIME are the two prime standards merely a transportation service for opaque email data and for providing end-to-end security for . We de- no compromise – aside from the endpoints of sender or scribe novel attacks built upon a technique we call mal- receiver – should affect the security of an end-to-end en- leability gadgets to reveal the plaintext of encrypted crypted email. emails. We use CBC/CFB gadgets to inject malicious plaintext snippets into encrypted emails. These snippets S/MIME and OpenPGP. The two most prominent stan- abuse existing and standard conforming backchannels to dards offering end-to-end encryption for email, S/MIME exfiltrate the full plaintext after decryption. We describe (Secure / Multipurpose Internet Extensions) and malleability gadgets for emails using HTML, CSS, and OpenPGP (), co-exist for more than X.509 functionality. The attack works for emails even if two decades now. Although the cryptographic secu- they were collected long ago, and it is triggered as soon rity of them was subject to criticism [8–10], little was as the recipient decrypts a single maliciously crafted published about practical attacks. Instead, S/MIME is email from the attacker. commonly used in corporate and government environ- 1 We devise working attacks for both OpenPGP and ments. It benefits from its ability to integrate into PKIs S/MIME encryption, and show that exfiltration channels and that most widely-used email clients support it by exist for 23 of the 35 tested S/MIME email clients and 10 default. OpenPGP often requires the installation of ad- of the 28 tested OpenPGP email clients. While it is ad- ditional and, besides a steady userbase within visable to update the OpenPGP and S/MIME standards to the technical community, is recommended for people in fix these vulnerabilities, some clients had even more se- high-risk environments. In fact, human rights organiza- vere implementation flaws allowing straightforward ex- tions such as Amnesty International [11], EFF [12], or filtration of the plaintext. Reporters without Borders [13] recommend using PGP. We show that this trust is not justified, neither in S/MIME nor in OpenPGP. Based on the complexity of 1 Introduction these two specifications and usage of obsolete crypto- graphic primitives, we introduce two novel attacks. Despite the emergence of many tech- Backchannels and exfiltration channels. One of the nologies, email is still one of the most common methods basic building blocks for our attacks are backchan- to exchange information and data, reaching 269 billion nels. A backchannel is any functionality that inter- per day in 2017 [1]. acts with the network, for example, a method for While transport security between mail servers is useful forcing the email to invoke an external URL. against some attacker scenarios, it does not offer reliable A simple example uses an HTML image tag which forces the email ticity of emails. Reports of pervasive data collection ef- client to download an image from .de. These forts by nation state actors, large-scale breaches of email backchannels are widely known for their privacy im- servers, revealing millions of email messages [2–5], or attackers compromising email accounts to search the 1A comprehensive list of European companies and agencies sup- emails for valuable data [6, 7] underline that transport porting S/MIME is available at https://gist.github.com/ security alone is not sufficient. End-to-end encryption rmoriz/5945400.

USENIX Association 27th USENIX Security Symposium 549 plications as they can leak whether and when the user element, whose URL is not closed with quotes. opened an email and which software and IP he used. Contributions. We make the following contributions: Until now, the fetching of external URLs in email was only considered to be a privacy threat. In this pa- • We introduce the concept of malleability gadgets, per, we abuse backchannels to create plaintext exfiltra- which allow an attacker to inject malicious chosen tion channels that allow sending plaintext directly to the plaintext snippets into the email ciphertext. We de- attacker. We analyze how an attacker can turn backchan- scribe and apply malleability gadgets for the CBC nels in email clients to exfiltration channels, and thus ob- and CFB modes used in email encryption. tain victim plaintext messages. We show the existence of backchannels for nearly every , ranging from • We analyze all major email clients for backchannels classical HTML resources to OCSP requests and Certifi- that can be used for the creation of exfiltration chan- cate Revocation lists. nels. Malleability gadget attacks. Our first attack exploits • OpenPGP’s plaintext compression significantly the construction of obsolete cryptographic primitives, complicates our attack. We describe techniques to while the second abuses the way how some email clients create arbitrary plaintexts from specific changes in handle different MIME parts. An important observation the compressed plaintext using advanced malleabil- for the first attack is that OpenPGP solely uses the Cipher ity gadgets. Feedback Mode (CFB) and S/MIME solely uses the Ci- pher Block Chaining (CBC) mode of operation. Both • We describe practical attacks against major email modes provide malleability of plaintexts. This property clients allowing to exfiltrate decrypted emails di- allows an attacker to reorder, remove or insert ciphertext rectly, without ciphertext modifications. blocks, or to perform meaningful plaintext modifications without knowing the encryption key. More concretely, • We discuss medium and long-term countermeasures he can flip specific bits in the plaintext or even create ar- for email clients and the S/MIME and PGP stan- bitrary plaintext blocks if he knows parts of the plaintext. dards. We use the malleability of CBC and CFB to con- struct so called malleability gadgets that allow us to cre- Responsible disclosure. We disclosed the vulnerabili- ate chosen plaintexts of any length under the assumption ties to all affected email vendors and to national CERTs that the attacker knows one plaintext block. These mal- and our findings were confirmed by these bodies. leability gadgets are then used to inject malicious plain- text snippets within the actual plaintext. An ideal mal- 2 Background leability gadget attack is possible if the attacker knows one complete plaintext block from the ciphertext, which In its simplest , an email is a text message con- is 16 bytes for AES. However, fewer known plaintext forming to the Internet Message Format (IMF) [14]. As bytes may also be sufficient, depending on the exfiltra- the IMF lacks features that are required in the modern tion channel that the attacker aims for. Guessing small Internet, such as the transmission of binary data, it is parts of plaintext is typically feasible since there are hun- augmented with Multipurpose Internet Mail Extension dreds of bytes of static metadata. (MIME) [15] to support transmission of multimedia mes- With this technique, we were able to defeat the en- sages or – in case of OpenPGP and S/MIME – to allow cryption modes used in both S/MIME and PGP. While end-to-end encryption of emails. attacking S/MIME is straightforward, for OpenPGP, we needed to develop more complex exploit techniques upon malleability gadgets because the data is typically 2.1 End-to-end encrypted email compressed before encryption. S/MIME and CMS. The Secure/Multipurpose Inter- Direct exfiltration attacks. Our second attack exploits net Mail Extension (S/MIME) is an extension to MIME how different email clients handle emails containing describing how to send and receive secured MIME multiple MIME parts. We discovered several attacks data [16]. S/MIME focuses on the MIME-related parts of variations that solely exploit the complex interaction of an email and relies on the Cryptographic Message Syn- HTML together with MIME, S/MIME and OpenPGP in tax (CMS) to digitally sign, authenticate, or encrypt ar- email clients. These cases are straightforward to exploit bitrary messages [17]. CMS is a set of binary encoding and do not require any changes of the ciphertext. In the rules and methods to create secured messages. As it is most straightforward example of our attacks, the adver- derived from PKCS#7, the term “PKCS” is found in var- sary prepares a plaintext email structure that contains an ious headers of secured emails.

550 27th USENIX Security Symposium USENIX Association Your temporary : Ohyoo4hu … Leaky window efail inc. Quality research. http://efail.de/images/efail.png

f a i l . d e / i m a g e s / e f a i l . p n g

f a i l . d e / O h y o o 4 h u

Pretty Good Privacy. Phil Zimmerman developed the Pi-1 Pi Leaky blocks Your temporary password: Ohyoo4hu … first version of Pretty Good Privacy (PGP) in 1991 as Pw-1 Pw - Efail GmbH a means to enable political activists to communicate se- curely on BBSs, Usenet groups and the early Internet. f a i l . d e / ? ? ? ? ? ? ? ? O h y o o 4 h u In the late ’90s, the IETF published RFC 2440 describ- ing the OpenPGP format, which has been updated sev- Figure 1: Replacing the URL in the ciphertext blocks eral times. The latest standard is RFC 4880, published (Cw−1,Cw) with (Ci−1,Ci) to exfiltrate sensitive data. in 2007, which describes a variety of methods to encrypt and sign digital data [18]. 3 Towards exfiltration attacks 2.2 Cryptographic basics Modern email clients are able to assemble and render In the email context, both S/MIME and PGP use hybrid various types of content, most notably HTML docu- encryption, in which the sender generates a random ses- ments, and HTML provides methods to fetch resources sion key s that is used to symmetrically encrypt the mes- like images and stylesheets from the Internet. Email sage m into a cipher text c. The session key s is encrypted clients may additionally request other information, for with at least two public keys using a public key encryp- example, to validate the status of a cryptographic certifi- tion scheme. The first encryption of s happens with the cate. We will refer to all these channels as backchan- public key of the sender. Additional are done nels because they can interact with possibly attacker- using all the public keys of the intended receivers. Thus, controlled servers. s will be encrypted under n+1 different public keys for n Backchannels in the email context are well-known to recipients of the email. Throughout this paper, we focus be a privacy issue because they allow detecting if, when on the symmetric encryption. and where a message has been read and may leak further information such as the user’s mail client and operating system. But they are more than that. Encryption modes in OpenPGP and S/MIME. For symmetric encryption of the message m, the standards In the following sections we show that backchannels specify several block ciphers, the most relevant being can be used to exfiltrate the plaintext of an email after it 3DES and AES. As encryption modes, S/MIME uses has been decrypted. The showed methods are directly ap- Cipher Block Chaining (CBC) and OpenPGP uses the plicable to S/MIME. For PGP, further requirements must Cipher Feedback Mode (CFB). During decryption, both be met, which are discussed in Section 5. modes produce intermediate values which are XORed (⊕) with an adjacent ciphertext block to produce the fi- 3.1 Block reordering attack nal plaintext block. For CBC, the decryption of Ci into its respective plaintext block is Pi = decs(Ci)⊕Ci−1. For CBC and CFB allow not only precise modifications of CFB, it is Pi = encs(Ci) ⊕Ci+1. the plaintext, but also to reorder ciphertext blocks. With some limitations, changing the order of the ciphertext Malleability in encryption modes. XOR is a mal- blocks will effectively also reorder the respective plain- leable operation, which means that flipping a single bit text blocks. in one of the two operands of XOR results in a bit flip of Assume an AES-CBC encrypted HTML email con- the final plaintext at the same position. Because XORing taining an HTML image tag at a known ciphertext pair with adjacent ciphertext blocks is the final operation in (Cw−1,Cw). Due to the reordering property, an at- CBC and CFB, precise plaintext manipulations are pos- tacker can replace (Cw−1,Cw) with another ciphertext sible by changing the ciphertext only. pair (Ci−1,Ci). In effect, the respective plaintext Pi will be reflected in the URL path and the resulting HTTP request will exfiltrate sensitive data a passive MitM at- Authenticated encryption Newer encryption schemes tacker can observe (see Figure 1). will detect modification of the ciphertext and do not out- put the plaintext in this case. Typically, this is archived by using Message Codes (MACs) or an 3.2 Malleability gadgets Authenticated Encryption (AE) scheme. However, both S/MIME and PGP predate these developments and use In the previous example, a MitM attacker could exfiltrate no authentication at all (S/MIME) or do not strictly com- those emails that already contained an external HTML mit to the requirements of an AE, which makes them eas- image using block reordering. We now relax this con- ier to misuse (PGP). straint and introduce the concept of malleability gadgets

USENIX Association 27th USENIX Security Symposium 551 CBC mode CFB mode Ci-1 Ci Ci Ci+1 4 Attacking S/MIME

(a) decryption decryption (c) encryption encryption In this section we show that S/MIME is vulnerable to CBC gadget attacks, and demonstrate how exfiltration channels can be injected into S/MIME emails. Pi-1 Pi (known) Pi (known) Pi-1

X Ci Ci X 4.1 S/MIME packet structure (b) decryption decryption (d) encryption encryption Most clients can either sign, encrypt or sign-then-encrypt

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? messages. Sign-then-encrypt is the preferred wrapping random plaintext random plaintext Pc (chosen) Pc (chosen) technique when both confidentiality and authenticity are needed. The body of a signed-then-encrypted email con- Figure 2: Transforming a known plaintext Pi to a chosen sists of two MIME entities, one for signing and one for plaintext Pc in CBC and CFB. encryption. The outermost entity – also specified in the email header – is typically EnvelopedData. The En- velopedData data structure holds the RecipientInfos with that allow to inject arbitrary plaintexts into encrypted multiple encrypted session keys and the EncryptedCon- emails given only a single block of known plaintext. tentInfo. EncryptedContentInfo defines which symmet- ric encryption algorithm was used and finally holds the Definition. Let (Ci−1,Ci) be a pair of two ciphertext ciphertext. Decryption of the ciphertext reveals the in- blocks and Pi the corresponding plaintext block of an ner MIME entity holding the plaintext message and its CBC encrypted ciphertext. We call ((Ci−1,Ci),Pi) a CBC signature. Note that there is no integrity protection. gadget if Pi is known to an attacker. Accordingly, we call ((Ci,Ci+1),Pi) of an CFB encrypted ciphertext a CFB 4.2 Attack description gadget. S/MIME uses the CBC encryption mode to encrypt Using CBC gadgets. Given a CBC gadget (see Fig- data, so the CBC gadget from Figure 2 can be used for S/MIME emails. When decrypted, the ciphertext ure 2 (a)), it is possible to transform Pi into any plaintext P by replacing C with X =C ⊕P ⊕P (see Figure 2 of a signed-then-encrypted email typically starts with c i−1 i−1 i c Content-type: multipart/signed (b)). This comes at a cost as X will be decrypted with an , which unknown key, resulting in uncontrollable and unknown reveals enough known-plaintext bytes to fully utilize AES-based CBC gadgets. Therefore, in the case of random bytes in Pi− . 1 S/MIME, an attacker can use the first two cipher blocks (IV,C0) and modify the IV to turn P0 into any chosen Using CFB gadgets. CFB gadget work similar to CBC plaintext block Pci . gadgets with the difference, that the block after the cho- sen plaintext block becomes a random block (see Fig- Injection of exfiltration channels. A slightly simpli- ure 2 (c, d)). fied version of the attack is shown in Figure 3. The first blocks of a ciphertext whose plaintext we want to exfil- Chosen plaintext and random blocks. A single block trate are shown in Figure 3 (a). We use (IV,C0) to con- of known plaintext is sufficient to inject any amount of struct our CBC gadgets because we know the complete chosen plaintext blocks at any block boundary. How- associated plaintext P0. Figure 3 (b) shows the canonical ever, the concatenation of multiple gadgets produces an CBC gadget as it uses X = IV ⊕ P0 to set all its plaintext alternating sequence of chosen plaintext blocks and ran- bytes to zero. dom blocks. Thus, to create working exfiltration chan- We then modify and append multiple CBC gadgets nels, an attacker must deal with these random blocks in a to prepend a chosen ciphertext to the unknown cipher- way that they are ignored. One can think of several ways text blocks (Figure 3 (c)). As a result, we control the to achieve that. When comments are available within a plaintext in the first and third block, but the second and context, for example via C-style comments /* and */, fourth block contain random data. The first CBC gadget exfiltration channels can easily be constructed by sim- block Pc0 opens an HTML image tag and a meaningless ply commenting out the random blocks. In case no com- attribute named ignore. This attribute is used to consume ments are available, characteristics of the underlying data the random data in the second block such that the random format can be used, for example, that unnamed attributes data is not further interpreted. The third block Pc1 then in HTML are ignored. starts with the closing quote of the ignored attribute and

552 27th USENIX Security Symposium USENIX Association IV C0 C1 C2 C3 X =IV ⊕ P0 C0

decryption decryption decryption decryption decryption (a) (b) Content-type: mu ltipart/signed 0 0 0 0 0 0 0 0

P0 P1 unknown plaintext unknown plaintext

X =IV ⊕ P ⊕ P ⊕ ⊕ C 0 0 c0 C0 X1 =IV P0 Pc1 0 C1 C2 C3

decryption decryption decryption decryption decryption decryption (c)

Pc0 random plaintext Pc1 P1 unknown plaintext unknown plaintext

Figure 3: Detailed description of the attack on S/MIME. The original ciphertext is shown in (a). (b) is the canonical CBC gadget resulting in an all zero plaintext block. (c) is the modified ciphertext that is sent to the victim.

adds the src attribute that contains the domain name from nately, src="http:// has already 12 bytes, leaving which the email client is supposed to load the image. The merely enough room for a 4 byte domain. A workaround fourth plaintext block again contains random data, which is to scatter the exfiltration code into multiple HTML is the first part of the path of the image URL. All subse- elements without breaking its functionality. In case of quent blocks contain unknown plaintexts, which now are the src attribute, an additional element can be used to globally de- email, the plaintext is sent to the HTTP defined in fine the base protocol first.

Pc1 . Emails sent as text/plain pose another diffi- culty. Although there is nothing special about those Meaningless signatures. One could assume that the emails in the context of CBC gadgets, injection of decryption of modified ciphertexts would fail because Content-type: text/html turned out to be dif- of the included in the signed-then- ficult due to restrictions in the MIME headers. An at- encrypted email, but this is not the case, because signa- tacker has to apply further tricks such that header parsing ture in S/MIME can easily be removed from the multi- will not break when random data is introduced into the part/signed mail body [19]. This transforms the signed- header. then-encrypted email into an encrypted message that has no signature. Of course, a cautious user could detect that 5 Attacking OpenPGP this is not an authentic email, but even then, by the time the user detects that, the plaintext would already have Our exfiltration attacks are not only possible in S/MIME, been exfiltrated. Signatures can also not become manda- but also work against OpenPGP. However, there are two tory, because this would hinder communi- additional obstacles: (1) OpenPGP uses compression by cation. Furthermore, an invalid signature typically does default and (2) Modification Detection Codes (MDC) are not prevent the display/rendering of a message in email used for integrity protection. client either. This has historic reasons, as mail gateways could invalidate signatures by changing line-endings in the plaintext, etc. Compression. In the context of malleability gadgets, compression makes exploitation more difficult, because 4.3 Practical exploitation the compressed plaintext is harder to guess. Similar to S/MIME, PGP emails also contain known headers Exfiltration codes must be designed such that they are and plaintext blocks, for example, Content-Type: ignorant to interleaved random blocks. Although this re- multipart/mixed, but after compression is applied, striction can be circumvented by careful design of the the resulting plaintext may vastly differ per mail. exfiltration code – recap the usage of the ignore attribute The difficulty here is to guess a certain amount of – some exfiltration codes may require additional tricks to compressed plaintext bytes in order to fully utilize the work in practice. CFB gadget technique. Not knowing enough compressed For example, HTML’s src attribute, requires the ex- plaintext bytes is hardly a countermeasure, but makes plicit naming of the protocol, e.g. http://. Unfortu- practical exploitation a lot harder.

USENIX Association 27th USENIX Security Symposium 553 We show how the compression structure can be ex- detected due to a mismatch of the SHA-1 hash of the ploited to create exfiltration channels. Interestingly, with message and the attached MDC packet. the compression in place, we can create exfiltration chan- nels even more precisely and remove the random data Generating SE packets. Clients may ignore the stan- blocks from the resulting plaintext. dards recommendation and still generate SE ciphertexts. These messages have no integrity protection and have no Integrity protection. The OpenPGP standard states means of preventing our attacks. Older ciphertexts that that detected modifications to the ciphertext should be were generated before the introduction of the MDC will “treated as a security problem”, but does not define what remain vulnerable. to do in case of security problems. The correct way of handling this would be to drop the message and notify the user. However, if clients try to display whatever is Ignoring the MDC. The MDC is only effective if it left of the message as a “best effort”, exfiltration chan- is checked. This can easily be verified by introducing nels may be triggered. changes to the ciphertext and leaving the MDC as it is. In order to understand how the integrity protection can If the MDC will not match the modified ciphertext and if be disabled and how compression can be defeated, we the client continues processing, the client may be vulner- have to go into more detail of OpenPGP. able.

5.1 OpenPGP packet structure Stripping the MDC. Similar to the previous attempt, the MDC can also be removed, such that the client can In OpenPGP, packets are of the form tag/length/body. not check the MDC at all. This is easily possible by re- The tag denotes the packet type as listed in Table 1. The moving the last 22 bytes from the ciphertext. body contains either another nested packet or arbitrary user data. The size of the body is encoded in the length Downgrade SEIP packets to SE packets. A more field. elaborate method is to disable the integrity protection by changing an SEIP packet to an Symmetrically Encrypted Tag no. Type of PGP packet (SE) packet, which has no integrity protection. This is 8 CD: Compressed Data Packet straightforward, because the packet type is not encrypted 9 SE: Symmetrically Encrypted Packet (see Figure 4). This downgrade attack has been known 11 LD: Literal Data Packet since 2002 [20], but never used in an actual attack. 18 SEIP: Symmetrically Encrypted and Integrity However, there is a caveat: in an SE packet, the last Protected Packet 19 MDC: Modification Detection Code Packet two bytes of the IV are added just after the first block. 60 – 63 Experimental packets (ignored by clients) This was originally used to perform an integrity quick check on the session key. Table 1: PGP packet types used throughout this paper. While the SE type resynchronizes the block bound- aries after encrypting these two additional bytes, the SEIP does not perform this resynchronization. To repair the decryption after changing the SEIP to an SE packet, Message encryption. A message is encrypted in four two bytes must be inserted at the start of the first block steps: (1) the message m is encapsulated in a Literal Data to compensate for the missing bytes. This was also de- (LD) packet. (2) the LD packet is compressed via deflate scribed by Perrin and Magazinius [20, 21]. and encapsulated in a Compressed Data (CD) packet. (3) the Modification Detection Code (MDC) over the CD packet is calculated (SHA-1) and appended to the CD SEIP (Tag 18) || Length packet as an MDC packet. (4) finally, the concatenated CD (Tag 8) || Length

CD and MD packets are encrypted and the ciphertext LD (Tag 11) || Length is encapsulated in an Symmetrically Encrypted and In- Content-type: multipart/mixed; boundary="..." tegrity Protected (SEIP) packet (see Figure 4). ...

MDC (Tag 19) || Length 5.2 Defeating integrity protection 9fbd5d27474c2670d78f71c32ef5404e37c9cd88 The OpenPGP standard mandates that clients should pre- fer the SEIP packet type over the SE packet type, because Figure 4: Nesting of a Symmetrically Encrypted and In- for SEIP packets, modification of the plaintext will be tegrity Protected Data Packet in OpenPGP.

554 27th USENIX Security Symposium USENIX Association Since an attack was published against this integrity change substantially and are difficult to predict for partly protection mechanism [22], its interpretation is discour- unknown plaintexts. For shorter texts, fixed Huffman aged [18], and the two bytes are ignored. They depict the trees are used. They are statically defined in [23] and not beginning of the first real plaintext block and the SE and located in the data. In the following sections, we assume SEIP packet types treat them differently. fixed Huffman trees to outline the attack.

5.3 Defeating deflate 5.3.1 Creating a CFB gadget OpenPGP utilizes the deflate algorithm [23] to compress The first encrypted block seems most promising, because LD packets before encrypting them. It is based on LZ77 it consists of OpenPGP packet metadata and compres- (specifically LZSS) and Huffman Coding. Although the sion headers. exact details are not important for this paper, it is im- By exploiting backreferences in the compression algo- portant to note that a single message may be partitioned, rithm we are able to use only 11 bytes long malleability such that different modes of compression can be used for gadgets. These backreferences allow us to reference and different segments of the message. concatenate arbitrary blocks of data and thus create ex- filtration channels more precisely. Therefore, instead of Modes of compression. The standard defines three trying to work around the compression, we use it to pre- modes of compression: uncompressed, compressed with cisely inject our exfiltration codes in compressed form. fixed Huffman trees, and compressed with dynamic Huffman trees. It is specified by a header prepended to 5.3.2 Exfiltrating compressed plaintexts each segment. A single OpenPGP CD packet can contain multiple compressed or uncompressed segments.2 Assume we are in possession of an OpenPGP SEIP packet which decrypts to a compressed plaintext. We Backreferences. Typically, a full message is wrapped know one decrypted block which allows us to construct a inside a single compressed segment. Then, the algorithm malleability gadget and thus arbitrary number of chosen applies a search for text fragment repetitions of certain plaintexts. Our goal is to construct a ciphertext which de- length within the boundaries of a sliding window. If a crypts to a compressed packet. Its decompression leads repetition is found, it is replaced with a shorter pointer to to an exfiltration of the target plaintext. its previous occurrence. A simplified attack is shown in Figure 5 and can be For example, the text How much wood could performed as follows. Using our malleability gadget we a woodchuck chuck is shortened to How much first create three ciphertext block pairs (Ci,Ci+1) which wood could a <-13, 4>chuck <-6, 5>. In decrypt into useful text fragments (Pc0,Pc1,Pc2). The reality, the deflate algorithm encodes backreferences as first text fragment represents an OpenPGP packet struc- small bit strings to achieve a higher compression level. ture which encodes a CD packet (which is encoded as The backreference strings are inserted into a Huffman 0xaf in OpenPGP) containing a LD packet (encoded as tree that is placed before the compressed text. During the 0xa3). The latter two text fragments contain an exfiltra- decompression process, the algorithm uses the Huffman tion channel, for example, ios: (1) with OpenPGP-encrypted password-reset emails from Facebook and (2) by simulating the standard en- Table 3: Start sequences of approx. 500,000 emails from cryption process with GnuPG with the Enron dataset the enron email data set sorted by frequency. 2635 differ- containing 500,000 real world emails. ent beginnings were observed in total with the 500 most Our approach was as follows: in case of the Facebook frequent sequences accounting for approx. 41% of the emails, we build an email generator to generate 100,000 mails. password reset emails. This emails were generated based on a comparison of real password reset emails and were indistinguishable from the real emails. We then used emails with exactly these starting bytes, we can break GnuPG in its default configuration to encrypt all emails. approximately 39% of all Facebook mails. In the next step, we removed the encryption layer to ob- The measurements on the Enron dataset had a higher tain the compressed plaintext only. We then grouped variance, with approx. 7% of the most often found start- each email by its beginning 11 bytes (see Table 2). The ing bytes, and 2% of the second most often found starting most often observed starting sequence made up 31% of bytes. The results are shown in Table 3. This means that all facebook emails. The second most frequent starting with two emails approx. 9% of Enron, or “real world”, bytes made up 8%. This means, that by sending two emails can be exfiltrated. 3This is not a hard requirement and other exploitation techniques Although 500 guesses are very few in a cryptographic may improve on this. sense, the requirement to open 500 emails makes our

556 27th USENIX Security Symposium USENIX Association attacks hardly practical. However, this constraint can be relaxed, because MIME allows to send multiple MIME parts per email. Using the multipart/mixed content-type, multiple guesses can be embedded into a single email. We measured how many parts are allowed per email and found that up to 500 parts are realistic in popular email clients. To conclude: we expect that exfil- tration is possible for 40% of all emails by sending only a single email. If, however, exfiltration does not work on the first try, an attacker can send additional emails, also over multiple days to stay stealthy.

6 Attacking MIME parsers

We found that various email clients do not isolate multi- ple MIME parts of an email but display them in the same HTML document. This allows an attacker to build trivial decryption oracles which work for S/MIME, PGP and presumably for other encryption schemes. We call the attack Direct Exfiltration. To perform this attack, an attacker simply wraps the encrypted message into MIME parts containing an Figure 6: Malicious email structure and missing context HTML based backchannel and sends the message to the boundaries force the client to decrypt the ciphertext and victim. One possible variant of this attack using the leak the plaintext using the element. HTML tag is shown in Figure 6 (a). If the email client first decrypts the encrypted part and then other clients our attacks require user interaction. For ex- puts all body parts into one HTML document as shown ample, in Thunderbird and we can completely in Figure 6 (b), the HTML rendering engine leaks the redress the UI with CSS and trick the user into submitting decrypted message to the attacker-controlled web server the plaintext with an HTML form if he clicks somewhere within the URL path of a GET request as shown in Fig- into the message. Note that thanks to the MIME struc- ure 6 (c). ture the attacker can include several ciphertexts into one Because the plaintext message is leaked after decryp- email and exfiltrate their plaintexts at once. For Thun- tion, this attack is independent of the email encryption derbird this security issue is present since v0.1 (2003). scheme and may be used even against authenticated en- cryption schemes. Direct exfiltration channels arise from faulty isolation between secure and insecure message 7 Exfiltration channels in email clients parts. Although it seems that these are solely imple- mentation bugs, their mitigation can be challenging. For Backchannels in email clients are known as privacy risks, example, if the email decryption and email presentation but there is no comprehensive overview yet. We per- steps are provided by different instances, the email client formed an analysis of existing backchannels by system- is not aware of the encrypted email message structure. atically testing 48 clients and give the complete results This scenario is quite common when email security gate- in Appendix B. Note that 13 of the tested clients do ways are used. either not support encryption at all or we could not get Out of 48 tested mail clients 17 had missing isola- the OpenPGP or S/MIME modules to work and there- tion which would allow leaking secret messages to an fore could not test whether backchannels can be used for attacker-controlled web server in case a mail gateway exfiltration. This distinction is important because some would decrypt and simply replace the encrypted part with email clients behave differently for encrypted and unen- the plaintext. Even worse, in five email clients, the con- crypted messages. For example, HTML content that can cept shown in Figure 6 can be exploited directly: Ap- be used to load external images in unencrypted mails is ple Mail (macOS), Mail App (iOS), Thunderbird (Win- usually not interpreted for deprecated PGP/INLINE mes- dows, macOS, ), Postbox (Windows) and Mail- sages. On the other hand, for three clients we were Mate (macOS). The first two clients by default load ex- able to bypass remote content blocking simply by en- ternal images without asking and therefore leak the plain- crypting the HTML email containing a simple tag.

USENIX Association 27th USENIX Security Symposium 557 PGP 7.1 Web content in email clients OS Client S/MIME -MDC +MDC SE √ HTML. The most prominent form of HTML content Outlook 2007 ∠ ∠ ∠ √ √ √ Outlook 2010 ∠ are images. Of the tested 48 email clients, 13 load ex- Outlook 2013 ⊥ √ √ √ ternal images by default. For 10 of them, this can be Windows Outlook 2016 ⊥ √ √ √ turned off whereas three clients have no option to block Win. 10 Mail ∠ ––– remote content. All other clients block external images Win. Live Mail ∠ ––– The Bat! ⊥ √ √ √ by default or explicitly ask the user before downloading. Postbox ∠ ∠ ∠ ∠ We analyzed all HTML elements that could poten- √ √ eM Client ∠ ∠ tially bypass the blocking filter and trigger a backchan- IBM ––– ∠ nel using a comprehensive list of HTML4, HTML5 Thunderbird ∠ ∠ ∠ ∠ √ √ √ and non-standard HTML elements that allow including

Linux ∠ √ √ √ Trojita´ ∠ URIs. For each element-attribute combination, links √ √ √ KMail ⊥ were built using a variety of well-known4 and unofficial5 Claws √ √ √ √ √ √ √ √ URI schemes based on the assumption that http:// ∠ ∠ ∠ ∠ links may be blacklisted by a mail client while others √ √ √ MailMate ∠ might be allowed. We added specific link/meta tags in macOS ∠ ∠ ∠ ∠ the HTML header. In addition, we tested against the Mail App ∠ ––– 6 √ √ √ iOS Canary Mail– vectors from the Tester project and the 7 K-9 Mail– √ √ √ Cure53 HTTPLeaks repository. This extensive list of √ √ R2Mail2 ∠ ∠ test-cases allowed us to bypass external content blocking √ √ Android MailDroid ∠ ∠ in 22 email clients. Nine ∠ ––– United Internet– √ √ √ √ √ √ .org– Cascading Style Sheets (CSS). Most mail clients ProtonMail– √ √ √ Mailfence– √ √ √ allow CSS declarations to be included in HTML ∠ ––– emails. Based on the CSS2 and CSS3 standards √ √ – ∠ we assembled an extensive list of properties that √ Horde IMP ⊥ ∠ ∠ √ √ √ allow included URIs, like background-image:

Webapp AfterLogic– Rainloop– √ √ √ url("http://efail.de"). These allowed by- – √ √ √ passing remote content blocking on 11 clients. √ ∠ Exfiltration (no user interaction) No exfiltration channel ⊥ Exfiltration (with user interaction)– Encryption not supported JavaScript. We used well-known Cross Site Scripting Table 4: Exfiltration channels for various email clients test vectors8,9 and placed them in various header fields for S/MIME, PGP SEIP with stripped MDC (-MDC), like Subject: as well as in the mail body. We identi- PGP SEIP with wrong MDC (+MDC), and PGP SE fied five mail clients which are prone to JavaScript exe- packets. cution, allowing the construction of particularly flexible backchannels.

Table 4 shows the 35 remaining clients. An attacker 7.2 S/MIME specific backchannels can exploit 23 S/MIME email clients out of which eight require either a MitM attacker or user interaction like OCSP requests. Mail clients can use the Online Cer- clicking on a link or explicitly allowing external images. tificate Status Protocol (OCSP) to check the validity of 17 S/MIME clients allow off-path exfiltration channels X.509 certificates that are included in S/MIME signa- with no user interaction. tures. OCSP works as follows: the client decrypts the email, parses the certificate and obtains the URL of the From the 35 email clients, 28 support OpenPGP and OCSP-responder. The client then sends the serial num- 10 allow off-path exfiltration channels with no user ber of the certificate via HTTP POST to the responder interaction. Five clients allow SEIP ciphertexts with stripped MDC and ignore wrong MDCs if they exist. 4https://www.w3.org/wiki/UriSchemes Six clients support SE ciphertexts. Three clients – which 5https://github.com/Munter/schemes show OpenPGP messages as plain text only – are secure 6https://www.emailprivacytester.com/ 7https://github.com/cure53/HTTPLeaks against automated backchannels, but are still vulnerable 8https://www.owasp.org/index.php/XSS_Filter_ to backchannels that require more complex user interac- Evasion_Cheat_Sheet tion. 9http://html5sec.org

558 27th USENIX Security Symposium USENIX Association and obtains a data structure with status information about clients performed a request to the given URL, therefore the certificate. the issue is only relevant to a MitM attacker. Using this channel for data exfiltration requires re- placing the URL ciphertext blocks with other cipher- text blocks. In typical scenarios this is complicated by 7.4 External attachments two factors: One, the OCSP-responder’s URL is part of a larger base64 encoded data structure. Therefore, The message/external-body content type allows an attacker must be careful not to destroy the base64- references to external resources as MIME parts instead of decoding process by carefully selecting or masking the directly including within the mail. This is a known tech- plaintext. Two, if a valid certificate chain is used, nique to bypass virus scanners running on a mail gate- the OCSP-responder’s URL is cryptographically signed way. However, there are various proprietary variants of which makes this backchannel unusable as long as the this header, for which one email client automatically per- signature is properly checked. Eleven clients performed formed a DNS request for the external attachment’s host- OCSP requests for valid certificates from a trusted CA. name. It is noteworthy that this was done automatically, the email did not have to be explicitly opened. CRL requests. Similar to OCSP, Certificate Revoca- tion Lists (CRLs) are used to obtain recent status infor- 7.5 Email security gateways mation about a certificate. Unlike OCSP, a CRL is pe- riodically requested and contains a list of multiple serial Email security gateways are typically used in large en- of revoked certificates. Requesting the list in- terprises to secure the outgoing communication with volves an HTTP request to the server holding the CRL S/MIME or OpenPGP. This ensures that employees do and the CRL backchannel is very similar to the OCSP not have to install any extensions or generate keys, and backchannel. Ten clients performed CRL requests for that their emails are automatically encrypted and de- valid certificates from a trusted CA, one client even con- crypted. nected to an untrusted, attacker-controlled web server. Our attacks are applicable to email security gateways as well. In fact, preventing the showed attacks in these Intermediate certificates. S/MIME is built around the scenarios could be even more challenging, especially for concept of hierarchical trust and requires following a cer- the MIME-related issues. The reason is that a gateway tificate chain back to a trusted root. If the certificate is only used to decrypt the incoming emails and has no is incomplete and intermediate certificates are missing, knowledge of the email processing clients. the chain can not be verified. To remedy this, a CA We were not able to systematically analyze security may augment certificates with an URL to the next link gateways as they are not easily accessible. Nevertheless, in the chain. A client can query this URL to obtain we had a chance to test two appliances. The configu- the missing certificates. These requests for intermedi- ration of the first one was insecure and we could find a ate certificates can be used as a backchannel. Like the direct exfiltration exploit. The second gateway was con- backchannels via OCSP and CRL requests, this is made figured correctly and we were not able to find any direct difficult by the base64 encoding. However, the signature exploits in the limited time we had for the evaluation. can only be verified after the intermediate certificate was obtained. This makes exploitation of this channel much easier. Seven clients requested intermediate certificates 8 Mitigations from an attacker-controlled LDAP and/or web server. Backchannels are critical, because they provide a way 7.3 OpenPGP specific backchannels to instantly obtain the plaintext of an email. Reliably blocking all backchannels, including those not based on An email client receiving a PGP-signed message may HTML, would prevent all the attacks as presented. How- try to automatically download the corresponding public ever, it does not fix the underlying vulnerability in the key. There are various protocols to achieve this, for ex- S/MIME and OpenPGP standards. In a broader sce- ample DANE [24], HKP [25] or LDAP [26] [27]. We nario, an attacker could also inject binary attachments observed one client trying to obtain the public key for or modify already attached ones, such that exfiltration is a given key ID. This can potentially be abused by mal- done later even if no email client is involved. Therefore, leability gadgets to leak four bytes of plaintext. We also blocking network requests is only a short-term solution. applied 33 PGP-related email headers that refer to public In the following section we present long-term mitigations keys (e.g. X-PGP-Key: URI), but none of the tested which require updating the standards.

USENIX Association 27th USENIX Security Symposium 559 8.1 Countering direct exfiltration attacks attack. AuthenticatedData Same origin policy for email. The complexity of Although CMS defines an HTML, CSS and MIME makes it possible to mix en- type [29], S/MIME’s current specification does not. crypted and plaintext contents. If an exfiltration chan- There were efforts to introduce authenticated encryption nel is available, this can lead to direct leaks of decrypted in OpenPGP which is, however, expired [30]. plaintexts, independently of whether the ciphertext is au- By introducing these algorithms, the standard would thenticated or not. In web scenarios, a typical protec- need to address backwards compatibility attacks and tion against these kinds of attacks is the same origin pol- handling of streaming-based decryption. icy [28]. Similar protection mechanisms could be ap- plied in email scenarios as well. These should enforce that email parts with different security properties are not Solving backwards compatibility problems. In a combined. backwards compatibility attack an attacker takes a secure However, this mitigation is hard to enforce in every authenticated ciphertext (e.g., AES-GCM) and forces the scenario. For example, email gateways typically used receiver to use a weak encryption method (e.g., AES- in companies process encrypted emails and forward the CBC) [31]. To prevent these attacks, usage of different plain data to email clients used by the employees. Email keys for different cryptographic primitives has to be en- clients have no knowledge whether the original message forced. For example, the decrypted key can be used as an was encrypted or not. In such scenarios this countermea- input into a key derivation function KDF together with an sure must be combined with different techniques. An ef- algorithm identifier. This would enforce different keys fective mitigation for an email gateway would be to dis- for different algorithms: play only the first email body part and convert further body parts into attachments. kAES-CBC = KDF(k,“AES-CBC”) (1) k = KDF(k,“AES-GCM”) (2) 8.2 Countering malleability gadget attacks AES-GCM The S/MIME standard does not provide any effective se- Although an email client could use S/MIME’s capabili- curity measures countering our attacks. OpenPGP pro- ties list to promote more secure ciphers in every signa- vides Message Modification Codes and we could observe ture, an attacker can still forward emails she obtained in several OpenPGP implementations that were not vulner- the past. The email client may then (a) process the old able to our attacks because they dropped ciphertexts with email and stay susceptible to exfiltration attacks or (2) do invalid MDCs. Unfortunately, the OpenPGP standard is not process the email and break interoperability. not clear about handling MDC failures. The standard only vaguely states that any failures in the MDC check “MUST be treated as a security problem” and “SHOULD Streaming-based decryption. OpenPGP uses stream- be reported to the user” [18] but lacks a definition on how ing, i.e. it passes on plaintext parts during decryption if to deal with security problems. Furthermore, the stan- the ciphertext is large. This feature collides with our re- dard still supports SE packets which offer no integrity quest for AE ciphers because most AE ciphers also sup- protection. From this perspective, the security vulnera- port streaming. In the event that the ciphertext was mod- bilities observed in GnuPG and are standard- ified, it will pass on already decrypted plaintext, along conforming, as GnuPG returns an error code and prints with an error code at the end. If these plaintext parts are out a specific error message. Our experiments showed interpreted, exfiltration channels may arise despite using that different clients deal differently with MDC failures an AE cipher. We think it is safe to turn off streaming in (see Table 4). the email context because the size of email ciphertexts is In the long-term, updating the S/MIME and OpenPGP limited and can be handled by modern . Other- standards is inevitable to meet modern cryptographic wise, if the ciphertext size is a concern, the email should best practices and introduce authenticated encryption al- be split into chunks which are encrypted and authenti- gorithms. cated so that no streaming is needed. A cryptographic approach to solve this problem would be to use a mode Authenticated encryption (AE). Our attack would be of operation which does not allow for decrypting the ci- prevented if the email client detects changes in the ci- phertext before its authenticity is validated. For example, phertext during decryption and prevents it from being AES-SIV could be used [32]. Note that AES-SIV works displayed. On a first thought, making an AE block ci- in two phases and thus it does not offer such performance pher such as AES-GCM the default, would prevent the as e.g., AES-GCM.

560 27th USENIX Security Symposium USENIX Association 9 Related work signatures.

In 2000 Katz and Schneier described a chosen-ciphertext attack [33] that blinds an uncompressed ciphertext, Acknowledgements which they send in a spoofed email to the victim. They The authors thank Marcus Brinkmann and Kai Michaelis then hope that the victim replies to the email with the for insightful discussions about GnuPG, Lennart Grahl, blinded ciphertext, that they can then unblind. This at- Yves-Noel Weweler and Marc Dangschat for their early tack requires a cooperating victim and does not work work around X.509 backchannels, Hanno Bock¨ for his against compressed plaintexts. comments on AES-SIV and our attack in general, Tobias In 2001 Davis described “surreptitious forwarding” Kappert for countless remarks regarding the deflate algo- attacks and their applicability to S/MIME, PKCS#7, rithm, and our anonymous reviewers for many insightful MOSS, PEM, PGP, and XML [34] in which an attacker comments. can re-sign or re-encrypt the original email and forward Simon Friedberger was supported by the Commis- it onto a third person. sion of the European Communities through the Horizon In 2002 Perrin presented a downgrade attack, which 2020 program under project number 643161 (ECRYPT- removes the integrity protection turning a SEIP into a SE NET). Juraj Somorovsky was supported through the data packet [20]. In 2015, Magazinius showed that this Horizon 2020 program under project number 700542 downgrade attack is applicable in practice [21]. (FutureTrust). Christian Dresen and Jens Muller¨ have In 2005 Mister and Zuccherato described an adaptive- been supported by the research training group ‘Human chosen-ciphertext attack [22] exploiting OpenPGP’s in- 15 Centered System Security’ sponsored by the state of tegrity quick check. The attacker need 2 queries to de- North-Rhine Westfalia. crypt two plaintext bytes per block. The attack requires a high number of queries, which makes the attack unprac- tical for email encryption. References Strenzke [19] improved one of Davis’ attacks and noted that an attacker can strip a signature and re-sign the [1] The Radicati Group, Inc., “Email statistics report, encrypted email with his private key. He sends the email 2017 - 2021,” Feb. 2017. to the victim who hopefully responds with an email in- [2] Wikileaks, “Vp contender sarah palin hacked,” cluding the decrypted ciphertext. Sept. 2008. https://wikileaks.org/ Many attacks abuse CBC malleability property to cre- wiki/VP_contender_Sarah_Palin_ ate chosen-ciphertext attacks [35–38]. Practical attacks hacked. have been shown against IPSec [39, 40], SSH [41, 42], TLS [43–46], or XML Encryption [47]. Overall, the at- [3] Wikileaks, “Sony email archive,” Apr. 2015. tacker uses the server as an oracle. This is not possible https://wikileaks.org/sony/ in typical OpenPGP and S/MIME scenarios, since users emails/. are unlikely to open many emails without getting sus- picious. Some of these attacks exploit that with CBC [4] Wikileaks, “Hillary clinton email archive,” it is also possible to encrypt arbitrary plaintext blocks Mar. 2016. https://wikileaks.org/ or bytes [38, 40, 47]. For example, Rizzo and Duong clinton-emails/. described how to turn a decryption oracle into an en- cryption oracle. They used their CBC-R technique to [5] Wikileaks, “The podesta emails,” Mar. 2016. compute correct headers and issue malicious JSF view https://wikileaks.org/podesta- states [38]. emails/. In 2005, Fruwirth, the author of the Linux Unified Key [6] K. Thomas, F. Li, A. Zand, J. Barrett, J. Ranieri, Setup (luks), wrote a compendium of attacks and inse- L. Invernizzi, Y. Markov, O. Comanescu, V. Er- cure properties of CBC [48] in the hard disk encryption anti, A. Moscicki, D. Margolis, V. Paxson, and context. Later in 2013, Lell presented a practical exploit E. Bursztein, eds., Data breaches, , or mal- for CBC malleability against a Ubuntu 12.04 installation ware? Understanding the risks of stolen creden- that is encrypted using luks [49] with CBC. An attack tials, 2017. very similar to Lell’s was described in 2016 in the Own- cloud server side encryption module [50]. [7] E. Bursztein, B. Benko, D. Margolis, T. Pietraszek, In 2017 Cure53 analyzed the security of Enig- A. Archer, A. Aquino, A. Pitsillidis, and S. Sav- mail [51]. The report shows that surreptitious forwarding age, “Handcrafted fraud and extortion: Manual ac- is still possible and that it is possible to spoof OpenPGP count hijacking in the wild,” in IMC ’14 Proceed-

USENIX Association 27th USENIX Security Symposium 561 ings of the 2014 Conference on Internet Measure- [20] “Openpgp security analysis,” Sept. 2002. https: ment Conference, (1600 Amphitheatre Parkway), //www.ietf.org/mail-archive/web/ pp. 347–358, 2014. openpgp/current/msg02909.html.

[8] M. Green, “What’s the matter with [21] J. Magazinius, “Openpgp seip downgrade at- pgp?,” Aug. 2014. https://blog. tack,” Oct. 2015. http://www.metzdowd. cryptographyengineering.com/2014/ com/pipermail/cryptography/2015- 08/13/whats-matter-with-pgp/. October/026685.html.

[9] M. Marlinspike, “Gpg and me,” Feb. 2015. [22] S. Mister and R. Zuccherato, “An attack on cfb https://moxie.org/blog/gpg-and- mode encryption as used by openpgp.” Cryptology me/. ePrint Archive, Report 2005/033, 2005. https: //eprint.iacr.org/2005/033. [10] F. Valsorda, “I’m throwing in the towel on PGP, and I work in security,” Dec. 2016. https: [23] P. Deutsch, “Deflate compressed data format speci- //arstechnica.com/information- fication version 1.3,” May 1996. RFC1951. technology/2016/12/op-ed-im- giving-up-on-pgp/. [24] P. Wouters, “Dns-based authentication of named entities (dane) bindings for openpgp,” August 2016. [11] Amnesty International, “Verschlusselte¨ Kom- RFC7929. munikation via PGP oder S/MIME.” https: //www.amnesty.de/keepitsecret. Ac- [25] D. Shaw, “The OpenPGP HTTP Keyserver Pro- cessed: 2018-02-22. tocol (HKP),” Internet-Draft draft-shaw-openpgp- hkp-00, Internet Engineering Task Force, Mar. [12] Electronic Frontier Foundation, “How to: Use PGP 2003. Work in Progress. for Windows.” https://ssd.eff.org/en/ module/how-use-pgp-windows. Accessed: [26] G. Good, “The ldap data interchange format (ldif) - 2018-02-22. technical specification,” June 2000. RFC2849.

[13] United Nations Educational Scientific and Cul- [27] “How to setup an openldap-based pgp key- tural Organization and Reporters Without Borders, server.” https://wiki.gnupg.org/ Safety Guide for Journalists – a Handbook for Re- LDAPKeyserver. porters in High-Risk Environments. CreateSpace Independent Publishing Platform, 2016. [28] “Same origin policy,” Jan. 2010. https: //www.w3.org/Security/wiki/Same_ [14] P. Resnick, “Internet message format,” October Origin_Policy. 2008. RFC5322. [29] R. Housley, “Cryptographic message syntax [15] N. Freed and N. Borenstein, “Multipurpose internet (cms) authenticated-enveloped-data content type,” mail extensions () part one: Format of internet November 2007. RFC5083. message bodies,” November 1996. RFC2045. [30] “Modernizing the openpgp message format,” [16] B. Ramsdell and S. Turner, “Secure/multipurpose 2015. https://tools.ietf.org/html/ internet mail extensions (s/mime) version 3.2 mes- draft-ford-openpgp-format-00. sage specification,” January 2010. RFC5751. [31] T. Jager, K. G. Paterson, and J. Somorovsky, “One [17] R. Housley, “Cryptographic message syntax Bad Apple: Backwards Compatibility Attacks on (cms),” September 2009. RFC5652. State-of-the-Art ,” in Network and Distributed System Security Symposium (NDSS), [18] J. Callas, L. Donnerhacke, H. Finney, D. Shaw, and February 2013. R. Thayer, “Openpgp message format,” November 2007. RFC4880. [32] D. Harkins, “Synthetic initialization vector (siv) au- thenticated encryption using the advanced encryp- [19] F. Strenzke, “Improved message takeover at- tion standard (aes),” October 2008. RFC5297. tacks against s/mime,” Feb. 2016. https: //cryptosource.de/posts/smime_mta_ [33] J. Katz and B. Schneier, “A chosen ciphertext at- improved_en.html. tack against several e-mail encryption protocols,” in

562 27th USENIX Security Symposium USENIX Association Proceedings of the 9th Conference on USENIX Se- ’16, (New York, NY, USA), pp. 1480–1491, ACM, curity Symposium - Volume 9, SSYM’00, (Berke- 2016. ley, CA, USA), pp. 18–18, USENIX Association, 2000. [43] N. J. A. Fardan and K. G. Paterson, “Lucky thir- teen: Breaking the tls and dtls record protocols,” [34] D. Davis, “Defective sign & encrypt in s/mime, in 2013 IEEE Symposium on Security and Privacy, pkcs#7, moss, pem, pgp, and xml,” in Proceedings pp. 526–540, May 2013. of the General Track: 2001 USENIX Annual Tech- nical Conference, (Berkeley, CA, USA), pp. 65–78, [44] M. R. Albrecht and K. G. Paterson, “Lucky mi- USENIX Association, 2001. croseconds: A timing attack on amazon’s s2n im- plementation of tls,” in Advances in Cryptology – [35] S. Vaudenay, “Security flaws induced by cbc EUROCRYPT 2016 (M. Fischlin and J.-S. Coron, padding - applications to ssl, ipsec, wtls ..,” in eds.), (Berlin, Heidelberg), pp. 622–643, Springer EUROCRYPT (L. R. Knudsen, ed.), vol. 2332 of Berlin Heidelberg, 2016. Lecture Notes in Science, pp. 534–546, Springer, 2002. [45] G. Irazoqui, M. S. Inci, T. Eisenbarth, and B. Sunar, “Lucky 13 strikes back,” in Proceedings of the 10th [36] K. Paterson and A. Yau, “Padding Oracle Attacks ACM Symposium on Information, Computer and on the ISO CBC Mode Encryption Standard,” in Communications Security, ASIA CCS ’15, (New Topics in Cryptology – CT-RSA 2004, vol. 2964 York, NY, USA), pp. 85–96, ACM, 2015. of Lecture Notes in Computer Science, Springer Berlin / Heidelberg, Feb. 2004. [46] J. Somorovsky, “Systematic fuzzing and testing Proceedings of the 2016 ACM [37] C. J. Mitchell, “Error oracle attacks on cbc mode: of tls libraries,” in SIGSAC Conference on Computer and Communi- Is there a future for cbc mode encryption?,” in In- cations Security formation Security (J. Zhou, J. Lopez, R. H. Deng, , CCS ’16, (New York, NY, USA), and F. Bao, eds.), (Berlin, Heidelberg), pp. 244– pp. 1492–1504, ACM, 2016. 258, Springer Berlin Heidelberg, 2005. [47] T. Jager and J. Somorovsky, “How To Break XML [38] J. Rizzo and T. Duong, “Practical padding ora- Encryption,” in The 18th ACM Conference on Com- cle attacks,” in Proceedings of the 4th USENIX puter and Communications Security (CCS), Oct. conference on Offensive technologies, WOOT’10, 2011. (Berkeley, CA, USA), pp. 1–8, USENIX Associa- [48] C. Fruhwirth, “New methods in hard disk en- tion, 2010. cryption,” July 2005. http://clemens. [39] J. P. Degabriele and K. G. Paterson, “Attacking endorphin.org/nmihde/nmihde-A4- the IPsec standards in encryption-only configura- ds.pdf. tions,” in IEEE Symposium on Security and Pri- vacy, pp. 335–349, IEEE Computer Society, 2007. [49] J. Lell, “Practical malleability attack against cbc- encrypted luks partitions,” 2013. [40] J. P. Degabriele and K. G. Paterson, “On the (in)security of IPsec in MAC-then-encrypt con- [50]H.B ock,¨ “Pwncloud – bad crypto in the figurations,” in ACM Conference on Computer encryption module,” Apr. 2016. and Communications Security (E. Al-Shaer, A. D. https://blog.hboeck.de/archives/ Keromytis, and V. Shmatikov, eds.), pp. 493–504, 880-Pwncloud-bad-crypto-in-the- ACM, 2010. Owncloud-encryption-module.html.

[41] M. R. Albrecht, K. G. Paterson, and G. J. Wat- [51] “Pentest-report enigmail,” Dec. 2017. son, “Plaintext recovery attacks against ssh,” in https://enigmail.net/download/ Proceedings of the 2009 30th IEEE Symposium on other/Enigmail%20Pentest%20Report% Security and Privacy, SP ’09, (Washington, DC, 20by%20Cure53%20-%20Excerpt.pdf. USA), pp. 16–26, IEEE Computer Society, 2009. [42] M. R. Albrecht, J. P. Degabriele, T. B. Hansen, and A Unsuccessful backchannel tests K. G. Paterson, “A surfeit of ssh cipher suites,” in Proceedings of the 2016 ACM SIGSAC Conference We pursued further tests which were not successful but on Computer and Communications Security, CCS are documented here for the sake of completeness.

USENIX Association 27th USENIX Security Symposium 563 Spam datasets. We checked whether spammers may B Backchannel analysis already be aware of bypasses for remote content block- ing in email clients and analyzed two large spam This section presents the table summarizing our results datasets10,11 containing over ten millions of spam emails on backchannels in email clients. altogether ranging from 1997 to 2018. However, we found that spammers do not use or are not aware of by- passes for content blocking as they only included well- known technique to trace if an email is actually read.

Generic email headers. There are various standard- ized and proprietary email headers12 which allow to in- clude URIs. Furthermore, we used various public email datasets to compile a list of 9,400 mail headers which contain URLs. We tested those headers against all email clients, but none triggered with the exception of external attachments mentioned in Section 7.4

Anti-spoofing headers. We included email headers to fight spam (SPF, DKIM), however the triggered DNS re- quests at the MTA level, not when mail was opened in the MUA. It is however noteworthy that two email clients performed a DNS lookups for the hostname part of the sender at the time the mail was opened. although this is a privacy issue, we cannot use it to for exfiltration because the DNS request was no longer trig- gered for From: header within the encrypted part of the message.

Message disposition notification. We identified seven standardized and proprietary email headers which re- quest a confirmation mail attesting that the message has been read. Two mail clients automatically send confir- mation emails which has a privacy impact but cannot be used as an exfiltration channel because the mail was not triggered if the message disposition notification header was within the encrypted part. All other clients do not support the feature or explicitly ask the user before send- ing a message disposition notifications.

File preview. Some email clients try to generate a pre- view for attached files. We prepared specially-crafted PDF, SVG, vCard and vCalendar files which contain hy- perlinks, trigger a connection or execute JavaScript when opened. However in the previewed version none of these actions was taken for any of the tested clients.

10http://untroubled.org/spam/ 11http://artinvoice.hu/spams/ 12https://www.iana.org/assignments/message- headers/message-headers.

564 27th USENIX Security Symposium USENIX Association Support Backchannels S/MIME PGP Email HTML/CSS/JS PKI

Windows Outlook 2007 (12.0.4518.1014) native GPG4win H15 P1 I1 I2 I3 Outlook 2010 (14.0.7190.5000) native GPG4win P1 I2 I3 Outlook 2013 (15.0.4989.1000) native GPG4win I2 I3 Outlook 2016 (16.0.4266.1001) native GPG4Win I2 I3 Win. 8 Mail (17.4.9600.16384) n/a n/a + H1 H6 Win. 10 Mail (17.8730.21865.0) native n/a + Win. Live Mail (16.4.3528.0331) native n/a H17 I1 I2 The Bat! (8.2.0) native GnuPG E1 Postbox (5.0.20) native Enigmail P3 I2 eM Client (7.1.31849.0) native native E3 J3 I1 I2 IBM Notes (9.0.1) native n/a H13 H16 P2 J1 (7.2.8) n/a n/a * Mail (4.72.572) n/a PMPGP E1 H14 P2 P4

Linux Thunderbird (52.5.2) native Enigmail H2 I2 Evolution (3.22.6) native GnuPG H3 Trojita´ (0.7-278) native GnuPG H3 I3 KMail (5.2.3) native GnuPG I3 Claws (3.14.1) plugin GPG plugin I3 Mutt (1.7.2) native GnuPG I3

macOS Apple Mail (11.2) native GPGTools E2 + I1 I2 I3 MailMate (1.10) native GPGTools H3 I1 I2 I3 Airmail (3.5.3) plugin GPG-PGP + H10 H11 H14

iOS Mail App (11.2.2) native n/a + I1 Canary Mail (1.17) n/a native E4 + Outlook (2.56.0) n/a n/a * Android K-9 Mail (5.403) n/a OpenKeychain R2Mail2 (2.30) native native H10 J2 MailDroid (4.81) Flipdog Flipdog H4 H5 H14 H15 J2 Nine (4.1.3a) native n/a K2 H4 H5 H14 H15 J1

Webmail GMX, Web.de, ... n/a + K1 C7 C8 C9 Mailbox.org n/a Mailvelope K1 C9 n/a native ProtonMail n/a OpenPGP.js H3 H4 H12 H14 H15 C1 Mailfence native OpenPGP.js H8 C5 C12 C15 I3 GMail native n/a + Outlook.com native n/a + iCloud Mail n/a n/a + Yahoo Mail n/a n/a C5 C11 FastMail n/a n/a + Mail.Ru n/a n/a * Zoho Mail n/a n/a H9 C12 P1

Webapp Roundcube (1.3.4) native Enigma H7 C3 AfterLogic (7.7.9) plugin OpenPGP.js H4 C2 C10 C13 C14 C16 Rainloop (1.11.3) n/a OpenPGP.js C4 C13 C14 Mailpile (1.0.0rc2) n/a GnuPG #

Groupware Exchange OWA (15.1.1034.32) native n/a I1 I2 GroupWise (14.2.2) native n/a H9 C2 C5 C11 C12 Horde (5.2.22/IMP 6.2.21) native GnuPG I4 Backchannel to arbitrary URI Backchannel to fixed URI

Table 5: Backchannels for various email clients. (Legend on next page.)

USENIX Association 27th USENIX Security Symposium 565 Legend + Remote images are loaded by default but this can be deactivated * Remote images are loaded by default and it cannot be deactivated # Remote images are loaded through prefetching in modern browsers PKI requests I1 Request for intermediate S/MIME certificate are performed to an attacker-controlled URI I2 OCSP requests to a fixed CA URL are performed for valid/trusted S/MIME signed emails I3 CRL requests to a fixed CA URL are performed for valid/trusted S/MIME signed emails I4 HKP requests to keyserver are performed to retrieve public keys for PGP signed emails Encrypted emails K1 Remote images are loaded automatically if the mail is PGP/MIME encrypted K2 Remote images are loaded automatically if the mail is S/MIME encrypted HTML attributes (bypasses for remote content blocking) H1 H2 H3 H4 H5