Automated Verification for Secure Messaging Protocols and Their
Total Page:16
File Type:pdf, Size:1020Kb
Automated Verification for Secure Messaging Protocols and Their Implementations: A Symbolic and Computational Approach Nadim Kobeissi, Karthikeyan Bhargavan, Bruno Blanchet To cite this version: Nadim Kobeissi, Karthikeyan Bhargavan, Bruno Blanchet. Automated Verification for Secure Mes- saging Protocols and Their Implementations: A Symbolic and Computational Approach. 2nd IEEE European Symposium on Security and Privacy , Apr 2017, Paris, France. pp.435 - 450, 10.1109/Eu- roSP.2017.38. hal-01575923 HAL Id: hal-01575923 https://hal.inria.fr/hal-01575923 Submitted on 21 Aug 2017 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Automated Verification for Secure Messaging Protocols and their Implementations: A Symbolic and Computational Approach Nadim Kobeissi Karthikeyan Bhargavan Bruno Blanchet INRIA Paris INRIA Paris INRIA Paris Abstract—Many popular web applications incorporate end-to- for application-specific messaging patterns and deployment end secure messaging protocols, which seek to ensure that constraints. Such custom protocols deserve close scrutiny, messages sent between users are kept confidential and authen- but their formal security analysis faces several challenges. ticated, even if the web application’s servers are broken into First, web applications often evolve incrementally in an or otherwise compelled into releasing all their data. Protocols ad hoc manner, so the embedded cryptographic protocol that promise such strong security guarantees should be held up is only ever fully documented in source code. Even when to rigorous analysis, since protocol flaws and implementations protocol designers or security researchers take the time to bugs can easily lead to real-world attacks. create a clear specification or formal model for the protocol, We propose a novel methodology that allows protocol these documents are typically incomplete and quickly go designers, implementers, and security analysts to collabora- out-of-date. Finally, even if the protocol itself is proved to tively verify a protocol using automated tools. The protocol be secure, bugs in its implementation can often bypass the is implemented in ProScript, a new domain-specific language intended security guarantees. Hence, it is not only important that is designed for writing cryptographic protocol code that to extract a model of the protocol from the source code and can both be executed within JavaScript programs and auto- analyze its security, it is essential to do so in a way that the matically translated to a readable model in the applied pi model can evolve as the application is modified. calculus. This model can then be analyzed symbolically using In this paper, we study the protocol underlying the ProVerif to find attacks in a variety of threat models. The Signal messaging application developed by Open Whisper model can also be used as the basis of a computational proof Systems. Variants of this protocol have also been deployed using CryptoVerif, which reduces the security of the protocol within WhatsApp, Facebook Messenger, Viber, and many other popular applications, reaching over a billion devices. to standard cryptographic assumptions. If ProVerif finds an The protocol has been known by other names in the past, attack, or if the CryptoVerif proof reveals a weakness, the including Axolotl, TextSecure (versions 1, 2, and 3), and protocol designer modifies the ProScript protocol code and it continues to evolve within the Signal application under regenerates the model to enable a new analysis. the name Signal Protocol. Until recently, the main docu- We demonstrate our methodology by implementing and mentation for the protocol was its source code, but new analyzing a variant of the popular Signal Protocol with only specifications for key components of the protocol have now minor differences. We use ProVerif and CryptoVerif to find been publicly released.1 new and previously-known weaknesses in the protocol and Signal Protocol has ambitious security goals; it enables suggest practical countermeasures. Our ProScript protocol asynchronous (zero round-trip) authenticated messaging be- code is incorporated within the current release of Cryptocat, tween users with end-to-end confidentiality. Each message is a desktop secure messenger application written in JavaScript. kept secret even if the messaging server is compromised, and Our results indicate that, with disciplined programming and even if the user’s long term keys are compromised, as long some verification expertise, the systematic analysis of complex as these keys are not used by the attacker before the target cryptographic web applications is now becoming practical. message is sent (forward and future secrecy.) To achieve these goals, Signal uses a novel authenticated key exchange 1. Introduction protocol (based on mixing multiple Diffie-Hellman shared secrets) and a key refresh mechanism (called double ratch- Designing new cryptographic protocols is highly error- eting). The design of these core mechanisms in TextSecure prone; even well-studied protocols, such as Transport Layer version 2 was cryptographically analyzed in [2] but the Security (TLS), have been shown to contain serious protocol protocol has evolved since then and the security of Signal as flaws found years after their deployment (see e.g. [1]). it is currently implemented and deployed remains an open Despite these dangers, modern web applications often em- question. bed custom cryptographic protocols that evolve with each In fact, although they all implement the same core release. The design goal of these protocols is typically protocol, different implementations of the Signal protocol to protect user data as it is exchanged over the web and synchronised across devices, while optimizing performance 1. https://whispersystems.org/docs/specifications/x3dh/ 1 vary in important details, such as how users are identified model in the applied pi calculus (x4). Model extraction and authenticated, how messages are synchronised across enables formal verification to keep up with rapidly changing devices, etc. We seek to develop and analyze one such source code. Readable models allow the protocol analyst variant that was recently incorporated into Cryptocat, a desk- to experiment with different threat models and security top messaging application developed by one of the current goals and to test new features before including them in the authors. We call this variant SP in the rest of this paper. We implementation. develop a detailed model for SP in the applied pi calculus A Symbolic Security Analysis of SP. We formalize and and verify it using the ProVerif protocol analyzer [3] for analyze a variant of Signal Protocol for a series of security these security goals against adversaries in a classic Dolev- goals, including confidentiality, authenticity, forward secrecy Yao model [4]. We also develop a computational proof for and future secrecy, against a classic symbolic adversary (x5). SP using the CryptoVerif prover [5]. There remains the Our analysis uncovers several weaknesses, including previ- challenge of keeping our models up-to-date as the protocol ously unreported replay and key compromise impersonation code evolves within Cryptocat. To this end, we design a attacks, and we propose and implement fixes which we then model extraction tool that can compile the protocol source also verify. code to the applied pi calculus. A Computational Cryptographic Proof for SP. We present Signal has been implemented in various programming proofs of message authenticity, secrecy and forward secrecy languages, but most desktop implementations of Signal, for SP obtained using the CryptoVerif computational model including Cryptocat, are written in JavaScript. Although prover [5]. (x6) JavaScript is convenient for widespread deployability, it is not an ideal language for writing security-critical applica- A Verified Protocol Core for Cryptocat. We integrate our 2 tions. Its permissive, loose typing allows for dangerous im- verified protocol code into the latest version of Cryptocat plementation bugs and provides little isolation between ver- (x7), a popular open source messaging client with thousands ified cryptographic protocol code and unverified third-party of users that is developed and maintained by one of the components. Rather than trying to verify general JavaScript authors of this paper. We show how the new architecture of programs, we advocate that security-critical components like Cryptocat serves to protect the verified protocol code from SP should be written in a well-behaved subset that enables bugs in the rest of the application. formal analysis. We introduce ProScript (short for “Protocol Script”), 2. A Security Model for Encrypted Messaging a programming and verification framework tailored specif- ically for the implementation of cryptographic protocols. We consider a simple messaging API as depicted below. ProScript extends Defensive JavaScript (DJS) [6], [7], a An initiator A can start a conversation with B by calling static type system for JavaScript that was originally de-