I've been reading a bit into car security and all of the ways cars can be stolen through various alterations of replay attacks. Upon researching whether any of the more modern cars are using anything more secure than "new code after usage", I haven't really found anything satisfying. Which makes me question, why don't car manufacturers just use something like RFC 4226 to secure the cars? It seems like an easy enough solution. Am I missing something here perhaps?
RFC 4226 (HOTP) would still be vulnerable to replay attacks in some situations. In the case of old fashioned key fobs, where you have to press a button to unlock the car, imagine someone who has brief access to the key fob while you are out of range of the car. The attacker can press the button once, record the code transmitted by the fob, and then hurry out to your car, replay the recorded code, and gain access to the vehicle.
Another attack possible on this is the RollJam attack and requires only a $32 device. The device is hidden near the vehicle. When the owner comes by and unlocks the car, the signal sent by the fob is recorded by the device and jammed so the car does not unlock. The owner, naturally, tries again. The signal is recorded and jammed again, but the first signal is then replayed. The car receives the replayed signal and unlocks. Meanwhile, the second signal has still not been seen by the car so it can be used to unlock the car once the owner leaves.
For more modern key fobs, it gets more complicated. These are designed to be passive so that you don't have to press any button for unlocking the car. As long as the fob is in your pocket, the car will unlock itself when you walk up to it and lock itself when you walk away, no interaction required. Nice, right? Turns out these are a handful to secure. Now if you use HOTP in this case, well then all the attacker has to do is pretend to be the car and request a code while you are out of the car's range. Then record the code, go back to the car, replay it and profit.
And then there is a DOS vulnerability. Since an attacker can request as many HOTP codes as they want, they can make the internal HOTP counter of the fob drift so far away from the counter in the car, that the fob will no longer be able to authenticate. (Actually, this can be an issue with normal fobs too. What happens if your child starts playing with it and presses the unlock button hundreds of times?)
In fact, it turns out, these modern keyless fobs take a lot of effort to secure. Early manufacturers decided to implement proprietary challenge-response mechanisms. A cryptographically secure challenge response system, what could go wrong? Well, guess what the car thieves did?
They simply amplified the signals transmitted by the vehicle and the fob to make the challenge-response mechanism work over much larger distances than it was meant to. So your BMW is parked outside your house and you are snug in bed having a good night's sleep. Someone walks up to your window with a special device. The device relays an amplified challenge from your car to the key fob in your room. The fob thinks the car is nearby, so it computes the response and transmits it back. The device amplifies the response so it reaches the car, and BOOM, when you wake up in the morning, your shiny new BMW is gone.
So then, the manufacturers had to apply further security measures, like measuring the time it took for the key fob to respond. If it took too long to receive the response, the car would conclude that the fob was out of range. But I guess the car manufacturers have learnt their lesson by now and have more robust security (or perhaps not).
The design flaw is not in the cryptographic binding between the prover (key) and verifier (car). It's in the communication channel. HOTP is a secure way to generate tokens but it doesn't secure the channel. HOTP can be only used in keyfob with remote locking/unlocking. NFC devices have an unfixable problem of relay attacks on which attacks against keyfobs are based on.
Modern cars use 3 types of keys:
Keyfob With Remote Locking/Unlocking & Push Button Start
Keyfobs use rolling code to authorise lock & unlock command. The car passively listens to the code and verifies if it matches with the future code. Manufacturers can actually use HOTP here but it cannot be used for push button start. Push button start verifies keyfob through challenge & response to detect keyfob presence. Car also periodically pings keyfob to detect its presence while running and throws warning if keyfob is not being detected. Keyfobs are vulnerable to RollJam attack and Signal Amplification Relay Attack (SARA).
In RollJam attack, the relay jams & captures the 1st signal. The car owner thinking it might have been missed, signals one more time. The relay jams & captures the 2nd signal and replays the 1st signal. Now the attacker has unused 2nd signal to unlock the car. To start the car, the attacker uses SARA to amplify the challenge signal so it reaches to the keyfob and relay back the response to the car. It's enough to start the car but if the car stops, it won't start again without keyfob presence.
Keyless Entry Fobs & Push Button Start
Keyless entry fobs don't use rolling code to lock/unlock the door. They use challenge-response entirely. Cars continuously emit a random challenge and listens for the keyless entry fob to produce token over the challenge. As long as the keyless entry fob is in proximity, door remains unlocked and trunk can be open with a button press.
It is also vulnerable to SARA. Car thieves have been caught using this attack to steal luxury cars. The only condition is once the engine is started, it shouldn't be turned off after leaving the sight.
Smart Card Keyless Entry & Push Button Start
Contactless Smart Card keys are relatively more secure because their passive power source limits the range of prover to just 3-6 cm from the verifier. Beyond that range, the smart card cannot be powered or the response from the card is not reachable to the verifier. Tesla Model X comes with NFC smart card key and keyless entry fob as an accessory. It is the same concept as contactless payments.
Although SARA doesn't work on contactless smart cards because of small range, the basic relay attack still works. E.g. The attacker has to just wave the relay around your pockets while being connected with the other relay near the car over wifi, bluetooth or mobile data. This attack also works on contactless payments.
The only counter measure against relays is Distance Bounding Protocol (demo). With distance bounding, the relays have to be under 6 metre of the distance between the verifier and the prover if latency tolerance is 20 nanoseconds. Only the verifier needs to have clock for this. Distance bounding is actually the specification of EMV Contactless Cards and only Mastercard is known to be using it. Car manufacturers needs this to prevent relay attack against keyless entry fobs and smart card keyless entry.