Tag: Sub-GHz

  • Flipper Zero, part 3: Sub-GHz remotes, rolling codes and how gates should be built

    Flipper Zero, part 3: Sub-GHz remotes, rolling codes and how gates should be built

    Part 3 of 5 in the Flipper Zero series. Part 1: what it actually is and what it can’t do. Part 2: why so many office badges are weaker than they look.

    Garage doors, gates, car fobs, doorbells and cheap alarm sensors all talk on a handful of license-free bands. Depending on where you live, that’s mostly 315, 433.92, 868 and 915 MHz. The Flipper Zero’s CC1101 transceiver covers 300 to 348, 387 to 464 and 779 to 928 MHz, with regional limits on where it’s allowed to transmit. That makes it a handy way to look at your own remotes and ask whether the thing guarding your driveway was designed by someone who had ever met an attacker.

    Same rules as the earlier parts: my own device, my own remotes, and a defender’s goal. Transmitting captured codes at a gate or car you don’t own is illegal in most places, and the receiver you’re testing may belong to a landlord or an employer. Get permission first.

    What the Flipper shows you

    The Sub-GHz menu has Read, Read RAW, Saved and Add Manually. Read tries to decode a signal against the protocols it knows and prints the frequency, modulation and bits. Read RAW records the pulse timing without interpreting it.

    Here’s my Flipper’s main menu with Sub-GHz selected, followed by the Sub-GHz submenu.

    Flipper Zero main menu with Sub-GHz highlighted
    Flipper Zero Sub-GHz submenu: Read, Read RAW, Saved, Add Manually

    Press a cheap fixed-code remote near it and the Flipper shows the same bits every time. Press a rolling code remote and the bits change on every press. Seeing that on your own remote takes about ten seconds and teaches more than any slide.

    Fixed codes: nothing to defend

    Old remotes with DIP switches, and the cheapest 433 MHz clones, send the same code on every press. Anyone who hears it once can send it forever. There’s no cryptography to attack, and that’s the whole problem. If your gate still uses one, replace the receiver and remotes. No setting makes a fixed code safe.

    Rolling codes: what they are

    A rolling code remote sends a serial number and a counter, protected so the receiver can check that the counter has moved forward. The best known design is Microchip’s KeeLoq. It uses a 32 bit block cipher with a 64 bit key and 528 rounds. The hopping part of the message carries a 16 bit synchronisation counter, and the serial number goes out in the clear beside it. In the common learning schemes, the per-remote key is derived from the serial number and a manufacturer key.

    That last detail is where the trouble started. Several groups published cryptanalysis of KeeLoq in 2007 and 2008. In 2008, Eisenbarth and colleagues presented “On the Power of Power Analysis in the Real World” at CRYPTO. They used power analysis on the receiver side to extract the manufacturer key. With that key, anyone who hears one transmission from a remote can compute its key from the serial number. That breaks the whole product family, not just one gate.

    Receivers also have to tolerate lost presses. Say you pressed the button in your pocket twice while out of range. The receiver has to accept counter 5 after seeing counter 2, so it accepts any value inside a look-ahead window. Here’s a toy model of that logic. It isn’t KeeLoq. It uses HMAC-SHA256 truncated to 4 bytes, but the receiver behaviour has the same shape:

    import hmac, hashlib
    
    KEY = b"per-remote-secret"
    WINDOW = 16
    
    def code(counter):
        msg = counter.to_bytes(4, "big")
        return hmac.new(KEY, msg, hashlib.sha256).digest()[:4].hex()
    
    class CounterReceiver:
        def __init__(self):
            self.last = 0
        def press(self, c):
            for n in range(self.last + 1, self.last + 1 + WINDOW):
                if hmac.compare_digest(code(n), c):
                    self.last = n
                    return f"OPEN (counter {n})"
            return "rejected"

    Jam and capture

    Samy Kamkar showed the practical weakness at DEF CON 23 in 2015 with a device he called RollJam. The attacker jams the receiver and records the owner’s press at the same time. The owner presses again. The attacker jams and records that press too, but this time releases the earlier code to the receiver, so the door opens and the owner has no reason to think anything happened. The attacker now holds a valid code the receiver has never seen.

    The diagram compares the two receiver designs.

    Sequence diagram comparing a counter-only receiver, where jammed and recorded codes open the gate twice, with a challenge-response receiver, where a recorded answer fails against a fresh nonce. Annotation boxes added for explanation.

    The core problem is that a counter-only receiver has no idea when a code was made. A code from yesterday is as good as one from a second ago, as long as the counter hasn’t passed it. I ran the toy model through the scenario and the output is below. My script generates the jammed presses, so this simulates the logic and doesn’t capture a real remote.

    Terminal output of the toy rolling code receiver showing a replay rejected, a jam-and-capture attack succeeding twice, and a challenge-response receiver rejecting a captured answer

    Look at the third line of the middle block. The receiver accepts the stored second code long after the owner walked off. The stored code only works once, since replaying it afterwards fails, but one use is enough to open a gate.

    Counter windows have caused real vulnerabilities too. CVE-2021-46145 covers the Honda Civic 2012 key fob, where the rolling code doesn’t expire and the counter resynchronisation can be abused to replay unlock commands. CVE-2022-27254 is a worse case on the 2018 Civic, where the remote sends the same signal for every unlock request, so it was never rolling at all.

    How a gate should be built

    If I were specifying a new gate or garage opener, I’d require four things.

    First, the receiver should reject codes older than a few seconds, or use challenge-response. In the last block of the demo, the receiver sends a random nonce and the remote answers with an HMAC of it. A captured answer fails against the next nonce, so storing it gains nothing. This needs a two way radio, which costs a little more, and that’s the price of getting rid of the stored-code attack.

    Second, use a modern authenticated protocol with a per-device key that isn’t derived from a shared manufacturer secret. AES-based systems exist. Ask the installer what the remote actually uses. If the answer is “rolling code” with no name attached, treat it as a fixed code until proven otherwise.

    Third, keep the radio the weaker half of the system. A gate that opens on a single radio message shouldn’t also be the only barrier to anything you care about. Put cameras on it, put a lock on the inner door, and don’t rely on it to separate a vehicle from the street.

    Fourth, plan to replace the remotes. Lost ones should be removed from the receiver, not just forgotten, so choose a receiver that lets you delete individual remotes.

    Testing your own gear

    With the Flipper you can check three things on your own remote. Does Read decode it as a known protocol, or do you get raw pulses only? Do the bits change between presses? If they don’t, you have a fixed code and a replacement project. And can you find the manufacturer and model on the receiver, so you can read its actual security claims instead of guessing?

    I wouldn’t go further than that with equipment I don’t control.

    Part 4 moves to USB, keystroke injection from the Bad USB menu, and how to lock endpoints down.

    Other parts of the Flipper Zero series: part 1, part 2, part 3, part 4, part 5.

  • Flipper Zero, part 1: what it actually is and what it can’t do

    Flipper Zero, part 1: what it actually is and what it can’t do

    Part 1 of 5 in the Flipper Zero series.

    I own a Flipper Zero, and the first thing that struck me was how ordinary the insides are. Some people treat it as a skeleton key, others wave it off as a toy. Both are wrong. If you are responsible for doors, badges or wireless gear, it helps to know which parts of the legend are true, because the bad habits it exposes are very old ones.

    This series covers it from the defender’s side, on hardware I own, and nothing here is a how-to for getting into other people’s property. Later parts cover access cards, Sub-GHz remotes, USB keystroke injection and the Wi-Fi dev board.

    A small computer with a lot of radios

    The Flipper Zero comes from Flipper Devices Inc. It was funded on Kickstarter in 2020, where it raised about $4.8 million, and the first units reached backers roughly 18 months later. The firmware runs on FreeRTOS and is open source under the GPL, and the schematics are published. An app store opened in July 2023.

    The brain is an STM32WB55RG: a 64 MHz Arm Cortex-M4 for the application and a separate 32 MHz Cortex-M0+ for the radio stack, sharing 1024 KB of flash and 256 KB of SRAM. The screen is a 1.4 inch monochrome LCD at 128×64, you drive it with a five-way D-pad, and a microSD card (not in the box) holds your data. The interface is a pixel-art dolphin whose mood depends on how you use the device. That was a deliberate choice, and it explains the toy-versus-weapon argument better than any spec does.

    The interfaces

    Each radio is a separate, fairly standard part:

    • Sub-1 GHz: a TI CC1101 transceiver covering 315, 433, 868 and 915 MHz depending on region. This is where garage doors, gates and simple sensors live.
    • NFC at 13.56 MHz: an ST25R3916 handling ISO 14443 A and B, so MIFARE Classic, Ultralight and DESFire, plus FeliCa, iClass (Picopass) and NFC Forum tags.
    • 125 kHz RFID for older proximity cards, with formats such as EM4100 and HID H10301.
    • Bluetooth LE 5.4, infrared transmit and receive, iButton contacts and 13 GPIO pins. Flipper’s tech specs list those as 3.3V logic with 5V tolerant inputs. I treat that as a limit rather than an invitation: if you wire anything to them, read the GPIO documentation first and never connect another device’s power rail to the header.
    • USB-C, over which it can present itself as a keyboard. That is the BadUSB feature.
    Block diagram of the Flipper Zero: its microcontroller connected to the Sub-GHz, NFC, 125 kHz RFID, infrared, iButton, GPIO and USB interfaces

    Each of these is a commodity part a hobbyist can buy as a separate module. Flipper Devices’ contribution was packing them into one pocketable case with a friendly interface.

    Myth versus reality

    “It cracks any card.” No. Reading a card and breaking it are two different things. A 125 kHz card announces a fixed ID to anyone who asks, so copying one is trivial, and that is a flaw in the card. A system using modern cards with proper cryptographic authentication is a different problem, and a handheld does not change that.

    “It does Wi-Fi attacks.” Not by itself. There is no Wi-Fi radio on the board. The Wi-Fi features come from a separate add-on board, which gets its own part.

    “It can open any car or garage.” It can record and replay Sub-GHz signals, which only works against a receiver that accepts the same code every time. Rolling codes are designed to stop exactly that, and I will go through how in part 3.

    “It’s a toy.” Also no, as the next section shows. So the fair summary: the Flipper makes known weaknesses easy to demonstrate. It doesn’t invent new ones.

    Why institutions got nervous anyway

    Amazon banned its sale on 7 April 2023, describing it as a card skimming device. Packages ordered in Brazil in 2023 were reported seized by the telecom regulator Anatel. In February 2024, Innovation, Science and Economic Development Canada announced an intention to ban devices that could be used to clone wireless signals for remote entry, in response to a rise in car theft. Whether those moves were proportionate is debatable. They do show that people are worried about cheap, easy-to-use radio tools, and banning one product won’t remove the underlying weaknesses.

    There is a milder example too. With third-party firmware or apps the device can send Bluetooth LE advertisements that pop up on nearby phones. That was disruptive enough that Android and Windows added detection for BLE spam.

    What a defender should do with this

    Treat it as a cheap way to audit your own estate, within your local radio rules. If it can read and replay your badges or remotes, so can many other devices that do not have a dolphin on the screen. Check which card technology your access system uses, whether your gate remotes use fixed codes, and whether your endpoints let any USB keyboard type into a logged-in session. If the answer is a fixed identifier, a protocol with known weaknesses or a remote with no rolling code, the gadget is the least of your worries, so plan the migration.

    Only point it at gear you own or have written permission to test. That’s the law in most places, and it’s also the line between an audit and a problem.

    Part 2 looks at RFID and NFC badges, and why so many office cards are weaker than people think.

    Other parts of the Flipper Zero series: part 1, part 2, part 3, part 4, part 5.