Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

RFID Monotonic Counter Anti-Tearing Defeated - 519

quarkslabPosted 4 Years Ago
  • Radio-frequency identification (RFID) cards are common for scanning for identity reasons, such as school cards or at hospitals. RFID cards do not have power themselves; the reader gives the card the power. So, what happens if a user tears the card away from the reader? Writes may be unfinished, leaving the card in an insecure state!
  • In a previous article, the same authors discussed this as a whole. They discuss the theoretical nature of the attack with EEPROM writes, then move into RFID specific attacks.
  • The original article attacks the ATA5577C RFID writer. This device attempts to protect devices from read/write operations with a password. Using a few different techniques, this security protection was able to be bypassed! In particular, by tearing the RFID card AFTER a clearing operation, only SOME of the bits were flipped. Because of this, some of the security had been defeated.
  • The actual linked above looks into a Monotonic counter that is implemented by MIFARE Ultralight EV1. In this mode, there are three operations: increment count, read the count and read the validity flag. The goal of the attack is to bypass the anti-tearing feature in order to corrupt the counter.
  • The validity flag is presumably written at the same time as a new counter value is written. But, the slot containing the highest value is return for the counter value, as there are multiple slots. The flag determines which slot to take.
  • After doing some testing, the authors noticed that at the limit of a valid flag and reading the counter multiple times that the value being read would be different! But why? One of the bits could be weakly programmed, resulting in a different value being read at different points. If this weakly programmed bit is used in conjunction with a tearing event (corrupted tearing flag), this could cause trouble!
  • The attack works as follows:
    • Have to have a weakly programmed bit at a power of 2. This is done by executing a value that will ROLE this over from 0x100. Hopefully, this will be 0x?00, where the ? is the weakly programmed bit.
    • Increment by a value of 0. At the end of the write operation, we tear this off in order to get the second slot corrupted.
    • Now, the second slot needs to be recovered. Because the second slot is corrupted and part of the first slot is weakly programmed, we hope for a read of 0x000 instead of 0x100. When we increment by 0, this operation happens.
    • With both values stable, the attack has reset
  • The EEPROM volatility via weakly programmed bits, along with a logic bug allowed for this to be possible. The proxmark now has the capability to perform this attack automatically, which is pretty awesome! This is a super interesting piece of research that is hard to pull of but impactful if it works.