Attacks on public transportation tickets have been around for a number of years. Two Italian students were able to lock a single use ticket and continually use it on the Turin public transit system. After reading through the research, I decided to try find out if Singapore's public transit fare system is vulnerable to a similar exploit.
The EZ-Link standard ticket is a single use ticket for the MRT system in Singapore. The standard ticket is only valid for a single day. However, commuters can get a refund for their unused tickets from any passenger service centre within 3 days of purchase of the ticket. In an effort to reduce wastage, the single ticket can also be topped up and used for up to 6 trips within 30 days.
Upon scanning the standard ticket with an NFC reader, I discovered that the card used is Mifare Ultralight, which is same as that used in the Turin system. Mifare Ultralight does not support any form of encryption or access control, hence it is possible to obtain a card dump.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Upon consulting the Mifare Ultralight specifications, I realised that the standard ticket worked differently from the Turin system. The attack on the Turin system involved locking the bits in the OTP page so they cannot be turned on or off, however the OTP page on the standard ticket was already permanently locked. Hence, the EZ-Link system must rely on a different method. At a cursory glance, I was unable to find the date of purchase, 13 June, nor the $1.50 stored value anywhere on the card. I needed more samples so I decided to acquire a second card and dump both cards in new and spent state.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
I wanted tickets that differed in only 1 attribute, in this case, the date, so I could identify which bits were flipped, which would indicate the page where the date was stored. The tickets were bought from the same dispensing machine, hence the similar ID numbers.
Comparing the dumps, it became obvious that page 10 to 14 (Line 14-18) is used to store the data. However, a difference in only 1 attribute resulted in a significant difference in data. 13 June looked completely different from 14 June. $1.50 looked completely different from $0. In other words, the cipher used exhibited very good diffusion properties.
XOR cipher
We will start with the low hanging fruit first, the XOR cipher. When the key of the XOR cipher is as long as the plaintext, we get a one time pad which exhibits good randomness. The card ID, OTP and the last page is ruled out because they are too similar, hence given that the plaintext is similar, they will produce similar looking ciphertexts. The only candidate key is page 4 to 8 (Line 8-12). It is 160 bits long, exactly the same length as the plaintext and card #1 has a very different value compared to card #2. Unfortunately, the XORed result did not display any correlation.
3DES cipher
Moving on, I realised that the card UID is exactly 56 bits, which is the effective keysize for DES. Using a script which I wrote, I expanded the key and used it to perform both DES-CBC and 3DES-CBC(DDD) decryption. DED is the preferred mode, most likely used in CEPAS as well, but with only 1 key, DED mode would be equivalent to DES. The results were similarly unspectacular.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Time for more research. NXP publishes a document which provides implementation "hints". One of the tips include the use of a 128 bit Master Key which is encrypted with the card UID to produce 3 card keys which is used for 3DES(DED) decryption. The document also describes the use of zero padding and a default IV of 0s. In a last ditch attempt, I decided to follow the "hints" as closely as possible. Since I did not have a Master Key, I zero padded page 4 to 8 and used it in place of the Master Key. No dice. Looks like the crypto is sound.
1 2 3 4 5 6 7 |
|
Pass the (EZ-Link Standard) ticket attack
The pass-the-ticket attack is based off the pass-the-hash attack, the idea being that if you cannot crack the hash, you simply forge a request and include the hash within. It is perfect for use with the Mifare Ultralight because the card does not contain a chip. It cannot perform a challenge response, or include a unique nonce or timestamp for each request. Therefore, it is trivial to perform a replay attack. In order to exploit the system, dump page 10 to 14 into a file. Go up to the passenger service centre and ask for a refund. Once out of sight, clone page 10 to 14 back onto the card. Go and ask for another refund at a different counter. Profit.
With more than 100 MRT stations in Singapore, there is more than enough to rotate around. A single card with round trip fare can store up to $6+, assuming you refund 3 card per station (to avoid suspicion), it is $18/station. Assuming you can visit 5 stations in an hour, it is a cool $90/hour in cash. Some stations have multiple centres due to multiple exits or it being an interchange with multiple lines. Further Profit. Don't forget, you also get to travel for free by reloading a 4th card and using it for personal travel.
The only equipment required is an Android phone with an NXP NFC chipset. A list of compatible phones has been provided here. There are many apps out there which allow reading and writing to Mifare Ultralight cards.
Proof
EZ-Link Golden Ticket
Inspired by the Kerberos golden ticket, a hypothetical EZ-Link golden ticket would allow unlimited travel for free. The cipher will first need to be broken, so it is impossible as of now. You will then need to get hold of a blank Mifare Ultralight card. Write in the data as necessary. Lock page 10 to 14. The card can now be used for free for today. For tomorrow, unlock pages 10 to 14, write in new data, and relock the pages. Make sure not to lock the block locking bits or you will not be able to unlock the pages anymore. For convenience, an app could perform the necessary computation, unlocking and relocking at the touch of a button. This is assuming the reader at the gantry does not verify the state of the locking bits.
Conclusion
While the EZ-Link standard ticket is not vulnerable to a golden ticket attack as was the case in the Turin exploit, it is vulnerable to a pass-the-ticket attack. The pass-the-ticket attack is usually less severe than the golden ticket attack. However, in this particular case, EZ-Link allows for the refund of the tickets. This increases the severity of the attack since attackers can now extract cash from the system, cash that can be spent not only on transportation, but on food, entertainment or elsewhere.