RFIDThief

Man-in-the-middle device for attacking RFID access control systems

2022Security ResearchEmbedded SystemsGitHub

Overview

RFIDThief is a man-in-the-middle device for RFID access control systems. It sits on the physical wiring between a card reader and door controller, intercepts credentials as they are transmitted, and allows an attacker to remotely sniff, replay, or deny service to the door controller. My teammate John Dale and I built the device during the 36-hour Hack UMass hackathon in the Fall of 2022. We won first place out of 600+ attendees.

We targeted the Wiegand protocol, the wiring standard still used in most RFID access systems worldwide. Wiegand is a straightforward protocol, and is used to transmit plaintext card IDs from readers to door controllers. Instead of demonstrating our device on a physical door, we built a model door controller and card reader for the hackathon. We demonstrated the failure modes of Wiegand through several exploits, and showed how adding a second factor of authentication (in our case, a fingerprint reader) could mitigate the attack. Even with additional authentication modes, our system is still able to deny service to legitimate users.

RFIDThief

Background

A typical RFID access control system looks like this: you tap an RFID card on a wall reader, the reader extracts a unique card ID (via either an unencrypted or encrypted channel), and that ID gets sent over a run of wire to a controller that decides whether to unlock the door based on your card ID.

While early low-frequency (125 kHz) RFID systems communicated unencrypted card IDs to readers, modern systems use high-frequency (13.56 MHz) technology and encrypt the card ID. Less expensive implementations use public key encryption, while more expensive solutions use private key encryption.

While card encryption has come a long way in the hopes of deterring wireless sniffing, the physical protocol these systems use to communicate with door controllers has not. Wiegand has been the dominant protocol for decades, for its simplicity and reliability along long distances. Most major RFID reader manufacturers still offer Wiegand on all of their products, even their most expensive private key encrypted readers. The beauty of this is that you can entirely bypass the wireless channel and attack the physical one instead, even when RFID cards and readers have the most advanced encryption.

In the below pinout, all logic lines are +5V while the reader power is +12V. D0 and D1 correspond to Wiegand card data sent from the reader to the controller. The controller writes to the red and green lines to control the reader LED color, as well as the buzzer to play tones. An additional tamper line changes state when the reader is taken off of its mount — this is typically an optical sensor in HID readers. This tamper line is the reader's first and only defense against Wiegand sniffing, but most installations don't wire it or have real-time monitoring to do anything about it.

Wiegand Reader Pinout

Access control vendors now recommend newer protocols like OSDP (which in its default mode disables encryption, truly groundbreaking stuff) for installations with high security requirements, but most deployments still use Wiegand. There is a high cost associated with switching from Wiegand to OSDP: OSDP uses RS-485, which requires shielded twisted pairs. Most Wiegand installations do not use shielded twisted pairs, so these runs would need to be fully replaced, potentially across hundreds of feet.

Wiegand is a one-way street. Card IDs are sent asynchronously whenever a card is presented to the reader. There is no way to ping the reader, or identify a legitimate reader from a malicious one. The data is sent on two lines, DATA0 and DATA1. A high voltage on the D0 line indicates a '0', and the same for the D1 line. It's dead simple — there is no clock, no parity bit or checksum. There is no authentication between the reader and the panel, and all card IDs are transmitted as plaintext.

Wiegand Protocol

It's also incredibly slow — the pulse width typically ranges from 50 to 100 µs, and the pulse interval from 1ms to 2ms. This makes it very easy to bit bang with a microcontroller! Here is what a Wiegand trace looks like for a 32-bit card ID. You can see how short the pulse durations are compared to the pulse intervals.

Wiegand Protocol

Now that you understand Wiegand, you can see how easy it is to break!

System Architecture

We built a full demo stack so we could attack the system remotely. We didn't have access to a real reader or access controller at the time of the hackathon, so we built our own. Here are the components of the system as used in our demo:

  1. Reader: an RFIDuino Shield on top of an Arduino that scans 125 kHz tags and bit-bangs the card ID out as a 32-bit Wiegand frame.
  2. MITM: a Wi-Fi-connected ESP8266 that sits in the middle, listens to the reader's Wiegand lines with GPIO interrupts, optionally rewrites the ID, logs everything to a web server, and forwards a Wiegand frame to the controller.
  3. Controller: a Wi-Fi-connected ESP8266 acting as the access control panel. It decodes the incoming Wiegand bits, checks them against an allowlist, and drives an RGB LED and buzzer to indicate whether the card is authorized or not.
  4. Fingerprint Sensor: a GT-511C3 fingerprint sensor connected to its own Wi-Fi-connected ESP8266. Used to mitigate the attack by forwarding fingerprint matches to the controller server.

The ESPs all communicate with a server hosted on Adafruit IO. Captured input/output IDs show up on a live dashboard, and attack modes can be toggled remotely from that same interface.

Attacks

Sniffing

The MITM attaches falling-edge interrupts on DATA0 and DATA1 and fills a 32-bit buffer as pulses arrive. Once a full frame is in, it converts the bitstring to an integer, publishes the captured ID to the web server, and decides what to send downstream based on its current mode.

Spoofing

Because the MITM owns the link to the controller, it can substitute IDs before forwarding them. We hardcoded a small remapping table for the demo:

  • A known good badge passes through unchanged
  • A known bad badge stays bad
  • A third "malicious" badge gets rewritten into the good ID on the way out

From the controller's point of view, the attacker just presented a valid card. From the reader's point of view, nothing unusual happened. That substitution attack is what makes a wiring MITM worse than a simple eavesdrop.

Replay

Captured credentials do not have to be used immediately. From the web dashboard we could trigger a replay based on previously captured credentials, which made the MITM bit-bang a stored valid ID onto the controller lines with no card on the reader at all. Once you have sniffed one authorized badge, you can remotely unlock the door on demand.

Denial of Service

A second cloud toggle puts the MITM into DoS mode. Instead of forwarding real card data, it sends all-zero frames to the panel on any card read. Legitimate badges stop unlocking the door until the mode is turned off. This mode bypasses our mitigation completely.

Mitigation

To show a practical mitigation, we added a fingerprint sensor that doesn't use any physical data wires. It reads fingerprint data and transmits fingerprint hashes over the cloud to the web server, where the controller checks for a match before granting access.

Legacy low-frequency (125 kHZ) RFID systems, marketed by HID as Prox, transmit card IDs in plaintext to the reader. Wiegand works the same way, but on the physical layer. HID has publicly acknowledged that systems with two authentication modes are the only way to secure Prox systems, but the same logic applies to Wigeand:

“While we acknowledge that it may be possible, under certain conditions, to clone some proximity cards, we believe access control systems that use Prox are secure when they are combined with proper procedures and policies, and where necessary, additional layers of security such as surveillance cameras, keypad readers and/or fingerprint readers, to name a few." - Former HID CEO Denis R. Hébert.

By using a second independent path for the fingerprint data, in this case an encrypted network, we eliminate the single point of physical failure that is Wiegand.

Recognition