Ciphertext-Only Cryptanalysis on Hardened Mifare Classic Cards Extended
Total Page:16
File Type:pdf, Size:1020Kb
Eindhoven University of Technology MASTER Ciphertext-only cryptanalysis on hardened mifare classic cards extended Meijer, C.F.J. Award date: 2016 Link to publication Disclaimer This document contains a student thesis (bachelor's or master's), as authored by a student at Eindhoven University of Technology. Student theses are made available in the TU/e repository upon obtaining the required degree. The grade received is not published on the document as presented in the repository. The required complexity or quality of research of student theses may vary by program, and the required minimum study period may vary in duration. General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain EINDHOVEN UNIVERSITY OF TECHNOLOGY MASTER THESIS Ciphertext-only Cryptanalysis on Hardened Mifare Classic Cards Extended The paradox of keeping things secret Supervisors: Author: dr. ing. Roel VERDULT Carlo MEIJER prof. dr. Boris SKORIC´ A thesis submitted in fulfilment of the requirements for the degree of Master of Science in Information Security Technology Department of Mathematics and Computer Science August 17, 2016 EINDHOVEN UNIVERSITY OF TECHNOLOGY Abstract Faculty of Computer Science Department of Mathematics and Computer Science Master of Science Ciphertext-only Cryptanalysis on Hardened Mifare Classic Cards Extended The paradox of keeping things secret by Carlo MEIJER Despite a series of attacks, MIFARE Classic is still the world’s most widely de- ployed contactless smartcard on the market. The Classic uses a proprietary stream ci- pher CRYPTO1 to provide confidentiality and mutual authentication between card and reader. However, once the cipher was reverse engineered, many serious vulnerabili- ties surfaced. A number of passive and active attacks were proposed that exploit these vulnerabilities. The most severe key recovery attacks only require wireless interaction with a card. System integrators consider such card-only attacks as one of the most seri- ous threat vectors to their MIFARE Classic-based systems, since it allows the adversary to avoid camera detection, which is often present at an access control entrance or pub- lic transport gate. However, all card-only attacks proposed in the literature depend on implementation mistakes which can easily be mitigated without breaking backwards compatibility with the existing reader infrastructure. Consequently, many manufactures and system integrators started to deploy “fixed” MIFARE Classic cards which are resilient to such vulnerabilities. However, these coun- termeasures are rather palliating and inadequate for a cryptographically insecure ci- pher such as CRYPTO1. In support of this proposition, we present a novel cipher-text card-only attack that exploits a crucial and mandatory step in the authentication proto- col and which solely depends on the cryptographic weaknesses of the CRYPTO1 cipher. Hence, in order to avoid this attack, all cards and readers should be upgraded to sup- port an alternative authentication protocol which inherently breaks their backwards compatibility. Our attack requires only a few minutes of wireless interaction with the card, in an uncontrolled environment and can be performed with consumer-grade hardware. The information obtained allows an adversary to drop the computational complexity from 248 to approximately 230, which enabled us to practically recover a secret key from a hardened MIFARE Classic card in about 5 minutes on an single core consumer laptop. iii Acknowledgements This reasearch is conducted as a master thesis for the master Information Security Technology, which is offered by Eindhoven University of Technology. Though, the entire research took place at the Radboud University Nijmegen. This thesis is an extension of the paper [MV15], by myself and Roel Verdult. This thesis contains, among other extensions, proofs of lemmas that were omitted in the original paper due to space restrictions. Furthermore, a number of errors in the paper have been identified and corrected in this thesis. I would like to take the opportunity to thank my supervisor, Roel Verdult. I still remember my first appearance in Roel’s office, exchanging ideas about what an inter- esting research topic. Although I really liked the idea of performing cryptanalysis on hardened MIFARE Classic, I was reluctant since, at that time, I was neither experienced nor skilled in the field of cryptanalysis. However, Roel pointed me to some literature and convinced me to give it a try. Roel’s confidence in my abilities, useful insights and guidance have been crucial ingredients during this research, as well as for my personal development. It has been a great pleasure to work with you, Roel. The next person I would like to thank is Tanja Lange. She was my intended su- pervisor and has supervised me throughout the research. Unfortunately, due to time constraints, I had to switch to Boris Skori´cduring the time when the graduation took place. Although we didn’t see each other much in person during the research, her feedback has contributed immensely to the quality of my paper and this thesis. As for her contribution: I remember the submission deadline for my paper being 1PM, and receiving the last batch of feedback at 6.39AM, so I still had enough time to merge them in the final revision. I think that says it all. Thank you so much. Finally, I would like to thank Boris Skori´c,who helped me a lot getting all the pa- perwork done for my graduation. I first introduced myself about a month before my defense. Thank you so much for your support and the nice and speedy arrangement. The responsible disclosure, giving a talk at a scientific conference, the media at- tention. Working on this research has been a truly unforgettable experience. Thanks everyone involved for making it possible. v Contents Abstract iii Acknowledgementsv 1 Introduction1 1.1 Research Question...............................2 1.2 Contribution...................................2 1.3 Overview.....................................3 2 Related work5 2.1 General Stream Cipher attacks........................5 2.2 Attacks on MIFARE Classic..........................5 2.2.1 Keystream recovery attack.......................5 2.2.2 Genuine reader attacks.........................6 2.2.3 Card-only attacks............................6 3 Background7 3.1 MIFARE Classic cards.............................7 3.2 Memory Structure................................7 3.3 Notation.....................................8 3.4 Cipher and Tag Nonces.............................8 3.5 Authentication Protocol and Initialization..................9 3.5.1 Nested authentication......................... 10 4 Known Vulnerabilities 11 4.1 Short Key Length................................ 11 4.2 Predictable Nonces............................... 11 4.3 The Nested Authentication.......................... 11 4.4 Parity bits.................................... 12 4.5 Keystream leakage through errors...................... 13 4.6 LFSR Rollback.................................. 13 4.7 Odd Inputs to the Filter Function....................... 13 5 Attacking Mifare Classic 15 5.1 Offline Brute Force Attack........................... 16 5.2 Sum Property.................................. 16 5.3 Splitting the Sum property........................... 19 5.4 Determining the sum property at time 8................... 22 5.5 Differential Analysis.............................. 24 5.5.1 Combining two sum properties.................... 25 5.5.2 Combining additional sum properties................ 26 5.6 Filter Flip Property............................... 27 vii 6 Performance analysis 31 7 Conclusion 35 7.1 Recommendations............................... 36 viii List of Figures 3.2.1 Memory layout of a MIFARE Classic card...................7 3.4.1 Structure of the CRYPTO1 stream cipher...................9 4.4.1 The encryption of parity bits.......................... 12 5.3.1 Sum values and probabilities. Probabilities are obtained by averaging over 8192 random cipher states........................ 22 6.0.1 Median leftover complexity.......................... 31 6.0.2 Leftover search space with the correct key................... 32 6.0.3 Number of samples involved in the statistics................ 33 ix List of Tables 1.0.1 The MIFARE Classic compatible cards.....................2 7.0.1 Comparison of card-only attacks....................... 35 xi Chapter 1 Introduction MIFARE Classic cards occupy a considerable part of the contactless smartcard market. Such cards offer, in addition to simple identification, a modest amount of memory and cryptographic capability, making them suitable for applications such as access control and fare collection systems. The MIFARE Classic cards are still widely deployed in many public transport pay- ment systems. Examples of such systems include the Oyster Card1 in London, the Charlie Card in Boston2, the EasyCard in Taiwan3, and the OV-chipkaart in the Nether- lands4. In addition to public transport, it is also still used for contactless access control systems, integrated in many office buildings, including even high-security