Source-linked AI summary
A Practical Attack on the MIFARE Classic
Gerhard de Koning Gans, Jaap-Henk Hoepman, Flavio D. Garcia
TL;DR
MIFARE Classic is widely deployed despite relying on a proprietary, undisclosed protocol and cipher, motivating a practical security analysis. The paper studies its communication and architecture, then exploits a pseudo-random-generator weakness to recover CRYPTO1 keystream and read or modify protected memory. The attack fully compromises sector zero and extends to other sectors when limited plaintext or block knowledge is available.
Problem
MIFARE Classic is widely used for access control and other applications, but its proprietary protocol and cryptographic design require practical security evaluation.
Method
The authors analyze card-reader communication with a Proxmark III and exploit a pseudo-random-generator weakness to recover CRYPTO1 keystream without the encryption key.
Results
The attack reads all memory blocks in sector zero without the secret key and reads or modifies other sectors when one block is known.
Takeaways & Limitations
Stored data should not be considered secret, and its integrity and authenticity can no longer be relied on, although the secret keys remain unrecovered.
Takeaways & Limitations
Higher-sector attacks can leave a four-byte gap because key B is often unreadable, and long-term countermeasures require migration to cards with open designs.
Abstract
from arXiv · showhide
The MIFARE Classic is the most widely used contactless smart card in the market. Its design and implementation details are kept secret by its manufacturer. This paper studies the architecture of the card and the communication protocol between card and reader. Then it gives a practical, low-cost, attack that recovers secret information from the memory of the card. Due to a weakness in the pseudo-random generator, we are able to recover the keystream generated by the CRYPTO1 stream cipher. We exploit the malleability of the stream cipher to read all memory blocks of the first sector of the card. Moreover, we are able to read any sector of the memory of the card, provided that we know one memory block within this sector. Finally, and perhaps more damaging, the same holds for modifying memory blocks.
1 Introduction
The paper examines the widely deployed MIFARE Classic, whose proprietary security is important for many access-control applications but may be undermined by weaknesses in its pseudo-random generator. Using a Proxmark III, the authors recover CRYPTO1 keystream information and demonstrate practical reading and modification attacks.
- Motivation and system: Contactless cards support payment, passports, vehicle keys, and access control, making their security relevant across high-profile applications.Examples include public-transport cards, electronic passports, car keys, offices, airports, and military bases.
- Motivation and system: Wireless access lowers maintenance costs and reading times but introduces privacy threats and susceptibility to relay, replay, and skimming attacks.
- Motivation and system: MIFARE Classic is the most widely used contactless card and relies on proprietary CRYPTO1 for mutual authentication and data secrecy.The paper focuses on cards with 320B, 1KB, and 4KB memory sizes.
- Approach: The authors independently identify a pseudo-random-generator weakness and implement ISO 14443-A support on a Proxmark III to analyze and attack cards.The firmware supports reader-to-tag and tag-to-reader communication at physical and higher protocol levels.
- Consequences: The attack recovers all secret information in sector zero within minutes and can modify information there, while extending to most remaining-sector data depending on the scenario.The recovered plaintext also supports a separate brute-force attack on the keys, which the authors describe as ongoing work.
2 MIFARE Classic
MIFARE Classic is a memory card organized into sectors and protected by authentication, access conditions, and encrypted communication. Its protocol combines ISO 14443 components with a proprietary encrypted layer and supports data, value-block, and authentication operations.
- Communication layer: MIFARE Classic uses ISO 14443 type A for communication, while its high-level command protocol differs from the standard and remains proprietary.The card performs authentication before encrypting subsequent communication.
- Logical structure: Memory is divided into 16-byte blocks grouped into sectors, with sector layouts varying between the 1KB and 4KB cards.A 4KB card has 32 four-block sectors and 8 sixteen-block sectors; each sector ends with a trailer.
- Logical structure: Sector trailers store secret keys and access conditions that determine which operations are permitted.Key A is never readable, while key B may be configured as readable; a remaining byte has no defined purpose.
- Commands and access: Data blocks can hold arbitrary data or value blocks, while commands support reading, writing, incrementing, decrementing, restoring, and transferring values subject to access checks.Value blocks store signed values redundantly and use a block address as a pointer.
- Security features: The card encrypts communication with the proprietary CRYPTO1 stream cipher and uses 48-bit symmetric keys stored in sector trailers.
- Authentication: Authentication begins with a card-generated 32-bit nonce, followed by an encrypted reader response containing reader randomness and a final card response.The paper uses the initial card nonce as the relevant authentication information for its attack.
3 Hardware and Software
The authors use the Proxmark III to eavesdrop on MIFARE Classic transactions and act as a reader, implementing the required ISO14443-A functionality across physical and higher protocol layers.
- The MIFARE Classic reader uses a closed-design microchip to communicate with application software and execute commands.
- The Proxmark III supports signal processing at both low and high frequencies and routes antenna signals through an FPGA.
- The Proxmark III was configured to eavesdrop on transactions and communicate with cards as a MIFARE reader.
- The authors implemented ISO14443-A processing and generation for reader-to-tag and tag-to-reader communication.
4 Communication Characteristics
The authors characterize MIFARE Classic communication through recorded traces, identifying anticollision, authentication, encrypted commands, timing units, and encrypted parity behavior.
- Recorded traces represent reader messages as PCD and card messages as TAG, using hexadecimal notation and ETUs for timing.One ETU equals 1.18µs, and incorrect encrypted parity appears as an exclamation mark.
- Anticollision: The anticollision procedure begins with the reader sending 93 20, after which the card returns its unique identifier.The reader then sends 93 70 with the UID and two CRC bytes to select the card.
- Authentication: Authentication messages #7 to #10 establish authentication before higher-layer commands are handled.An authentication request beginning with 60 uses key A, while 61 indicates key B; the second byte identifies the target block.
- Encrypted parity bits can appear as parity errors in recorded messages.
- Encrypted Communication: After authentication, encrypted commands include operations such as increment followed immediately by a read command.
5 Weakness in MIFARE Classic
The paper extends prior CRYPTO1 analysis by exploiting a weak MIFARE Classic nonce generator, whose repeated nonces make practical keystream recovery and offline key attacks possible.
- The attack uses the weak card-side pseudo-random generator and treats CRYPTO1 as a bitwise stream cipher without requiring its full algorithm.
- About 600,000 nonces could be requested per hour, with a nonce reappearing at least about four times within one hour.
- The nonce generator is an LFSR shifting every 9.44µs, allowing theoretical nonce repetition after 0.618s at precisely timed queries.
- Timing nonce requests after power-up reduced the observed nonce set to ten different values and shortened the waiting time.
- Without the cryptographic algorithm, exhaustive online key search would take 16,289,061 days, or about 44,627 years.
6 Keystream Recovery Attack
The attack replays a recorded authentication, recovers keystream segments from known plaintext, and exploits stream-cipher malleability to read sector zero without the secret key.
- The attack requires possession of the card, control of a Proxmark reader, and a recorded transaction whose nonce can be reproduced.
- The procedure modifies an encrypted command so the card returns a response with known plaintext, then derives corresponding keystream segments.
- Keystream Recovery: Because stream-cipher plaintext is XORed with the keystream, reusing that keystream with known plaintext reveals the encrypted counterpart.
- A weak pseudo-random generator lets the card repeat a nonce, enabling replay of an earlier recorded transaction.
- Keystream Mapping: Parity handling requires removing keystream bits used at parity positions before mapping the remaining keystream onto new messages.
- Authentication Replay: A recorded successful authentication can be replayed by waiting for the same nonce, resending the recorded response, and retrieving the card's challenge response.
- Reading Sector Zero: Sector zero can be read without its key because known manufacturer data recovers keystream information from block 0 and the sector trailer.
- Reading Sector Zero: When access conditions show that key B is unreadable, the resulting zero plaintext reveals the whole sector trailer and therefore sector zero.
7 Reading Higher Sectors
Higher sectors lack the manufacturer data available for sector zero, limiting keystream recovery. Key B is usually unreadable, leaving a four-byte gap, though compromise remains possible.
- Higher sectors lack the manufacturer data available for sector zero, so fewer plaintext and keystream bytes are known.The sector trailer and unknown data blocks are available instead.
- Key A always provides 10 keystream bytes, while unreadable Key B usually provides six more.This leaves a four-byte gap consisting of AC and U.
- A four-byte gap remains because Key B is usually unreadable, leaving AC and U unrecovered.
- Although harder to achieve, compromising higher sectors remains a potential threat.
8 Conclusions & Recommendations
The attack recovers keystream and command information that enables unauthorized reading and modification of MIFARE Classic memory without the secret key. The authors recommend short-term mitigations but ultimately advise migration to cards with open designs.
- The attack recovered keystream from a recorded genuine transaction and enabled operations as if the secret key were known.
- All sector-zero memory blocks were read without the secret key, and any sector could be read when one block within it was known.After recording a valid transaction, the attack also recovered portions of blocks in a sector and could modify sector information.
- Data stored on the card, except the keys themselves, should no longer be considered secret.The authors note that the attack does not clone cards because the secret keys remain secret.
- The integrity and authenticity of stored data can no longer be relied on, allowing electronic-purse values or loyalty levels to be changed.
- Known plaintext or keystream is necessary for brute-force or more sophisticated attacks aimed at recovering secret keys.The authors report progress toward recovering arbitrary sector keys.
- Short-term recommendations include avoiding secret information in sector zero, making Key B readable, and protecting sensitive data and modifications.Additional measures include multiple authentications, backoffice encryption, and extra authentication for data blocks.
- Backoffice fraud detection and security features provide a second line of defense for data collected from readers.
- Long-term countermeasures are insufficient, so the authors recommend migrating to cards with an open design architecture.