Mimesis Aegis: A Mimicry Privacy Shield A System’s Approach to Data Privacy on Public Cloud

Billy Lau, Simon Chung, Chengyu Song, Yeongjin Jang, Wenke Lee, and Alexandra Boldyreva College of Computing, Georgia Institute of Technology, Atlanta, GA 30332

{billy, pchung, csong84, yeongjin.jang, wenke, sasha.boldyreva}@cc.gatech.edu

Abstract transforming them to be fed to the underlying app, and reverse-transform the data from the app before display- We are now in the intersection of the cloud computing ing the plaintext data to the user. This technique allows age and mobile revolution. Increasing number of users M-Aegis to transparently integrate with most cloud ser- are storing and exchanging their data from their mo- vices without hindering usability and without the need bile devices to and through public cloud services such for reverse-engineering. We implemented a prototype of as those provided by Google, Facebook, Apple, and Mi- M-Aegis on Android and show that it can support a num- crosoft. Although users may want to have faith in cloud ber of popular cloud services, e.g. Gmail, Google Hang- providers to provide good security protection, the recent out, Facebook, WhatsApp, and Viber. story is the latest reminder of the real- Our performance evaluation and user study show that ity: the confidentiality of any data in public clouds can users incur minimal overhead in adopting M-Aegis on be violated, and consequently, while the providers may Android: imperceptible encryption/decryption latency not be “doing evil”, we can not and should not trust them and very low and adjustable false positive rate when with data confidentiality. searching over encrypted data. To better protect the privacy of user data stored on the cloud, in this paper we propose a privacy-preserving sys- 1 Introduction tem called Mimesis Aegis (M-Aegis) that is suitable for mobile platform. M-Aegis presents a novel approach to As a result of the growth in cloud computing and mobile user data privacy by providing good isolation and pre- technology, today we witness a continuously increasing serving user experience through the creation of a concep- number of users who utilize mobile devices [2] to interact tual layer called Layer 7.5 (L-7.5), which is interposed with public cloud services (PCS) (e.g. Gmail, Outlook, between the application (Layer 7) and the user (Layer 8). and WhatsApp) as an essential part of their daily lives. This approach allows M-Aegis to implement a true end- Generally, while the user’s connectivity to the Internet is to-end encryption of user data with three goals in mind: improved, the problem of preserving data privacy in the 1) plaintext data is never visible to the (untrusted) client interaction with PCS is yet unsolved. In fact, news about app used to access the cloud service or any intermediary the US government’s alleged surveillance programs re- entities in the communication; 2) the original user expe- minds everybody about a very unsatisfactory status quo: rience with target apps is preserved; and 3) our technique while PCS are essentially part-of-life, the default way is generalizable to a large number of apps and resilient to of utilizing them exposes the users to privacy breaches, app updates, hence our solution is scalable. We argue because it implicitly requires the users to trust the PCS that while existing solutions may achieve a combination providers with the confidentiality of their data, and thus of these goals, none can achieve all three, and thus M- their privacy; but such trust truly is unjustified, if not Aegis presents a clear advantage from the point of view misplaced. Incidents that demonstrate the breach of this of three entities in a security ecosystem: the user, the trust are easy to come by: 1) PCS providers are bounded system, and the developer. by law to share their users’ data with surveillance agen- In order to preserve the exact application workflow cies [12], 2) it is the business model of the PCS providers and look-and-feel, M-Aegis utilizes L-7.5’s unique lay- to go through their users’ data and share it with third par- ering hierarchy to form a coating on top of existing ap- ties [10, 19, 22, 40], 3) operator errors [34] can result in plication GUIs to both intercept user plaintext before unintended data access, and 4) data servers can be com-

1 promised by attackers [47]. bile device users simply do not favor using mobile To alter this undesirable status quo, solutions should browsers [28] to access PCS. Therefore, we rule out be built based on an updated trust model of everyday conventional browser-extension/plugin-based solu- communication that better reflects the reality of threats tions. mentioned earlier. In particular, new solutions must first 2. For a solution to be adoptable, it must preserve user assume PCS providers to be untrusted. This implies that experience. We posit that users will not accept solu- all other entities that are controlled by the PCS providers, tions that require them to switch between different including apps that users installed to engage with the apps to perform their daily tasks. Therefore, sim- PCS, must also be assumed untrusted. ply porting solutions like PGP onto mobile platform Although there are a plethora of apps available today would not work, because besides forcing users to that comes in various combinations of look-and-feel and use a separate and custom app, and it is impossible features, we observed that for a large class of these apps to recreate the richness and unique user experience that provides text communication services (e.g. email or of all existing email apps offered by various PCS private/group messaging categories), users can still enjoy providers today. In the context of mobile devices, the same quality of service1 without needing to reveal PCS nowadays are competing for market share not the true content of their data to the PCS providers. PCS only by offering more reliable infrastructure to fa- providers are essentially message routers and can func- cilitate user communication, but also by offering a tion normally without needing to know the content of the better user experience [14, 57]. Ultimately, users messages being delivered, analogous to postman deliver- will choose apps that they feel most comfortable ing letters without needing to learn the actual content of with. To reduce interference with the user’s interac- the letters. tion with the app of their choice, security solutions Hence, in theory, applying end-to-end encryption must be retrofittable to existing apps. Solutions that (E2EE) without assuming trust in the PCS providers repackage/rewrite existing apps have this criteria. seems to solve the problem. However, in practice, the 3. For a solution to be sustainable, it must be easy to direct application of E2EE solutions onto the mobile maintain and scalable: the solution must be suffi- device environment is more challenging than originally ciently general-purpose, requiring minimal efforts thought. A good solution must present clear advantages to support new apps and withstand app updates. to the entire mobile security ecosystem, in particular ac- In the past, email was one of the very few means counting for these factors: the users’ ease-of-use, hence of communication and protecting it is relatively acceptability and adoptability; the developers’ efforts to straightforward because email protocols (e.g. POP maintain support, and the feasibility and deployability of and IMAP) are well defined and therefore custom solution on the mobile system. From this analysis, we privacy-preserving apps can be built to serve this formulate three key challenges that must be addressed need. However, with the plethora of PCS that are coherently: becoming indispensable in a user’s everyday life today, a good solution should also be able to in- 1. For a solution to be secure, it must be properly tegrate security features to apps without requiring isolated from untrusted entities. It is obvious the reverse engineering of the app logic and/or net- that E2EE cannot protect data confidentiality if the work protocols, which are largely undocumented plaintext or even the encryption key can be com- and possibly proprietary (e.g. ). promised by architectures that risk exposing these Mimesis Aegis (M-Aegis) values. Traditional solutions like PGP [13] and In this paper, we introduce , newer solutions like Gibberbot [5], TextSecure [11], a privacy-preserving system that “mimics” the look and and SafeSlinger [41] provide good isolation prop- feel of existing apps to preserve user experience and erty, but forces user to use custom apps, which workflow on mobile devices, without changing the un- can cause usability problems (refer to (2)). Solu- derlying OS or modifying/repackacing existing apps. M- tions that repackage/rewrite existing apps to intro- Aegis achieves the design goals by operating at a con- Layer 7.5 (L-7.5) duce additional security checks [65, 27] do not have ceptual layer we call that is positioned this property (further discussed in Sect. 2.3). So- above the existing application layer (OSI Layer 7 [8]), lutions in the form of browser plugins/extensions and interacts directly with the user (popularly labeled as also do not have this property (further discussed in Layer 8 [16, 4]). Sect. 2.2), and they generally do not fit into the mo- From a system’s perspective, L-7.5 is a transparent bile security landscape because besides the fact that window in an isolated process that interposes itself be- mobile browsers do not support extensions [7], mo- tween Layer 7 and 8. The interconnectivity between these layers is achieved using the accessibility frame- 1the apps’ functionality and user experience are preserved work, which is available as an essential feature on mod-

2 ern operating systems (OS). Note that utilizing accessi- bility features for unorthodox purposes have been pro- posed by prior work [55, 48] that achieve different goals. L-7.5 extracts GUI information about the app below it through the OS’s user interface automation/accessibility (UIA) library. Using these information, M-Aegis is then able to “proxy” user input by rendering its own GUI (with a different color as visual cue) and subsequently handle those input (e.g. to process plaintext data or in- tercept user button click). Using the same UIA library, L-7.5 can also programmatically interact with various UI components on the app below on behalf of the user (re- fer to Sect. 3.3.2 for more details). Since major software vendors today have pledged their commitment towards continuous support and enhancement of accessibility in- terface for developers [9, 17, 6, 1], our UIA-based tech- nique is applicable and sustainable on all major plat- Figure 1: This diagram shows how M-Aegis uses L-7.5 forms. to transparently reverse-transform the message “dead- From a security design’s perspective, M-Aegis pro- beef” into “Hi there”, and also allow user to enter their vides two privacy guarantees during a user’s interaction plaintext message “Hello world” into M-Aegis’s text with a target app: 1) all input from the user first goes to box. To the user, the GUI looks exactly the same as the L-7.5 (and be optionally processed) before being passed original app. When the user decides to send it out, the to the app. This means that confidential data and user “Hello world” message will be transformed and relayed intent can be fully captured; and 2) all output from the to the underlying app. app must go through L-7.5 (and be optionally processed) before being displayed to the user. From a developer’s perspective, accessing and inter- M-Aegis creates an L-7.5 to protect user’s data privacy acting with a target app’s UI components at L-7.5 is very when interacting with Gmail. similar to that of manipulating the DOM tree of a web For users who would like to protect their email com- browser using Javascript. However, one major difference munications, they will also be concerned if encryption is that DOM tree manipulation only works for browsers, will affect the ability to search, because it is very impor- but UIA works for all apps on a platform. To track GUIs tant to improve user productivity [62]. For this purpose, on an original app, M-Aegis relies on resource id names we incorporated an encryption scheme into M-Aegis that available through UIA. Therefore, M-Aegis is resilient allows search over encrypted content without any server- to updates that change the look and feel of the app (e.g. side modification. Of course, efficient search functional- GUI position or color). It only breaks if the resource id ity does not permit the strongest security. Nevertheless, names are changed, which, through empirical evidences, our solution provides the appropriate and well-defined we conclude are very rare occasions. Even if such a case level of security. happens, there is very minimal effort required to redis- As a proof of concept, we implemented a prototype cover the resource id names and remap it to the logic of M-Aegis on Android that protects user data when inter- M-Aegis. From our experience so far, our solution does facing with text-based communication apps. M-Aegis not require developer attention across a few minor app supports email apps like Gmail and messenger apps like updates. Google Hangout, WhatsApp, and Facebook Chat. It pro- From a user’s perspective, M-Aegis is visible as an tects data privacy by implementing a true E2EE without always-on-top button. When it is turned on, users will trusting target apps by operating at L-7.5 while preserv- perceive that they are interacting with the original app ing user experience and original workflow. We also im- in plaintext mode; the only difference being the graph- plemented a version of M-Aegis on desktop to support ical user interfaces (GUIs) on the original app will ap- platform compatibility and demonstrate the generality of pear in a different color to indicate that protection is acti- our approach. Our initial performance evaluation and vated. This means that subtle features that contribute to- user study show that users incur minimal overhead in wards the entire user experience such as spellcheck and adopting M- Aegis on Android: imperceptible encryp- in-app navigation are also preserved. However, despite tion/decryption latency and very low and adjustable false user perception, the original app actually never receives positive rate when searching over encrypted data. the plaintext. Figure 1 gives a high level idea of how In summary, these are the major contributions of this

3 work: user data. These solutions provide good isolation prop- erty from untrusted entities. However, since they are de- • We introduced the concept of Layer 7.5 (L-7.5), a signed as standalone custom apps, they do not preserve conceptual layer that directly interacts with users user experience, requiring users to adapt to new work- on top of existing apps. This is a novel system’s flow on a custom app. Besides that, these solutions are approach that provides seemingly contrasting fea- not retrofittable to existing apps on the mobile platform. tures: transparent interaction with a target app and Like M-Aegis, Cryptons [36] introduced a similarly strong isolation from the target app. strong notion of isolation through its custom abstrac- • We designed and built Mimesis Aegis based on the tions. However, Cryptons assumes a completely differ- concept of L-7.5, a system that preserves user’s pri- ent threat model in that it assumes PCS to be trusted and vacy while interacting with PCS by protecting data thus requires both server and client (app) modifications, confidentiality. Essential functionalities of existing of which our work does not. Essentially, Cryptons fo- apps, especially search (even over encrypted data), cuses on a problem that is different from M-Aegis. For is also supported without any server-side modifica- example, Cryptons definitely could not protect a user’s tion. communication using existing messaging apps while as- • We implemented two prototypes of Mimesis Aegis, suming the provider to be untrusted. We also argue that one on Android and the other on Windows, with it is non-trivial to modify Cryptons to achieve the three support for various popular online services, namely, design goals we mentioned in Sect 1. Gmail, Facebook Messenger, Google Hangout, WhatsApp, and Viber. • We designed and conducted a user study that 2.2 Browser Plugin/Extention Solutions demonstrated the acceptability of our solution. Other solutions that focus on protecting user pri- The rest of the paper is structured as follows. Section vacy include Cryptocat [3], Scramble! [22] and Trust- 2 distinguishes our work from related work. Section 3 Split’s [40], NOYB (None of Your Business) [46], discusses the threat model of our work and presents the and SafeButton [53]. Some of these assume different design of M-Aegis. Section 4 presents the implementa- threat models, and achieve different goals. For exam- tion of M-Aegis and the challenges we face during the ple, NOYB protects user’s Facebook profile data while process. Section 5 presents performance evaluations and SafeButton tries to keep the user’s browsing history pri- user study of the acceptability of M-Aegis on Android. vate. Most of these solutions try to be transparently in- Section 6 discusses limitations of our work and answers tegrated into user workflow. However, since these so- some questions that readers may have about our system. lutions are mostly based on browser extension/plugins, Section 7 discusses future work and concludes our work. they are not applicable to the mobile platform, besides The Appendix formally studies a new searchable encryp- having questionable data isolation models. tion scheme: it defines the security notion, describes the Additionally, Cryptocat and TrustSplit require new construction and proves the scheme’s security. and/or independent service providers to support their functionalities. However, M-Aegis works with the exist- 2 Related Work ing service providers without assuming trust or requiring modification to the servers. Since M-Aegis is designed to achieve the three design goals described earlier while seamlessly integrating end- 2.3 Repackaging/Rewriting Solutions to-end encryption into user’s communication, we discuss how well existing works achieve some of these goals and There is a category of work that repackages/rewrites an how they differ from our work. We also highlight the app’s binary to introduce security references, such as work that we consider as orthogonal to our solution. We Aurasium [65], Dr. Android [49], and others [27]. Our argue that as far as we know, there are no existing work solution is similar to these approaches in that we can that achieves all the three necessary design goals. retrofit our solutions to existing apps and still preserve user experience, but is different in that M-Aegis’ cov- 2.1 Standalone Solutions erage is not limited to apps that do not contain native code. Also, repackaging-based approaches suffer from There are many standalone solutions that aim to protect the problem that it will break app updates. In some cases, user’s data confidentiality. Solutions like PGP [13] (in- the security of such solutions can be circumvented be- cluding S/MIME [37]), Gibberbot [5], TextSecure [11], cause the isolation model is unclear, i.e. the untrusted SafeSlinger [41], and FlyByNight [54] provides secure code resides in the same address space as the reference messaging and/or file transfer through the encryption of monitor (e.g. Aurasium).

4 2.4 Orthogonal Work 3.2 Threat Model

Although our work focuses on user interaction on mo- 3.2.1 In-Scope Threats bile platform with cloud providers, we assume a very different threat model than those that focus on more ro- We begin with the scope of threats that M-Aegis is de- bust permission model infrastructure and those that focus signed to protect against. In general, there are three par- on controlling/tracking information flow, such as Taint- ties that pose threats to the confidentiality of users’ data Droid [38] and Airbag [64]. These solutions requires exposed to public cloud through mobile devices. There- changes to the underlying app, framework or the OS, but fore, we assume these parties to be untrusted in our threat M-Aegis does not. model: ACG [56] uses user input as permission granting in- tent to allow apps to access user owned resources. Al- • Public cloud service (PCS) providers. Sensitive though we made the same assumptions as ACG to cap- data stored in the public cloud can be compromised ture authentic user input, ACG is designed for a different in several ways: 1) the PCS providers are com- threat model and security goal than ours. Further, ACG pelled by the law [18] to provide access to user’s requires a modified kernel but M-Aegis does not. sensitive data to law enforcers [12]; 2) the business Persona [21] presents a completely isolated and new model of the PCS providers provides strong incen- online social network that provides certain privacy and tive for them to share/sell the data with third par- security guarantees to the users. While related, it differs ties [10, 19, 22, 40]; 3) PCS administrators who from the goal of M-Aegis. have access to the sensitive data may also com- Frientegrity [43] and Gyrus [48] focus on different as- promise the data, either intentionally (e.g., Edward pects of integrity protection of the user’s data. Snowden) [12] or not [34]; and 4) vulnerabilities of [35] is well known for its capability to hide a user’s the PCS can be exploited by attackers to exfiltrate IP address while browsing the Internet. However, it fo- sensitive data [47]. cuses on anonymity guarantees while M-Aegis focuses • Client-side apps. Since client-side apps are devel- on data confidentiality guarantees. oped by the PCS providers to allow user to access their services, it follows that these apps are consid- Off-the-record messaging (OTR) [30] is a secure com- ered untrusted too. munication protocol that provides perfect forward se- • Middle boxes between the PCS and the client-side crecy and malleable encryption. While OTR can be im- app. Finally, sensitive data can also be compro- plemented on M-Aegis using the same design architec- mised when it is transferred between the PCS and ture to provide these extra properties, it is currently not the client-side app. Incorrect protocol may allow the focus of our work. attackers to eavesdrop on plaintext data or perform man-in-the-middle attacks [39]. 3 System Design M-Aegis addresses the above threats through isolation by first creating L-7.5 of which it would handle and apply 3.1 Design Goals end-to-end encryption (E2EE) on user private data. We consider the following components as our trusted com- In this section, we formally reiterate the design goals that puting base (TCB): the hardware, the operating system our system wants to achieve. We posit that a good solu- (OS) and the framework that controls and mediates ac- tion must: cess to hardware. In the absence of physical input de- vices (e.g. mouse and keyboard) on mobile devices, we 1. offer good security by applying strong isolation additionally trust the soft keyboard to not leak what user from untrusted entities (defined in Sect. 3.2). have typed using the soft keyboard to the untrusted apps. 2. preserve user experience by allowing user a trans- We rely on the TCB to correctly handle I/O for M-Aegis, parent interaction with existing apps. and to provide the proper isolation between M-Aegis and 3. be easy to maintain and scale by devising a suffi- the untrusted components. ciently general-purpose approach. Additionally, we also assume that all the components of M-Aegis, including L-7.5 that it creates, are trusted. Above all, these goals must be satisfied within the The user is also considered trustworthy under our threat unique set of constraints found in the mobile platform, model in his intent. This means that he is trusted to turn including user prefence, adoptability and deployability on M-Aegis when he wants to protect the privacy of his factors. data during his interaction with the PCS.

5 3.2.2 Out of Scope Threats a natural way to handle user interaction, thus preserv- ing user experience without the need to reverse-engineer Our threat model does not consider the following types of the logic of TCAs or the network protocols used by the attacks. First, M-Aegis only guarantees the confidential- TCAs to communicate with their respective cloud service ity of the user’s data, but not its availability. Therefore, backends, fulfilling the third design goal. attacks that deny access to the data (denial-of-service) There are basically three cases of user interactions either at the server or the client are beyond the scope to handle. The first case considers interactions that do of this work. Second, any attacks against our TCB are not involve data confidentiality (e.g. deleting or rela- orthogonal to this work. Such attacks include, but not beling email). Such input do not require extra process- limited to malicious hardware [52], attacks against the ing/transformation and can be directly delivered to the hardware [63], the OS [50], the platform [61] and privi- underlying TCA. Mimic-GUIs for display such as that lege escalation attacks (e.g. unauthorized rooting of de- on the left in Fig. 2 are examples for this case. Such vice). Third, M-Aegis is designed to prevent any di- click-through behavior is a natural property of transpar- rect flow of information from authorized user to afore- ent windows, and helps M-Aegis maintain the fluency in mentioned untrusted entities. Hence, leakage through all user interaction. side-channels [60] are beyond the scope of this work. The second case considers interactions that involve Since the user is assumed to be trustworthy under our data confidentiality (e.g. entering message or searching threat model to use M-Aegis correctly, M-Aegis does not encrypted email). Such input requires extra processing protect user against social engineering based attacks. For (e.g. encryption and encoding operations). For such example, phishing attacks to trick users into either turn- cases, M-Aegis places opaque GUIs that “mimics” the ing off M-Aegis and/or entering sensitive information GUIs on the TCA, which are purposely painted in dif- into unprotected UI are beyond the scope of our paper. ferent colors for two reasons: (a) as a placeholder for The other limitations of M-Aegis, which are not secu- user input so that it does not leak to the TCA, and (b) rity threats, are discussed in Sect. 6.2 for user’s visual feedback. Mimic-GUIs for the subject and content as seen in Fig. 3 are examples for this case. 3.3 M-Aegis Architecture Since L-7.5 is always on top, this provides the guarantee that user input always goes to the mimic-GUIs instead of M-Aegis is architected to fulfill all of the three design those of the TCA’s. goals mentioned in Sect. 3.1. Providing strong isolation guarantees is the first one. To achieve this, M-Aegis is The third case considers interactions with control designed to execute in a separate process although it re- GUIs (e.g. clicking on send buttons). Such input re- sides on the same operating system (OS) as the target quires user action to be “buffered” while the input in the client app (TCA). Besides memory isolation, the filesys- second case is being processed before being relayed to tem of M-Aegis is also shielded from other apps by the the actual control GUI. For such cases, M-Aegis creates OS’ app sandbox protection. semi-transparent mimic-GUIs that register themselves to Note that our architecture is flexible in that should absorb/handle user clicks/taps. Again, these mimic GUIs greater degree of isolation be desirable, a virtual machine are painted with a different color to provide visual cue to based setup can be adopted to provide even stronger se- the user. Examples of these include the purple search curity guarantees. However, we do not consider such de- button in the left figure in Fig. 2 and the purple send but- sign at this time as it is currently unsuitable for mobile ton in Fig. 3. Note that our concept of intercepting user platform, and the adoption of such technology is beyond input is similar to that of ACG’s [56] in capturing user the scope of our paper. In the following, we describe the intent, but our application of user intent differs. main components that make up M-Aegis. 3.3.2 UIA Manager (UIAM) 3.3.1 Layer 7.5 (L-7.5) To be fully functional, there are certain capabilities that M-Aegis creates a novel and conceptual layer called M-Aegis requires but are not available to normal apps. Layer 7.5 (L-7.5) to interpose itself between the user First, although M-Aegis itself is confined within the OS’ and the TCA. This allows M-Aegis to implement a true app sandbox, it must be able to figure out which TCA the end-to-end encryption (E2EE) without ever exposing the user is currently interacting with. This is important so plaintext data to the TCA, which is considered untrusted, that the specific logic to handle the TCA can be properly while maintaining the TCA’s original functionalities and invoked. Additionally, this is important to help M-Aegis user experience, fulfilling the second design goal. L-7.5 clean up the screen when the TCA is terminated. Second, is built by creating a transparent window that is always- M-Aegis requires information about the GUI layout for on-top. This technique is advantageous in that it provides the TCA it is currently handling. This allows M-Aegis to

6 Figure 2: The figure on the left illustrates how user perceives the Gmail preview page when M-Aegis is turned on. The figure on the right illustrates the same scenario but with M-Aegis turned off. Note that the search button is painted with a different color on M-Aegis is turned on. properly render mimic GUIs on L-7.5 to intercept user 3.3.3 Per-TCA Logic I/O. Third, although isolated from the TCA, M-Aegis must be able to communicate with the TCA to maintain M-Aegis can be extended to support many TCAs. For functionality and ensure user experience is not disrupted. each TCA of interest, we build a per-TCA logic as an For example, for user input, it must be able to relay user extension module. Basically, the per-TCA logic is re- clicks to the TCA, and eventually send encrypted data sponsible to render the specific mimic-GUIs according to the TCA, and click on TCA’s button on behalf of the to information it queries from the UIAM. Therefore, the user; for output on screen, it must be able to grab the ci- per-TCA logic is responsible for handling direct user in- phertext so that we can decrypt it and then render it on put. Specifically, it decides whether the user input will L-7.5. be directly passed to the TCA or be encrypted and en- coded before doing so. This ensures that the TCA never M-Aegis extracts certain features from the underly- obtain the plaintext data while user interaction is still in ing OS’s accessibility framework, which are exposed plaintext mode. The per-TCA logic also intercepts but- to developers in the form of User Interface Accessibil- ton clicks so that it can then instruct UIAM to emulate ity/Automation (UIA) library. We are then not only able the user’s action on the button on the underlying TCA. to know which TCA is currently executing, but we can Besides that, the per-TCA logic also decides which en- also query the GUI tree of the TCA to get detailed in- cryption and encoding scheme to use according to the formation about how the page is being laid out (e.g. lo- type of TCA it is handling. For example, encryption and cation, size, type, and resource-id of the GUIs). More encoding schemes for handling email apps would differ importantly, we are able to get the information about the from that of messenger apps. content of these GUI items.

Exploiting UIA is advantageous to our design as com- 3.3.4 Cryptographic Module pared to other methods of grabbing information from the screen, e.g. OCR. Besides having perfect content accu- M-Aegis’ cryptographic module is responsible for pro- racy, our technique is not limited by screen size. For viding encryption/decryption and cryptographic hash ca- example, even though the screen size may prevent full pabilities to support our searchable encryption scheme text to be displayed, the UIAM is still able to grab the (described in detail in the Appendix) to the per-TCA text in its entirety through the UIA libraries, allowing us logic so that M-Aegis can transform/obfuscate messages to comfortably apply decryption to the ciphertext. through E2EE operations. Besides standard crypto- graphic primitives, this module also includes a search- We thus wrap around all these capabilities and advan- able encryption scheme to support search over encrypted tages to build a crucial component of M-Aegis called the email that works without server modification. Since the UIA manager (UIAM). discussion of any encryption scheme is not complete

7 without encryption keys, key manager is also a part of this module. Key Manager. M-Aegis has a key manager per TCA that manages key policies that can be specific to each TCA according to user preference. The key manager supports a range of schemes, including simple password- based key derivation functions to derive symmetric keys (that we assume to be shared out of band), which we currently implement as default, to more sophisticated PKI-based scheme for users who prefer stronger secu- rity guarantees and do not mind the additional key set-up and exchange overheads. However, the discussion about the best key management/distribution policy is beyond the scope of this paper. Searchable Encryption Scheme (EDESE). There are numerous encryption schemes that support keyword Figure 3: User still interacts with Gmail app to compose search [45, 59, 44, 31, 33, 29, 51]. These schemes ex- email, with M-Aegis’ mimic GUIs painted with different hibit different tradeoffs between security, functionality colors on L-7.5. and efficiency, but all of them require modifications on the server side. Schemes that make use of inverted in- dex [33] are not suitable, as updates to inverted index keywords used in any email thread is estimated to be cannot be practically deployed in our scenario. d = 106, the number of bits set to 1 for one keyword Since we cannot assume server cooperation (con- is r = 10. Plugging in these values into the formula for −rd/B r sistent with our threat model in Sect. 3.2), we de- false positive calculation [44], i.e. (1 − e ) , we cap signed a new searchable encryption scheme called easily- the probability of a false positive δ to 0.0003. deployable efficiently-searchable symmetric encryption We formally study the EDESE primitive in the Ap- scheme (EDESE). EDESE is an adoptation of a scheme pendix. In Appendix A.2, we define EDESE and propose proposed by Bellare et al. [24], with modifications simi- a security definition for EDESE schemes. We also dis- lar to that of Goh’s scheme [44] that is retrofittable to a cuss why the existing security notions are not suitable. non-modifying server scenario. Our definition considers an attacker who can obtain ex- We incorporated EDESE for email applications with amples of encrypted documents of its choice and the re- the following construct. The idea for the construction sults of queries of keywords of its choice. Given such an is simple: we encrypt the document with a standard en- adversary, an EDESE scheme secure under our definition cryption scheme and append MACs of unique keywords should hide all partial information about the messages in the document. To prevent leaking the number of except for the message length and the number of com- unique keywords we add as many “dummy” keywords mon keywords between any set of messages. Leaking as needed. the latter is unavoidable given that for the search func- In order to achieve higher storage and search effi- tion to be transparent to encryption, the output of a query ciency, we utilized a Bloom filter (BF) to represent the has to be a part a ciphertext. But everything else, e.g., EDESE-index. Basically, a BF is a data structure that the number of unique keywords in a message, positions allows for efficient set-inclusion tests. However, such of the keywords, is hidden. set-inclusion tests based on BFs are currently not sup- We provide the details of our construction in Appendix ported by existing email providers, which only support A.3. Next, in Appendix A.4, we prove that our construc- string-based searches. Therefore, we devised a solution tion is secure under the standard notions of security for that encodes the positions of on-bits in a BF as Unicode encryption and MACs. We also discuss the specific in- strings. stantiations of encryption and MAC schemes that we use. Since the underlying data structure that is used to sup- The encoding scheme that we use is further described in port EDESE is a BF, search operations are susceptible to Sect. 4.4. false positives matches. However, this does not pose a real problem to users, because the false positive rate is 3.4 User Workflow extremely low and is completely adjustable. Our current implementation follows these parameters: the length of To better illustrate how the different components in M- keyword (in bits) is estimated to be k = 128, the size of Aegis fits together, we describe an example workflow in- the BF array is B = 224, the maximum number of unique volved when a user composes and sends an email using

8 stock Gmail app on Android with M-Aegis turned on: 1) When the user launches the Gmail app, the UIAM notifies the correct per-TCA logic of the event. The per-TCA logic will then initialize itself to handle Gmail workflow. 2) As soon as Gmail is launched, the per-TCA logic will try to detect which state is Gmail app in (e.g. pre- view, reading, or composing email). This allows M- Aegis to properly create mirror-GUIs on L-7.5 to handle user interaction. For example, when a user is on the com- pose page, the per-TCA logic will mimic the GUIs of the subject and content fields (as seen in Fig. 3). The user then interacts directly with these mimic-GUIs in plain- text mode without extra effort. Thus, his workflow is not affected. Note that essential but subtle features like spell- check is still preserved, as this is an innate feature of Figure 4: Password prompt when user sends encrypted mobile device’s soft keyboard. Additionally, the “send” mail for a new conversation. button is also mimicked to capture user intent. 3) As the user finishes composing his email, he clicks on the mimicked “send” button on L-7.5 once, as how We then deployed our prototype on two Android he would normally do. Since L-7.5 receives the user in- phones from separate manufacturers, i.e. Samsung put and not the underlying Gmail app, the per-TCA logic Galaxy Nexus, and LG Nexus 4, targetting several ver- is able to capture this event and proceed to process the sions of Android, from Android 4.2.2 (API level 17) to subject and the content. the latest one: Android 4.4.2 (API level 19). The de- ployment is done on stock devices and OS, i.e. with- 4) The per-TCA logic selects the appropriate key to out modifying the OS or Android framework, or rooting, be used based on the recipient list and the predetermined other than simple app installation. This demonstrates the key policy for Gmail. If a key cannot be found for this ease of deployment and distribution of our solution. We conversation, M-Aegis prompts the user (see Fig. 4) for a have also implemented an M-Aegis prototype on Win- password to derive a new key. After obtaining the associ- dows 7 to demonstrate interoperability and generality of ated key for this conversation, M-Aegis will then encrypt approach, but we do not discuss the details here as it is these inputs and encode it back to text such that it can be not the focus of this paper. consumed by Gmail. As an interface to the user, we create a button that is 5) The per-TCA logic then requests the UIAM to fill in always on top even if other apps are launched. This al- the corresponding GUIs on Gmail with the transformed lows us to create a non-bypassable direct channel of com- text. After they are filled, the UIAM is asked to click the munication with the user besides providing visual cue of actual “send” button on behalf of the user. This provides whether M-Aegis is turned on or off. a transparent experience to the user. For app support, we use Gmail as example of email From this workflow, it should therefore be evident that apps and Facebook Messenger as example of messenger from the user’s perspective, the workflow of using Gmail apps. We argue that it is easy to extend the support to remains the same, because of the mimicking properties other apps within these classes. of M-Aegis. We first decribe the cryptographic schemes that we de- ployed in our prototype, then we explain how we build 4 Implementation and Deployment our UIAM and create L-7.5 on Android, and finally dis- cuss the per-TCA logic required to support both classes In this section, we discuss some important details of our of apps. prototype implementations. We implemented a proto- type of M-Aegis using Java on Android, as an accessi- 4.1 Cryptographic Schemes bility service. This is done by creating a class that ex- tends the AccessibilityService class and requesting For all the encryption/decryption operations, we use for BIND ACCESSIBILITY SERVICE permission in the AES-GCM-256. For password-based key generation al- manifest. This allows us to interface with the UIA li- gorithm, we utilized PBKDF2 with SHA-1 as keyed- brary, building our UIAM. We discuss this in further de- hash message authentication code (HMAC). We also tail in Sect. 4.2. utilized HMAC-SHA-256 as our HMAC to generate

9 tags for email messages (Sect. 4.4.1). These func- tionalities are available in Java’s javax.crypto and java.security packages. In terms of key management, for the sake of usabil- ity, we implemented a password-based scheme as the de- fault, and we assume one password for each group of message recipients. And we rely on the users to com- municate the password to the receiving parties using out of band channel (e.g. in person or phone calls). Again, please note that M-Aegis can also support PKI for users who prefer stronger security guarantees and do not mind the additional set-up overheads. However, the discus- sions about key exchange for this scheme is out scope of this paper. Since keys are stored locally for user conve- nience, we make sure that they are never saved to disk in Figure 5: The UI Automator Viewer presents an easy to plaintext. It is additionally encrypted with a key derived use interface for us to examine the UIA tree and deter- from a master password that is provided by the user dur- mine the resource ID (blue ellipse) associated with the ing installation. GUI of interest (red rectangle).

4.3 Layer 7.5 4.2 UIAM We implemented Layer 7.5 on Android as specific types of system windows, which are always-on-top despite changes to the current app or even when a different As mentioned earlier, UIAM is implemented based app is launched. Generally, Android allows the creation on UIA library. On Android, events that signify of various types of system windows. In our case, we something new is being displayed on the screen mainly focus on two, namely TYPE SYSTEM OVERLAY can be detected by monitoring following events: and TYPE SYSTEM ERROR; the first kind of window is for WINDOW CONTENT CHANGED, WINDOW STATE CHANGED, display-only and allows all tap/keyboard events to go to and VIEW SCROLLED. Upon receiving these events, the the underlying apps. In contrast, the user can interact per-TCA logic is informed. The UIA library presents a with the second type of window. Finally, Android allows data structure in the form of a tree with nodes represent- the use of any View objects for either type of window, ing UI components and the root being the top window. and we use this to create our mimic-GUIs, of which we This allows the UIAM to locate all UI components on can set the size and location of. We deliberately create the screen. our mimic-GUIs in different colors as a subtle visual cue Additionally, Android’s UIA framework also provides to the users that they are interacting with M-Aegis, with- us the ability to query for UI nodes by providing a re- out distracting them from their original workflow. source ID in an intuitive way. For instance, the node that represents Gmail’s search button can be found by query- ing for com.google.android.gm:id/search. More 4.4 Per-TCA Logic importantly, we do not need to guess the names of these From our experience of developing the per-TCA logic, resource IDs. Rather, we rely on a tool called UI Auto- the general procedure for development is as follow: mater Viewer [15] (see how we use this tool in Sect. 4.4), 1) Understand what the app does. This allows us to which comes with the default Android SDK. Once the identify which GUIs need to be mimicked for intercept- node of interest is found, all the other information about ing user I/O. For text-based TCAs, this is a very easy step the GUI represented by the node can be found. This in- because the core functionalities that M-Aegis needs to cludes the exact location and size of text boxes and but- handle are limited and thus easy to identify, e.g. buffer- tons on the screen. ing user’s typed texts and sending them to the intended Further, M-Aegis is able to programatically inter- recipient. act with various GUIs of the TCA using the function 2) Using UI Automator Viewer [15], examine the UIA performAction(). This is useful for it to click on the tree for the relevant GUIs of the TCA and identify sig- TCA’s button on user’s behalf after it has processed the natures (in our case, it is the GUI’s resource ID) for each user input. TCA state. UI Automator Viewer allows us to inspect

10 the UIA’s tree through a graphical interface (as seen in a pair of curly braces (i.e. {, }). Fig. 5), which significantly cuts down on our develop- Next, we describe implementation details that are spe- ment time. We basically rely on UI components that are cific to these class of apps. We begin by introducing the unique to certain states (e.g. the “send” button signifies format of message we created for each class. Then we that we are in the compose state). discuss other caveats (if any) that are involved in the im- 3) For each relevant GUI, we need to devise algo- plementation. rithms to extract either the location and content of cipher- text (for decryption and display), or the type, size and 4.4.1 Email Apps location of GUIs we need to mimic (e.g. the subject and content boxes in the Gmail compose UI). Again, this is We implemented support for Gmail on our prototype as a done through UI Automator Viewer. For example, for the representative app of this category without loss of gener- Gmail preview state, we query the UIA for nodes with ID ality. For Gmail, we create two custom formats to com- com.google.android.gm:/id/conversation list municate the necessary metadata to support M-Aegis’ to identify all the UIA nodes corresponding to the functionalities. preview item of each individual email, and from those Subject: {Encode(IDKey||IV||Encrypt(Sub ject))} we can extract all ciphertext on preview through the Content: {Encode(Encrypt(Content)||Tags)} UIA). A particular challenge we faced in supporting decryp- 4) Create event handlers for controls we mimic on L- tion during the Gmail preview state is that only the begin- 7.5. For example, for the Gmail compose state, we need ning parts of both the title and the subject of each mes- to listen for click/touch events to the “send” button we sage are available to us. Also, the exact email addresses place on L-7.5 and carry out the process described in of the sender and recipients are not always available, as Sect. 3.3.3 to encrypt the email and send the ciphertext some are displayed as aliases, and some are hidden due to the underlying TCA. to lack of space. The lack of such information makes it 5) Identify ways that each relevant state can be up- impossible to automatically decrypt the message even if dated. We found that updates can be handled with the the corresponding key actually exists on the system. following method: clear L-7.5 and extract all the infor- To solve these problems, when we encrypt a message, mation we need from that state and render everything we include a key-ID (IDKey) to the subject field (as seen again (this is how we handle scrolling). This is equiva- in the format description above). Note that since the key- lent to redrawing all GUIs on L-7.5 based on the detected ID is not a secret, it need not be encrypted. This way, we state. will have all the information we need to correctly decrypt There are two details that we need to pay attention to the little snippet displayed on the Gmail preview. when developing per-TCA logic. First, we need to be The Tags field is a collection of HMAC digests that careful about the type of input data that we feed to TCAs. are computed using the conversation key and keywords Since most TCAs only accept input data in specific for- that exist in that particular email. It is then encoded and mats, e.g. text format, they do not support the input of appended as part of the content that Gmail receives to random byte sequences as valid data. Therefore, the en- faciliate encrypted search without requiring modification crypted data must be encoded into text format before to Gmail servers. feeding it as input to the TCA. Conventionally, base64 encoding is used for such purposes. However, base64 encoding consumes too much on-screen real-estate. To 4.4.2 Messenger Apps overcome this, we encoded the binary encrypted data We implemented support for Facebook Messenger on our into Chinese Japanese Korean (CJK) Unicode characters, prototype as a representative app of this category without which have a more efficient on-screen real-estate con- loss of generality. The format we created for this class of sumption. To map the binary data into the CJK plane, we apps is simple, as seen below: 8 process the encrypted data at the byte granularity (2 ). Message: {Encode(IV||Encrypt(Message))} For each byte, its value is added to the base of the CJK We did not experience additional challenges when Unicode representation, i.e. 0x4E00. For example, byte supporting the Facebook Messenger app. 0x00 will be encoded as ‘一’, and byte 0x01 will be rep- resented as ‘丁’. Second, M-Aegis can only function correctly if it can 5 Evaluations differentiate between ordinary messages and encrypted ones to decrypt message properly. We introduce markers In this section, we report the results of experiments we into the encrypted data after encoding; in particular, we performed to first determine the correctness of our proto- wrap each of the subject and content of a message using type implementation, measure the overheads a user bears

11 when using M-Aegis, and user acceptability of our ap- For our experiment, we made sure that the whole pre- proach. view page consists of encrypted emails (a total of 6 can fit the screen) to demonstrate the worst case performance. 5.1 Correctness of Implementation Then, we measured the time taken to perform all the aforementioned micro operations. From the results, we Before we measure the performance, we manually ver- found that for this case, on average, it takes an additional ified that our app-support works correctly by navigat- 76 ms to finally render plaintext on L-7.5. Note that this ing through different states of the app and check if M- latency is well within the expected response time (50 - Aegis creates L-7.5 correctly. Then, we also manually 150 ms), beyond which a user would notice the slow- verified that the encryption and decryption operations on down effect [58]. M-Aegis work correctly. We made sure that the plain- text is properly received at the recipient’s end when the 5.2.2 Composing and Sending Encrypted Email correct password is supplied. We also manually verified the correctness of the our searchable encryption scheme First, we measured the extra time taken for a typical by first planting specific keywords to be searched. Then, email to be encrypted and for our searchable encryption we performed search using M-Aegis and found no false index to be built. We used the Enron Email Dataset [32] negatives in the search result. as a representation of how typical emails would be. Out of the dataset, we randomly picked 10 emails, with the following statistics: The average number of words in an 5.2 Performance on Android email is 331, out of which 153 are unique. The shortest The overhead that M-Aegis introduced to a user’s work- sampled email contains 36 words, out of which 35 are flow can be broken down into two main factors: i) the unique; while the longest sampled email contains 953 additional computational costs incurred during encryp- words, out of which 362 are unique. tion and decryption of data, ii) the additional I/O opera- In the worst case, i.e., with the longest sampled email, tions when redrawing L-7.5. We measure the overhead M-Aegis took around 205 ms in total to both encrypt and by measuring the overall latency presented to the user in build search index. However, note that this is actually a few cases. We found that M-Aegis imposes negligible blended in with the network latency user will already per- latency to the user. ceive while sending out email. All test cases were performed on one stock Android phone (LG Nexus 4), with the following specifications: 5.2.3 Searching on Encrypted Emails Quad-core 1.5 GHz Snapdragon S4 Pro CPU, equipped with 2.0 GB RAM, running Android Kit Kat (4.4.2, with As a user usually inputs only about one to three keywords API level 19). Unless otherwise stated, each experiment per search operation, the latency experienced when per- is repeated for 10 times and the averaged result is re- forming search is negligible. This is because the transfor- ported. mation of the actual keyword into indexes requires only For our evaluation, we only performed experiments on the forward computation of one HMAC, which is almost the setup for Gmail app because Gmail is representative instantaneous. of a more sophisticated TCA, therefore estimating the worst case performance for M-Aegis. The other class, 5.3 User Acceptability Study i.e. messenger apps, incurs much less overhead as the most involved operation is the encryption and decryption This section describes the user study we performed to of short texts within a page. validate the hypothesis about user acceptability of our M-Aegis concept and prototype. Users are sampled from 5.2.1 Previewing Encrypted Email a population of college students, of which we consider as tech-savvy. Particularly, they must be able to profi- There are additional costs involved in previewing en- ciently operate smart phones and have had experience crypted emails on the main page of Gmail. The costs are using Gmail app before. Each experiment was conducted broken down into times taken to i) traverse the UIA tree with two identical smart phones, i.e. Nexus 4, both run- to identify preview nodes, ii) grab the ciphertext from the ning Android 4.3, installed with stock Gmail app (v. 4.6). UIA node, iii) grab the associated key from key manager Only one of the devices has M-Aegis installed. according to key ID, iv) decrypting the ciphertext, and v) The set up of the experiment is as follows. First, rendering plaintext on L-7.5. We measure all these mi- we asked the user to perform a list of tasks: preview- cro operations as an entirety instead by running a macro ing, reading, composing, sending, and searching through benchmarks. email on a device which is not equipped with M-Aegis.

12 Participants were asked to pay attention to the overall ex- 6 Discussions perience of performing such tasks using Gmail app and try their best to remember it. This served as the control 6.1 Generality and Scalability experiment and to help participants recap the look and feel of the installed Gmail app. We believe that our M-Aegis architecture presents a general solution that protects users’ data confidentiality, Right after they are done, the participants were told to which is scalable in the following aspects: repeat the same set of tasks on another device which is Across multiple cloud services. In general, there are equipped with M-Aegis. This was done with the inten- two main classes of apps that provide communication tion that they were able to mentally compare the differ- services, which covers a large number of apps that user ence in user experience when interacting with the device care to protect, namely email and messenger apps. By equipped with M-Aegis. covering apps in these two categories, we argue that we can already satisfy a large need of the user in protecting After they were done with the second device, we ask the privacy of their data. the participants five questions, phrased in terms of do All the different components of M-Aegis incur a one they find any difference in the preview page, reading, time development cost. We argue that it is easy to sending, and searching email, and if they felt that their scale across multiple cloud services, because the per- overall experience using Gmail app on the second device TCA logic that needs to be written is actually very lit- is significantly different. tle per new TCA that we want to support. This should Upon finishing this, we debriefed the participants be evident through the five general steps highlighted in about the experiment process and explained the goal of Sect. 4.4. In addition, the logic we developed for the first M-Aegis. Lastly, we asked them whether they would use TCA (Gmail) serves as a template/example to implement M-Aegis to protect the privacy of their data. The results support other email apps. we collected and report here are from 15 participants. Across app updates. Since the robustness of our UIAM construct (Sect. 4.2) gives us the ability to track Altogether, we found that no participants noticed ma- all TCA’s GUIs regardless of its state, we are able to sur- jor difference between the two experiences using Gmail vive app updates quite easily. In fact, our Gmail app sup- app. Only one participant noticed a minor difference in port has survived two versions of updates without requir- the email preview interface, i.e. the overlays not catching ing major efforts to adapt. up smoothly when scrolled. A different participant no- As expected, resource ID names can change across up- ticed a minor difference in the process of reading email, dates. For example, when upgraded to Gmail app version i.e. L-7.5 lags a little before covering up the ciphertext 4.7.2, the resource ID name that identifies the sender’s with mimic-GUIs. There were only two participants who account name changed. But with a small fix to reidentify found the process of sending email differs from the orig- the resource ID using UI Automator Viewer, we quickly inal one. When asked for details, they all indicated that fixed it by changing the mapping in our per-TCA logic. the cursor when composing email was not working prop- Note that the logic in the per-TCA does not need to be erly. After further investigation, we found that this is modified. This is because the core functionality of the caused by a bug we in Android’s GUI framework than a updated GUI would not change to something radically fundamental flaw in our M-Aegis design. different. For example, a GUI associated with sender’s account name would not suddenly has the functionality However, despite the perceived minor differences of a compose editbox. when performing particular tasks, all participants indi- cated that they would use M-Aegis to protect the privacy of their data after understanding what M-Aegis is. This 6.2 Limitations implies that they believe that the overall disturbance to the user experience is not large enough to impede adop- As mentioned earlier, M-Aegis is not designed to protect tion. users against social engineering based attacks. Adver- saries can try to trick users into entering sensitive infor- Since we recruited 15 users for this study, the accu- mation to the TCA while M-Aegis is turned off. Our so- racy/quality of our conclusion from this study lies be- lutions is based on best effort by providing distinguishing tween 80% to 95% (between 10 and 20 users) accord- visual cues to the user when M-Aegis is turned on and ing to findings in [42]. We intend to continue our user its L-7.5 is created. For example, when turned on, the study to further validate our acceptability hypothesis and mimic-GUIs that M-Aegis creates are in different color. to continuously improve our prototype based on the re- Users can toggle M-Aegis’ button on/off to see the dif- ceived feedback. ference (see Fig. 2). However, we do not claim that this

13 fully mitigates the problem. client app is preserved completely, from workflow to One of the constraints we faced while retrofitting a se- GUI look-and-feel; and 3) the archicture and technique curity solution to existing TCAs (not limited to mobile are general to a large number of apps and resilient to environment) is that data must usually be of the right for- app updates. We implemented a prototype of M-Aegis mat (e.g. strictly text, image, audio, or video). For exam- on Android that can support a number of popular cloud ple, Gmail accepts only text (unicode-compatible) as its services (e.g. Gmail, Google Hangout, Facebook, What- subject, but Dropbox accepts any type of files, which can sApp, and Viber). Our user study shows that our sys- just be random blobs of bytes. Currently, other than the tem truly preserves both the workflow and the GUI look- text format, we do not (yet) support other types of user and-feel of the protected applications, and our perfor- data (e.g. image, audio and video). However, this is not mance shows that users experienced minimal overhead a fundamental design limitation of our system. Rather, in utilizing M-Aegis on Android: imperceptible encryp- it is because of the unavailability of transformation func- tion/decryption latency and very low and adjustable false tions (encryption and encoding schemes) that works for positive rate when searching over encrypted data. the aforementioned media types. Additionally, unlike text, the transforma- Acknowledgement tion/obfuscation function that is applicable in our scenario that takes input of other type of data may also The authors would like to thank the anonymous re- need to survive other process steps, such as compression. viewers for their valuable comments. We also thank It is normal for TCAs to perform compression on other the various members of our operations staff who pro- multimedias to save bandwidth and/or storage. For vided proofreading of this paper. This material is based example, Facebook is known to compress/downsample upon work supported in part by the National Science the actual image that the user uploads despite choosing Foundation under Grants No. CNS-1017265, CNS- the HD option. 0831300, CNS-1149051, CNS-0831184, TWC-1318511 While the proper application of encryption schemes and CNS-1318511, by the Office of Naval Research un- allows us to protect user’s data privacy, the confidential- der Grant No. N000140911042, by the Department of ity guarantee that we provide excludes risks at end-point Homeland Security under contract No. N66001-12-C- themselves. For example, poor random number gener- 0133, and by the United States Air Force under Contract ator can potentially weaken the cryptographic schemes No. FA8650-10-C-7025. Any opinions, findings, and that we applied. Further, it is currently unclear how our conclusions or recommendations expressed in this mate- text transformations will affect the server’s effectiveness rial are those of the authors and do not necessarily reflect in performing spam filtering. the views of the National Science Foundation, the Office Another limitation of our system is that it currently of Naval Research, the Department of Homeland Secu- does not tolerate typographical error during search. rity, or the United States Air Force. However, we would like to point out that this is a very unlikely scenario, given that soft keyboards on mobile References devices comes with spell check and autocorrect features. Again, this is not a flaw with our architecture, rather, it [1] Accessibility. http://developer.android.com/guide/topics/ui/ is because of the unavailability of encryption schemes accessibility/index.html. that tolerate typographical error search without requiring [2] Cisco Visual Networking Index: Global Mo- server modification. bile Data Traffic Forecast Update, 2013–2018. http://www.cisco.com/c/en/us/solutions/collateral/service- provider/visual-networking-index-vni/white paper c11- 7 Conclusions 520862.html. [3] Cryptocat. https://crypto.cat. In this paper we presented a privacy-preserving system [4] Engineering Security Solutions at Layer 8 and Above. called Mimesis Aegis (M-Aegis) to protect private user https://blogs.rsa.com/engineering-security-solutions-at-layer-8- data in public cloud services. M-Aegis provides strong and-above/, December. isolation and preserves user experience through the cre- [5] Gibberbot for Android devices. ation of a conceptual layer called Layer 7.5 (L-7.5), https://securityinabox.org/en/Gibberbot main. which is interposed between the application (Layer 7) [6] Google Accessibility. https://www.google.com/accessibility/policy/. and the user (Layer 8). This approach allows M-Aegis [7] Google Chrome Mobile FAQ. to implement a true end-to-end encryption of user data https://developers.google.com/chrome/mobile/docs/faq. while achieving three goals: 1) plaintext data is never [8] International technology - Open Systems Interconnection - visible to a client app, any intermediary entities, or the Basic Reference Model: The Basic Model. http://www.ecma- cloud provider; 2) the original user experience with the international.org/activities/Communications/TG11/s020269e.pdf.

14 [9] Microsoft Accessibility. [27] BERTHOME, P., FECHEROLLE, T., GUILLOTEAU,N., AND LA- http://www.microsoft.com/enable/microsoft/ LANDE, J.-F. Repackaging android applications for auditing section508.aspx. access to private data. In Availability, Reliability and Security [10] New privacy fears as facebook begins selling per- (ARES), 2012 Seventh International Conference on (2012), IEEE, sonal access to companies to boost ailing profits. pp. 388–396. http://www.dailymail.co.uk/news/article-2212178/New- [28] BOHMER¨ ,M.,HECHT,B.,SCHONING¨ ,J.,KRUGER¨ ,A., AND privacy-row-Facebook-begins-selling-access-users-boost- BAUER, G. Falling asleep with angry birds, facebook and kindle: ailing-profits.html. a large scale study on mobile application usage. In Proceedings [11] Secure texts for Android. https://whispersystems.org. of the 13th international conference on Human computer interac- tion with mobile devices and services (2011), ACM, pp. 47–56. [12] Snowden: Leak of NSA spy programs ”marks my end”. http://www.cbsnews.com/8301-201 162-57588462/snowden- [29] BONEH,D.,CRESCENZO,G.D.,OSTROVSKY,R., AND PER- leak-of-nsa-spy-programs-marks-my-end/. SIANO, G. Public key encryption with keyword search. In EU- ROCRYPT (2004), C. Cachin and J. Camenisch, Eds., vol. 3027 [13] Symantec desktop email encryption end-to-end of Lecture Notes in Computer Science, Springer, pp. 506–522. email for laptops and desktops. http://www.symantec.com/desktop-email-encryption. [30] BORISOV,N.,GOLDBERG,I., AND BREWER, E. Off-the-record communication, or, why not to use pgp. In Proceedings of the [14] Ten Mistakes That Can Ruin Cus- 2004 ACM workshop on Privacy in the electronic society (2004), tomers’ Mobile App Experience. ACM, pp. 77–84. http://www.itbusinessedge.com/slideshows/show.aspx?c=96038. [31] CHANG, Y.-C., AND MITZENMACHER, M. Privacy preserving [15] UI Testing — Android Developers. keyword searches on remote encrypted data. In Applied Cryp- http://developer.android.com/tools/testing/ tography and Network Security, J. Ioannidis, A. Keromytis, and testing_ui.html. M. Yung, Eds., vol. 3531 of Lecture Notes in Computer Science. [16] Layer 8 Security: OPSEC for Linux Com- Springer, 2005, pp. 442–455. mon Users, Developers and Systems Administrators. [32] COHEN, W. W. Enron email dataset. http://www.cs.cmu.edu/ en- http://www.linuxgazette.net/164/kachold.html, July 2009. ron, August 2009. [17] Accessibility. [33] CURTMOLA,R.,GARAY,J.A.,KAMARA,S., AND OSTRO- https://www.apple.com/accessibility/resources/, VSKY, R. Searchable symmetric encryption: Improved defini- February 2014. tions and efficient constructions. In ACM Conference on Com- [18] 107TH CONGRESS. Uniting and strengthening america by pro- puter and Communications Security (2006), A. Juels, R. N. viding appropriate tools required to intercept and obstruct terror- Wright, and S. D. C. di Vimercati, Eds., ACM, pp. 79–88. ism (usa patriot act) act of 2001. Public Law 107-56 (2001). [34] DELTCHEVA, R. Apple, AT&T data leak [19] ACQUISTI,A., AND GROSS, R. Imagined communities: Aware- protection issues latest in cloud failures. ness, information sharing, and privacy on the facebook. In Pri- http://www.messagingarchitects.com/resources/security- vacy enhancing technologies (2006), Springer, pp. 36–58. compliance-news/email-security/apple-att-data-leak-protection- issues-latest-in-cloud-failures19836720.html, June 2010. [20] AMANATIDIS,G.,BOLDYREVA,A., AND O’NEILL,A. Provably-secure schemes for basic query support in outsourced [35] DINGLEDINE,R.,MATHEWSON,N., AND SYVERSON, P. Tor: databases. In DBSec (2007), S. Barker and G.-J. Ahn, Eds., The second-generation onion router. Tech. rep., DTIC Document, vol. 4602 of Lecture Notes in Computer Science, Springer, 2004. pp. 14–30. [36] DONG,X.,CHEN,Z.,SIADATI,H.,TOPLE,S.,SAXENA, P., [21] BADEN,R.,BENDER,A.,SPRING,N.,BHATTACHARJEE,B., AND LIANG, Z. Protecting sensitive web content from client- AND STARIN, D. Persona: an online social network with user- side vulnerabilities with cryptons. In Proceedings of the 2013 defined privacy. In ACM SIGCOMM Computer Communication ACM SIGSAC conference on Computer & communications secu- Review (2009), vol. 39, ACM, pp. 135–146. rity (2013), ACM, pp. 1311–1324. [22] BEATO, F., KOHLWEISS,M., AND WOUTERS, K. Scramble! [37] ELKINS, M. Mime security with (pgp). Privacy Enhancing Technologies your social network data. In [38] ENCK, W., GILBERT, P., CHUN,B.-G.,COX, L. P., JUNG,J., (2011), Springer, pp. 211–225. MCDANIEL, P., AND SHETH, A. Taintdroid: An information- [23] BELLARE,M.,BOLDYREVA,A., AND MICALI, S. Public-key flow tracking system for realtime privacy monitoring on smart- encryption in a multi-user setting: Security proofs and improve- phones. In OSDI (2010), vol. 10, pp. 1–6. ments. In EUROCRYPT (2000), B. Preneel, Ed., vol. 1807 of [39] FAHL,S.,HARBACH,M.,MUDERS, T., BAUMGARTNER¨ ,L., Lecture Notes in Computer Science, Springer, pp. 259–274. FREISLEBEN,B., AND SMITH, M. Why eve and mallory love [24] BELLARE,M.,BOLDYREVA,A., AND O’NEILL, A. Determin- android: An analysis of android ssl (in)security. In Proceedings istic and efficiently searchable encryption. In CRYPTO (2007), of the 2012 ACM Conference on Computer and Communications A. Menezes, Ed., vol. 4622 of Lecture Notes in Computer Sci- Security (New York, NY, USA, 2012), CCS ’12, ACM, pp. 50– ence, Springer, pp. 535–552. 61. [25] BELLARE,M.,KOHNO, T., AND NAMPREMPRE, C. Breaking [40] FAHL,S.,HARBACH,M.,MUDERS, T., AND SMITH, M. Trust- and provably repairing the SSH authenticated encryption scheme: split: usable confidentiality for social network messaging. In Pro- A case study of the Encode-then-Encrypt-and-MAC paradigm. ceedings of the 23rd ACM conference on Hypertext and social ACM Trans. Inf. Syst. Secur. 7, 2 (May 2004), 206–241. media (2012), ACM, pp. 145–154. [26] BELLARE,M., AND NAMPREMPRE, C. Authenticated en- [41] FARB,M.,LIN, Y.-H., KIM, T. H.-J., MCCUNE,J., AND cryption: Relations among notions and analysis of the generic PERRIG, A. Safeslinger: easy-to-use and secure public-key ex- composition paradigm. In ASIACRYPT (2000), T. Okamoto, change. In Proceedings of the 19th annual international confer- Ed., vol. 1976 of Lecture Notes in Computer Science, Springer, ence on Mobile computing & networking (2013), ACM, pp. 417– pp. 531–545. 428.

15 [42] FAULKNER, L. Beyond the five-user assumption: Benefits of [59] SONG,D.X.,WAGNER,D., AND PERRIG, A. Practical tech- increased sample sizes in usability testing. Behavior Research niques for searches on encrypted data. In IEEE Symposium on Methods, Instruments, & Computers 35, 3 (2003), 379–383. Security and Privacy (2000), pp. 44–55.

[43] FELDMAN,A.J.,BLANKSTEIN,A.,FREEDMAN,M.J., AND [60] TSUNOO, Y., SAITO, T., SUZAKI, T., SHIGERI,M., AND FELTEN, E. W. Social networking with frientegrity: privacy and MIYAUCHI, H. Cryptanalysis of des implemented on computers integrity with an untrusted provider. In Proceedings of the 21st with cache. In Cryptographic Hardware and Embedded Systems- USENIX conference on Security symposium, Security (2012), CHES 2003. Springer, 2003, pp. 62–76. vol. 12. [61] US-CERT/NIST. Cve-2013-4787. [44] GOH, E.-J. Secure indexes. IACR Cryptology ePrint Archive http://web.nvd.nist.gov/view/vuln/detail?vulnId= (2003). CVE-2013-4787. [45] GOLDREICH,O., AND OSTROVSKY, R. Software protection and simulation on oblivious rams. J. ACM 43, 3 (1996), 431–473. [62] WHITTAKER,S.,MATTHEWS, T., CERRUTI,J.,BADENES,H., AND TANG, J. Am i wasting my time organizing email?: a study [46] GUHA,S.,TANG,K., AND FRANCIS, P. Noyb: Privacy in on- of email refinding. In PART 5——–Proceedings of the 2011 an- line social networks. In Proceedings of the first workshop on nual conference on Human factors in computing systems (2011), Online social networks (2008), ACM, pp. 49–54. ACM, pp. 3449–3458. [47] HENRY, S. Largest hacking, data breach prose- [63] WOJTCZUK,R., AND TERESHKIN, A. Attacking intel R bios. cution in U.S. history launches with five arrests. Invisible Things Lab (2010). http://www.mercurynews.com/business/ci23730361/largest- hacking-data-breach-prosecution-u-s-history, July 2013. [64] WU,C.,ZHOU, Y., PATEL,K.,LIANG,Z., AND JIANG,X. [48] JANG, Y., CHUNG, S. P., PAYNE,B.D., AND LEE, W. Gyrus: Airbag: Boosting smartphone resistance to malware infection. In A framework for user-intent monitoring of text-based networked NDSS (2014). applications. In NDSS (2014). [65] XU,R.,SA¨IDI,H., AND ANDERSON, R. Aurasium: Practi- [49] JEON,J.,MICINSKI,K.K.,VAUGHAN,J.A.,FOGEL,A., cal policy enforcement for android applications. In Proceedings REDDY,N.,FOSTER,J.S., AND MILLSTEIN, T. Dr. android of the 21st USENIX conference on Security symposium (2012), and mr. hide: fine-grained permissions in android applications. USENIX Association, pp. 27–27. In Proceedings of the second ACM workshop on Security and pri- vacy in smartphones and mobile devices (2012), ACM, pp. 3–14. [50] JIANG, X. Gingermaster: First android malware utilizing a root A Appendices exploit on android 2.3 (gingerbread). http://www.csc.ncsu.edu/faculty/jiang/ GingerMaster/. A Easily-Deployable ESE [51] KAMARA,S.,PAPAMANTHOU,C., AND ROEDER, T. Dy- namic searchable symmetric encryption. In Proceedings of the In this section, we formally define our cryptographic 2012 ACM conference on Computer and communications secu- scheme, which allows for search in encrypted emails. We rity (2012), ACM, pp. 965–976. start with the preliminaries. [52] KING, S. T., TUCEK,J.,COZZIE,A.,GRIER,C.,JIANG, W., AND ZHOU, Y. Designing and implementing malicious hard- ware. In Proceedings of the 1st Usenix Workshop on Large- A.1 Preliminaries Scale Exploits and Emergent Threats (Berkeley, CA, USA, 2008), LEET’08, USENIX Association, pp. 5:1–5:8. NOTATION AND CONVENTIONS. We denote by Σ∗ the [53] KONTAXIS,G.,POLYCHRONAKIS,M.,KEROMYTIS,A.D., set of all binary strings of finite length. If x,y are strings AND MARKATOS, E. P. Privacy-preserving social plugins. In Proceedings of the 21st USENIX conference on Security sympo- then (x,y) denotes the concatenation of x and y from sium (2012), USENIX Association, pp. 30–30. which x and y are uniquely decodable. For integers k,l, [54] LUCAS,M.M., AND BORISOV, N. Flybynight: mitigating the where k < l [k...l] denotes the set {k,k+1,...,l} and [k] privacy risks of social networking. In Proceedings of the 7th $ ACM workshop on Privacy in the electronic society (2008), ACM, denotes {1,...,k}. If S is a finite set, then s ← S denotes pp. 1–8. that s is selected uniformly at random from S. If s,S are [55] PEEK,D., AND FLINN, J. Trapperkeeper: the case for using vir- strings, then s ∈ S denotes that s is a substring of S. tualization to add type awareness to file systems. In Proceedings PROVABLESECURITYAPPROACH. In this work we ap- of the 2nd USENIX conference on Hot topics in storage and file ply the provable security approach. Unlike the unproduc- systems (2010), USENIX Association, pp. 8–8. tive and cyclic trial-and-error approach to security, this [56] ROESNER, F., KOHNO, T., MOSHCHUK,A.,PARNO,B., methodology allows us to have protocols, whose security WANG,H.J., AND COWAN, C. User-driven access control: Re- thinking permission granting in modern operating systems. In Se- is provably guaranteed, as long as the assumption about curity and Privacy (SP), 2012 IEEE Symposium on (2012), IEEE, the underlying hard problem remains true for computa- pp. 224–238. tionally bounded adversaries. This approach consists of [57] SHAH, K. Common Mobile App Design Mistakes to Take Care. the following components. (1) A formal definition of a http://www.enterprisecioforum.com/en/blogs/kaushalshah/common- mobile-app-design-mistakes-take-c. protocol’s syntax. (2) A formal definition of the secu- rity task in question that includes a precise description of [58] SHNEIDERMAN,B. Designing the User Interface: Strategies for Effective Human-Computer Interaction, fourth ed. Addison- adversarial capabilities and when is the adversary con- Wesley, 2005. sidered successful. (3) A reduction proof showing that

16 the only way to break the protocol according to the defi- gorithm T takes the input secret key sk, and a plaintext nition is by breaking the underlying problem, believed to m ∈ MsgSp to return a tag for m. For a message-tag pair be hard. (m,σ), we say σ is a valid tag for m, if σ = σ 0, where 0 SYMMETRIC ENCRYPTIONANDITSSECURITY.A sym- σ ← Tsk(m). metric encryption scheme SE = (K ,E , D) with as- We will use the following security definition (which sociated message space MsgSp, is defined by three al- implies the unforgeability against chosen message at- gorithms: The randomized key generation algorithm K tack). Let M = (K ,T ) be a MAC scheme. Let R be returns a secret key sk. The (possibly) randomized or the set of all functions with the same domain and range stateful encryption algorithm E takes the input secret key as T . M is called pseudorandom or PRF secure, if any sk, and a plaintext m ∈ MsgSp, and returns a ciphertext. adversary A with reasonable resources and access to an The deterministic decryption algorithm D takes the se- oracle that it can query on messages in MsgSp, has small cret key sk, and a ciphertext C to return the correspond- prf prf-advantage AdvM (A) defined as ing plaintext, or a special symbol ⊥ indicating that the ci- h $ (·) i h $ i phertext was invalid. The consistency condition requires Pr sk ← K : ATsk = 1 −Pr g ← R : Ag(·) = 1 . that Dsk(Esk(m)) = m, for all sk that can be output by K , and all m ∈ MsgSp. A weaker security notion, IND-DCPA, is defined in We now recall the standard cryptographic security no- [25]. The notion asks the scheme to hide all but equality tions for encryption, indistinguishability against chosen- of the underlying messages. It is defined similar to IND- plaintext attacks (IND-CPA). It formalizes the require- CPA but the adversary’s queries are required to have the ment that even though an adversary may know some par- same equality pattern among the “left” and ”right” vec- tial information about the data, no additional information tors. is leaked (besides the message length). Let SE = (K ,E ,D) be an encryption scheme. A.2 Primitive Definition and Security For an adversary A and a bit b, define the experiment ind-cpa-b Definition A.1 [EDESE] An easily-deployed effi- ExpSE (A) as follows. First the key sk is generated by K . Let LR (left-or-right) be the “selector” that on ciently- searchable symmetric encryption scheme input m0,m1,b returns mb. The adversary A is given ac- (EDESE) ESE is associated with message space cess to the left-right encryption oracle Esk(LR(·,·,b)) MsgSp and keyword space KwSp. We assume that each that it can query on any pair of messages of equal length message m ∈ MsgSp can also be viewed as a set of in MsgSp. The adversary’s goal is to output a bit d, keywords, and the particular meaning should be clear as its guess of the challenge bit b, and the experiment from the context. (E.g. |m| denotes the length of m in returns d as well. The ind-cpa-advantage of an adver- bits, |m|kw denotes the number of keywords in m and ind-cpa m0 ∩ m1 denotes the set of common keywords in m0 sary A, AdvSE (A), is defined as the difference be- ind-cpa-1 and m1.) We assume that given m ∈ MsgSp one can tween the probabilities of ExpSE (A) returning 1 and ind-cpa-0 efficiently extract all keywords in it. An EDESE scheme Exp (A) returning 1. SE is defined by four algorithms: The scheme SE is said to be indistinguishable against chosen-plaintext attack or IND-CPA, if for every • The randomized key generation algorithm K re- adversary A with reasonable resources its ind-cpa advan- turns a secret key sk. tage is small2. MESSAGE AUTHENTICATION CODES (MACS).A • The (possibly) randomized or stateful encryption al- message authentication code (MAC) M = (K ,T ) with gorithm E takes input the secret key sk, and a plain- associated message space MsgSp is defined by two al- text m ∈ MsgSp, and returns a ciphertext c. To use gorithms. The randomized key generation algorithm K the fact that a ciphertext is searchable by a server, returns a secret key sk. The deterministic3 tagging al- just like any other text, we will use the notation s ∈ c to denote that a substring s is part of c. 2Here, and further in the paper, we call the resources of an algorithm (or adversary) “reasonable”, if it runs for some reasonable amount of • The deterministic decryption algorithm D takes the time (e.g. up to 10 years, or does 260 basic operations in some fixed secret key sk, and a ciphertext c to return the plain- model of computation), and does reasonable number of oracle queries text. of reasonable length. We call the value of an advantage “small”, if it −20 is very close to 0 (e.g. 2 .) In general, “ reasonable” parameters • The deterministic query function takes input the depend on a particular application. We do not use asymptotic notation Q because the symmetric key primitives such as blockciphers are of fixed secret key sk, and a keyword w ∈ KwSp, and returns length. a string s. 3A MAC does not have to be deterministic, but most practical schemes are, and in this paper we consider only deterministic MACs. We require that

17 • Dsk(Esk(m)) = m, for all sk that can be output by MAC key, a new ciphertext includes the MAC of the K , and all m ∈ MsgSp. previous-scheme ciphertext, and the new decryption al- gorithm verifies the MAC before decrypting and out- • m ∈ MsgSp For all sk that can be output by K , all putting the message. and all w ∈ KwSp, we always have that Qsk(w) ∈ Esk(m), if w ∈ m, and the probability of Qsk(w) ∈ Remark A.5 Our security notion is similar to that of Esk(m), if w ∈/ m, is at most δ. Goh [44], but ours is stronger in that we allow the chal- The latter condition ensures that the search on a key- lenge documents to contain different number of words word will always return all ciphertexts of messages con- and we allow the adversary to pick an arbitrary num- taining the keyword, and that the probability of a false- ber of challenge document pairs adaptively. We do not positive is at most δ. know if the latter makes the definition strictly stronger, EDESESECURITY. We construct the following but unless one proves otherwise it is important to con- indistinguishability-based security definition, called sider more powerful adversaries. Also, for our primitive PRIV-CPA, for analyzing the security of EDESE the security notion requires the queries to hide partial in- schemes. Intuitively, this notion is similar to the stan- formation about keywords (besides equality). Goh’s def- dard IND-CPA notion with the additional condition that inition does not explicitly require that, even though such left-right queries preserve the number of common equal security may be implied for certain types of schemes. components between any sets of underlying messages. The security definitions for privacy-preserving MACs This is because for functionality we allow a scheme to (IND-DCPA) [25] and efficiently-searchable encryption leak that different messages share keywords. We first [20] require that only equality of plaintexts is leaked. provide the definition and follow with discussion. As are they are not directly suitable for our primitive as we must consider sets of messages and overlaps between Definition A.2 Let ESE = (K ,E ,D,Q) be an them. EDESE scheme with message and keyword spaces MsgSp,KwSp. For b ∈ Σ and adversary A, we de- priv-cpa-b A.3 Our Construction fine the experiment ExpESE (A) similar to ind-cpa-b We now construct an EDESE scheme with message ExpESE (A) except that A has the additional restric- tion: if (m1,m1),...,(mq,mq) are the queries A makes to and keyword spaces MsgSp,KwSp and then prove 0 1 0 1 it secure under the above definition. Let = its LR encryption oracle E (sk,LR(·,·,b)), then SE (K SE ,E SE ,DSE ) be a standard symmetric encryp- i j i j tion scheme with message space MsgSp, where mes- • for all i, j ∈ [q], |m0 ∩ m0|kw = |m1 ∩ m1|kw. sage can also be viewed as sets of keywords. Let M = For an adversary A, define its PRIV-CPA advantage (K ,T ) be a deterministic MAC with message space Σ∗. priv-cpa Let k be an integer parameter. Let encodee,encodeq be against ESE , AdvESE (A), as functions Σ∗ → Σ∗. h i h i priv-cpa-1 priv-cpa-0 We define ESE = (K ,E ,D,Q) as follows. Pr ExpESE (A) = 1 −Pr ExpESE (A) = 1 .

$ M $ SE We say that ESE is private under chosen-plaintext at- • K runs skM ← K and skSE ← K , and re- tacks (PRIV-CPA-secure) if the PRIV-CPA advantage of turns skM kskSE . any adversary against ESE is small. • Esk ksk (m) runs: Remark A.3 Note that the adversary is able to obtain M SE examples of encrypted documents of its choice and Let m = {w1,...,w`}. queries of keywords of its choice, even though it is not Let n be the maximum number of unique keywords given explicit encryption or query oracles. The adversary a message of length |m| can have. can still do the former by querying the left-right encryp- $ k tion oracle on pairs of equal messages and the latter by – If ` < n, then for i ∈ [` + 1,...,n] wi ← Σ querying the same oracle on, say, a pair of equal mes- – ti ← T (wi) for i ∈ [n] sages containing just one keyword. Then by the search- skM ability requirement the resulting ciphertext will contain – t ← encodee(t1,...,tn) the result of the query for this keyword. – Return tkE SE (m). skSE Remark A.4 We do not study chosen-ciphertext secu- • D (c) parses c as tagskc0 and returns rity here as it can be achieved using the encrypt-then- skM kskSE MAC method [26]. I.e., the key includes an additional DSE (c0). skSE

18 • Q (w) = encodeq(T (w)). into an array of size B the probability of a false positive skM kskSE skM δ is 1 − (1 − (1/B))rd)r ≈ (1 − e−rd/B)r [44]. The idea for the construction is simple: we encrypt the We note that our scheme is more more efficient than document with a standard encryption scheme and append that of [44]. To map a keyword to r bits [44] uses r in- MACs of unique keywords in the document. To prevent dependent MAC computations. We, on the other hand, leaking the number of unique keywords we add as many only use one MAC computation and use the pseudoran- “dummy” keywords as needed. domness property to construct an equivalent mapping. We now discuss how to instantiate the encode func- Discussion the concrete instantiation of our construc- tions so that the scheme satisfies the correctness require- tion can be found in Section 4.4. ments. CHOOSING encode FUNCTIONS. We could simply let A.4 Security Analysis the encodee function above to output its inputs in lex- icographical order and encodeq be the identity function. We now state the security result for our scheme. Note that in this case it is easy to see that the construction satisfies the requirements of a EDESE scheme with the Theorem A.6 If M is PRF and SE is IND-CPA- false-positives bound δ corresponding to the probability secure, then ESE is PRIV-CPA-secure. of a queried message colliding with a random k-bit mes- PROOFOF THEOREM A.6 sage or of MACs of two messages being the same, and Let SE = (K SE ,E SE ,DSE ) be a standard sym- this is small due to the standard unforgeability property metric encryption scheme with message space MsgSp, of a MAC scheme. where message can also be viewed as sets of keywords. Now we discuss how to instantiate encode functions Let M = (K ,T ) be a deterministic MAC with message so that ciphertexts get more compact. We introduce some space Σ∗. Let k be an integer parameter. As we men- extra parameters for the scheme: the size of the initially tioned, for simplicity we assume that encodee function empty Bloom filter bit array B and the number of bits in the construction outputs its inputs in lexicographical r being set to 1 for each keyword (these determine the order. Let ESE be as per Construction A.3. rate of false positives as we discuss below). Let p be the For an adversary A we consider a sequence of exper- length of MACs output by the algorithm of . We priv-cpa-0 T M iments, starting with Exp (A) = Exp (A) assume that p ≥ r logB. Let f be an injective function 0 ESE ∗ priv-cpa-1 from [B] to Σ . Then and ending with Exp3(A) = ExpESE (A). 1 1 Let the left-right queries made by A be (m0,m1), q q • encodee(t1,...,tn): 2 2 (m0,m1),...,(m0,m1), where for b ∈ Σ and i ∈ [q] i i,1 i,qbi – for every i ∈ [n] mb = {wb ,...,wb }. Then in Exp (A) the adversary is given ∗ Let h ,...,h be the numbers defined by 0 1 r the MACs and encryptions of {w1,1,..., 1st,...,rth logB-bits of ti resp. 0 w1,n},m1,...,{wq,1,...,wq,n},mq (the MACs are of the ∗ Set h ,...,h ’th bits of Bloom filter array 0 0 0 0 0 1 r keywords in sets and the encryptions of messages, and to 1. the MACs are output in the lexicographical order). And – For all positions p1,..., pv of the Bloom filter in Exp3(A) the adversary is given the MACs and encryp- which are 1, output f (p1),..., f (pv). 1,1 1,n 1 q,1 q,n q tions of {w1 ,..., w1 },m1,...,{w1 ,...,w1 },m1. Now consider experiment Exp (A) which is equivalent • encodeq(ti): 1 to Exp0(A), except that A is given encryptions of – Let h1,...,hr be the numbers defined by “right” messages (and the MACs are still of the “left” 1,1 1,n q,1 q,n q 1st,...,rth logB-bits of ti resp. 1 keywords’: {w0 ,...,w0 },m1,...,{w0 ,...,w0 },m1. – Set h1,...,hr’th bits of Bloom filter array to 1. Clearly, if the difference between probabilities of A outputting 1 in Exp0(A) and Exp1(A) is not small, then – For all positions p1,..., pu of the Bloom filter we can construct adversary B1 breaking IND-CPA secu- which are 1, output f (p1),..., f (pu). ind-cpa rity of SE with equal AdvSE (B1). B1 simply uses its It is easy to see that the scheme is correct. When the own challenge oracle to simulate the encryptions of doc- same keyword is encoded during encryption and query, uments output by A (which must be of the same length its deterministic MAC is mapped the same way to the in each query pair), and simulates the MACs of the key- same set of positions in Bloom filter. If M is a PRF, words (which are the same in both experiments) using then setting the bits to 1 using our method is equivalent the key it creates. to using r independent functions to random bits. After Now we consider experiment Exp2(A) which is equiv- inserting d ≤ |KwSp| distinct keywords using r mappings alent to Exp1(A), except that all keywords which are

19 unique (i.e. are not shared by different documents) are replaced with the corresponding “right” unique key- words. Note that due to the queries restriction in Defini- tion A.2 there are equal number of such unique keywords in the left and right queries (excluding the low proba- bility of collision in dummy keywords). We claim that if the difference between probabilities of A outputting 1 in Exp1(A) and Exp2(A) is not small, then we can eas- ily construct adversary B2 breaking PRF security of M prf with equal AdvM (B2). In fact, IND-DCPA security [25] would be sufficient. B2 would use its own challenge ora- cle to simulate MACs of the keywords (while preserving the equality pattern in its queries) and simulate the en- cryptions of the documents using the key it creates. And of course we could go with the stronger PRF adversary that we need for the efficient encoding. We finally claim that Exp2(A) and Exp3(A) are indis- tinguishable for A or, again, we can easily construct ad- versary B breaking PRF security of M . This is because the only difference is in the MACs of keywords which are shared between several messages. But since the MAC is deterministic, the resulting tags are output in the lexico- graphical order, and because of the restriction on the ad- versary A’s queries, we can see that these keywords un- derlying A’s queries in Exp2(A) and Exp3(A) have the same equality pattern. I.e. if we assume that the key- words in each set are sorted according to the correspond- i, j k, j ing MAC lexicographical positions, then w0 = w0 iff i, j k, j w1 = w1 for i 6= k both ∈ [q] and j ∈ [n]. Then it is easy to construct IND-DCPA adversary who can use its own challenge oracle to simulate the MACs. B3 can do so without violating its restriction on using the oracle, which is for left and right vectors of messages to have the same equality pattern. And of course we could con- struct a stronger PRF adversary. Putting it all together we can see that if there ex- ist an adversary A who can output 1 in Exp3(A) and Exp0(A) so that the difference between the correspond- ing probabilities is not small, and hence, by definition, priv-cpa AdvESE (A) is not small, then we can construct other adversaries B1,B2 with comparable resources such that

priv-cpa ind-cpa prf prf AdvESE (A) ≤ AdvSE (B1)+AdvM (B2)+AdvM (B3), and the statement of the theorem follows.

20