start	end	text
0	3660	Cool, I think I'll get started. My name is Lennart Wouters.
3660	7180	I'm here to present you an attack we did on a Tesla Model S.
7640	11480	And the goal of our research was to figure out how the passive keyless entry system
11480	16200	in the Tesla Model S works and to see if there's any vulnerabilities we could exploit.
16800	19520	So in the way a passive keyless entry and start system works is
19520	22080	you approach the vehicle with the key fob in your pocket
22600	25360	and it automagically unlocks and starts.
25920	29800	So what's actually going on in the back is the car sends a challenge to the key fob.
29980	34100	The key fob computes a cryptographic response and sends it back to the car.
34600	38560	If the cryptographic response is correct, the car will unlock and start.
39760	44040	Now if we take one of these key fobs and we open it up, this is what it looks like.
44280	48620	So this is the PCB from the back side. There's not much going on here.
48620	53460	You can see a UHF antenna, a low-frequency antenna, and an RF transmitter chip.
54040	58880	The front side is a bit more interesting. So you can see that there's one interesting chip here.
59420	64360	This is the Texas Instruments TMS37F128.
64660	68520	Now if you take an X-ray of this chip, you can see that there's actually two dies
68520	71920	or two distinct chips inside of this one package.
72500	75400	So there's an MSP430 microcontroller.
75400	80480	This is a general-purpose microcontroller which can communicate with the transponder.
80480	83640	So this is a TMS37F126.
84080	88180	And this transponder is actually the part that stores all of the cryptographic material
88180	91720	and it performs all of the cryptographic operations.
92400	96740	The microcontroller can talk to the transponder using an SPI interface.
98440	102820	Now usually you would look up the datasheet for one of these chips to figure out what is going on.
102920	106440	In this case, to get a full datasheet, you have to sign NDAs,
106440	108780	which is of course something we don't like to do.
109580	112500	Now the things you can find online are like some basics.
112500	120100	So this chip supports an 80-bit DST80 security authentication coprocessor, whatever that may be.
120100	125000	And then it uses a 5-byte challenge and 3-byte response algorithm.
125000	127660	And it also supports mutual authentication.
128400	131780	So let's get started and let's buy some of these ICs.
131860	135960	So I went to DigiKey or Farnell, but couldn't find any of them.
135960	139180	So again, you have to sign NDAs even to buy these chips.
139840	143060	Luckily at my research group, there's a lot of international colleagues.
143060	144800	I also have some Chinese colleagues.
144820	147020	And that makes it easier to get this stuff.
147660	150640	So we went to Taobao, ordered some of these chips.
150640	154900	And once we got them, we noticed that they use a very uncommon package type.
154980	157880	So we designed our own breakout board to get started.
158240	162460	Now the chip we acquired is the TMS37126.
162460	166060	So it's only the transponder without the included microcontroller.
167660	171020	So as I mentioned, you need to sign NDAs to get the datasheets.
171220	173020	There is some public information.
173140	176440	But the public information that is out there is very inconsistent.
176900	180400	So for this one chip, you can easily find two distinct pinouts.
180460	183140	Which makes it quite annoying when you want to connect to them.
184000	186980	My initial goal was to connect an Arduino to this chip.
186980	191140	So I could talk SPI with it and try to figure out what was going on.
191780	196720	So in this case, the Arduino is the SPI master and the transponder is the SPI slave.
197260	201100	When you connect all of this up on a breadboard, it looks somewhat like this.
203360	206500	So SPI usually has three data lines.
207060	213120	We have a clock line, a data line for data going from the slave to the master, and the other way around.
213380	218720	In this case, Texas Instruments decided to add a fourth line, which is called the busy line.
218720	223460	As you can imagine, this line is used by the slave, so in this case the transponder,
223460	227540	to indicate to the master when it is ready to receive the next byte of data.
228020	234460	You can also see in this diagram that an SPI packet in this case usually starts with a length byte.
234740	238100	And this byte indicates how many bytes will follow in this packet.
238520	240880	The second byte is the command you want to execute.
241020	243160	And then there might be one or more data bytes.
243720	247400	You can also get a reply back from the transponder, including some data.
248340	253740	Now, as we didn't have the data sheets, we had to figure out ourselves what available SPI commands there are.
254100	258700	And it turns out that this extra SPI busy line is very convenient for this,
258700	262000	because it will throw an error when there is something wrong.
262140	264580	So if you provide it with a command that does not exist,
264580	268820	it will throw an error by holding this line low or high for an extended period of time.
270040	271540	Then we made two observations.
272140	274840	When the command value is incorrect, it throws an error.
275220	281640	But if you set the length byte to FF, it will throw an error after the correct number of bytes was received.
281840	284520	So you can simply fix the length byte to FF,
284520	289800	and then enumerate all of the command bytes to figure out what all of the correct lengths and commands are.
290860	294360	So in that way, we uncovered some commands that we thought were interesting.
294900	298880	So as you can see, we found two commands that perform the DST40 cipher.
299160	301800	I will give some more information on that cipher later on.
301800	305620	And two commands that perform another unknown cipher.
306240	309480	Now, this unknown cipher also works on 40-bit keys.
309660	312300	And we were expecting to find an 80-bit cipher.
312580	318940	So I made the assumption that maybe the 80-bit cipher is a combination of two of these 40-bit ciphers.
319140	326640	Usually, combining two 40-bit ciphers into an 80-bit cipher results in interesting problems.
326760	330280	So I set out to reverse engineer the unknown cipher.
330280	333400	And we did this by providing an input and observing the output,
333400	337780	and then making assumptions based on DST40, which we knew how it worked.
338200	343260	So this means that I spent about a month trying to blackbox reverse engineer a cipher,
343260	345020	which in the end wasn't used.
345840	349500	We also found two commands that allow you to set a 40-bit key.
349500	351820	So no 80-bit keys, only 40-bit keys.
353640	357680	At this point, I finally got my hands on an actual Tesla Model S key fob.
357680	362380	And as you can see, there are some easily available debug paths.
362560	366940	And I was able to connect a JTAG programmer and figured out that the JTAG fuse wasn't blown.
367220	371400	So this means we can dump the program memory on the microcontroller,
371400	374800	throw it into a disassembler, and start looking at the assembly code.
375420	380660	So for the MSP430, the two things to do are first look at the interrupt vector table.
380840	382620	This is stored at the end of Flash.
382700	387240	And it basically teaches you what code will be run after an interrupt occurs.
387240	393040	So in the case of a key fob, for example, which code is run when you press a button on it.
393620	396240	And this helps you narrow down where to look in the assembly.
397200	401500	Secondly, references to special function registers are interesting.
401620	407160	And especially in this case, because we're trying to figure out which SPI commands the Tesla Model S key fob is using.
407880	413080	So I searched for the function which is doing the SPI communication, basically.
414160	416420	And then we went on to dynamic analysis.
416600	424500	So setting breakpoints in the microcontroller at the address where the SPI function starts, basically.
424640	426460	Then you would try to unlock the car.
426460	431840	When the breakpoint is triggered, you dump the memory to see which data was sent and received over SPI.
432440	437800	And by doing this a few times, well, just in the normal way as you would unlock the car normally,
437800	444120	we figured out that the only command they were using was 86, which we earlier figured out was DST 40.
445360	447240	Now, what is DST 40?
447580	452120	DST 40 is a cipher introduced back in 2000 by Texas Instruments.
452220	457460	It uses a 40-bit key, which I guess everyone knows is too short by today's standards.
457820	461220	The cipher itself was first reverse engineered back in 2005.
461220	466700	And back then it was used mainly in immobilizers and the ExxonMobil speedpass payment system.
468140	471320	This is a schematic overview of how the cipher works.
471800	474340	So at the bottom you have a 40-bit key register.
474340	477120	At the top you have a 40-bit challenge register.
477340	479620	And then there are some lookup tables in the middle.
479620	482280	These lookup tables produce two bits of output.
482840	486020	This round is executed 200 times.
486360	490320	And the two output bits are shifted into the challenge register every round.
490800	497880	After running the cipher for 200 rounds, the 24 least significant bits of the challenge register are returned as the response.
498880	506960	The important thing to remember here is that we have a 40-bit key, a 40-bit challenge, and the response is actually shorter than the challenge.
507040	510740	And this is important for somewhere next in the presentation.
511600	515120	We know that the key fob is using an old, outdated cipher.
515280	519520	But we still have to figure out how to talk to the vehicle and how to receive messages from the key fob.
521020	525520	If you look at one of these key fobs, you can observe two distinct systems.
525860	528200	There is a remote keyless entry system.
528280	532140	This is a system where you press a button on the key fob and then the car unlocks.
532620	535800	This is one-way communication going from the key fob to the vehicle.
536600	538920	Secondly, there is passive keyless entry and start.
538920	543440	This is two-way communication where you approach the vehicle and it automatically unlocks.
543920	548380	We will start by looking at the one-way communication, so the remote keyless entry.
548380	554420	Because these packets are easier to receive and it is easier to understand how everything works.
554980	560020	In order to receive messages from such a key fob, you need to have a few physical layer parameters.
560040	563860	Like the operating frequency, the modulation and the symbol rate.
564240	566440	These are relatively easy to determine.
568240	571940	Then what you do is, once you can receive one message, you just receive a few.
571940	576780	So you press the button a few times and you look at which parts of the message change.
576780	580600	And in that way you can understand what is going on.
581020	583220	So in this case there is one byte for the command.
583220	586560	And the command is basically do you want to lock or unlock the vehicle.
587060	590460	Then there is a three-byte response, which is the DST40 response.
590580	592220	And there is a two-byte counter.
592980	596080	So the way it works is the key fob stores a 40-bit counter.
596520	599440	Every time you press the button, the counter gets incremented.
599800	602600	And this counter is fed as a challenge to DST40.
602680	604240	And then the response is computed.
604240	610780	The reason they send a long part of the counter is to prevent desynchronization between key fob and car.
610880	616300	So if your kit presses the button too many times, you still want to be able to unlock your vehicle.
618100	621560	So I actually made a challenge for the Capture the Flag in the Car Hacking Village.
621980	625540	Which is based on a real Tesla Model S key fob.
625540	631400	So what I did is, I took one of the key fobs, I removed one of the buttons and I connected an Arduino to it.
631400	635080	And the Arduino will simulate the button press every 15 seconds.
635800	639900	Now, to have a challenge, it's nice if you can have a flag which is fixed.
640620	646820	So what I did is, I reset the key fob right after it transmits, so that the counter is not updated.
647200	651820	So in this way, the packet is fixed and you can have a fixed flag.
652460	657100	If you're having troubles with the challenge and you want some tips, you can come and find me after the talk.
657100	660420	Or you can look at the talk Rapid Radio Reversing by Michael Osman.
662560	666240	Now there should be a short video of a small proof of concept.
666620	668600	And we can show that we can unlock the doors.
668920	670860	We can open the trunk.
672140	674180	And we can also open the trunk.
679650	681310	But the video is not working.
684520	688240	Opening a vehicle is cool, but it's even cooler if you can drive off with it.
688640	691780	And to do that, you have to understand the passive keyless entry part.
691780	694380	As I said before, there's two-way communication.
694380	697480	So low frequency going from the vehicle to the key fob.
697480	700860	And high frequency for data going from the key fob to the car.
701380	706240	And the high frequency part is almost the same as the remote keyless entry scenario.
706940	710960	For the low frequency part, I used the Proxmark tree.
711260	714080	Because it supports the operating frequency.
714440	718200	But it turns out that the modulation is not supported in the Proxmark.
718540	720880	So I had to modify the hardware of the Proxmark.
720880	723400	I had to write my own Verilog code for the FPGA.
723420	725900	And I had to write my own microcontroller code.
726500	728860	So the signals look kind of like this.
729920	733680	So on top you have the signal received by the antenna of the Proxmark.
733740	736440	Then it's routed to an amplification stage.
736660	738640	Then there's an analog peak detect circuit.
738640	744560	And then after the analog peak detect circuit, the FPGA will output a digital signal.
744560	747280	Which can then be interpreted by the microcontroller.
748420	752600	Now receiving these LF signals was kind of a hassle.
752900	755540	So I had to spend a few of my weekends like this.
755780	757640	In the car and around the car.
757900	761660	So basically what I did was I taped the receiving antenna of the Proxmark.
761660	764320	Very close to the transmitting antennas of the car.
764320	765620	And that made it easier.
766220	769680	So in a Tesla Model S there's antennas at the rearview mirrors.
769760	771460	There's one in the center cup holder.
771660	772900	There's one at the trunk.
772900	775660	And there's one in the middle of the windshield.
776880	780360	So at this point we can receive ultra high frequency signals.
780360	782200	We can receive low frequency signals.
782200	784540	So we can build a protocol analyzer.
784980	789820	So I have a simple Python script that controls both the yardstick 1 and the Proxmark.
790060	794460	And it basically gives me a trace of all of the communication between the key fob and the car.
795060	796820	So again what you do is you do the same.
796820	799760	You unlock the car a few times while you have your script running.
799760	801120	And you look at the output.
801120	806620	And then by seeing which parts change you can kind of guess what the protocol looks like.
807060	810980	So I figured out that the car sends a message twice a second.
810980	814080	And it's just pulling to see if a key fob is closed.
814860	819800	And this wait message contains a car identifier which the key fob is looking for.
819920	822280	Now if the key fob is closed it will reply.
822560	827840	And this reply is basically the same message as the wait command but it's an obfuscated version.
828080	830660	I'm not sure why the obfuscation is there.
830660	834940	Because if you receive messages from two vehicles you can easily figure it out.
834940	838560	It's basically a combination of some byte swaps and bit shifts.
839440	843340	So when the key fob replies the car will send a random challenge.
844040	846100	The key fob computes the response.
846400	849040	And if the response was correct the car unlocks.
849660	856100	Now as you can see here you need to send the car identifier along with your challenge to the key fob.
856100	858060	Because otherwise it won't reply.
860180	865480	Now one scenario we were thinking about is could we steal a car without ever seeing the key fob?
865480	868420	Like could we just stand next to it and lock it and drive off?
868980	873160	And it turns out it is possible but it would take you about 97 days.
873440	875560	So it's not really a practical attack.
877700	880540	So we wanted to also have a practical attack of course.
882940	888860	And to get a practical attack the thing you need to do is to recover the 40-bit key as fast as possible.
889460	897020	So to recapitulate, DST40 uses a 40-bit challenge, a 40-bit key, but the output is only 24 bits.
897380	899780	So it's kind of like a compression function.
900280	905160	And this means that you need at least two challenge-response pairs in order to recover the 40-bit key.
905980	909860	What we did was to make a time-memory trade-off table.
910460	914300	And the general idea is that we fixed one challenge.
914300	915720	So we chose one.
915880	920640	And then for every possible key we recorded which response it produced.
921140	927000	So because the response is shorter than a challenge there will be multiple keys that produce the same response.
927320	931060	And we grouped all of the keys that produce the same response into one file.
931340	934380	So we have a 5.4 terabyte lookup table.
934440	937160	Which has 2 to the 24 files.
937160	939420	So one file for each response.
939420	943200	And each of these files contains about 2 to the 16 keys.
944580	949240	So once you have this table, recovering the key from a keyfob is quite easy.
949960	956180	You first have to get the 2-byte car identifier, which you can do by brute force or sniffing it from the vehicle.
956720	959880	Then you send the challenge that you used to make your table.
960460	966080	You record the response and use the value of this response to take the file from your lookup table.
966080	969280	And at that point the keyspace is only 2 to the 16.
970520	975140	So then you send a second random challenge to the keyfob, record the response.
975400	978520	And you test the remaining 2 to the 16 keys.
978880	982420	Testing these 2 to the 16 keys takes 2 seconds on a Raspberry Pi.
983760	985580	So we built this device.
987580	991400	I have it here with me if anyone wants to take a look at it later, just come and find me.
992220	993080	No.
995580	998520	So it basically contains the Proxmark 3 and the UpStick 1.
998560	1001720	Then the Raspberry Pi, which is basically the brains of the operation.
1001840	1003640	And a USB power bank.
1004000	1007780	So the way I use this is I make a hotspot on my phone.
1008040	1010200	The Raspberry Pi automatically connects to it.
1010400	1014480	I SSH into the Raspberry Pi and I can control everything I want.
1014820	1018960	And using this connection, the Raspberry Pi can also fetch files from a lookup table.
1020100	1025940	Now after we built this Proof of Concept attack, we of course also notified Tesla.
1027080	1032420	And then after notifying them, we realized that Tesla didn't build the system themselves, so they bought it.
1032540	1036260	And they bought it from a company called Pektron, which is based in the UK.
1037040	1041020	And then looking at FCC documentation, we figured out that they built similar systems...
1041720	1046460	using the same Texas Instruments chip for McLaren, Karma, and Triumph.
1046460	1052340	I don't have a McLaren. This is Vegas, so if anyone has one, let me know.
1054780	1061280	So we contacted Tesla, and then they worked on fixing the key fob, so they made a new version of this key fob.
1061440	1066420	And all vehicles produced from June 2018 onwards are using this newer version of the key fob.
1067040	1070740	Existing customers can also request a new version of the key fob.
1071500	1076600	They also did some over-the-air software updates that make the attack harder to execute.
1076760	1082180	So they have a pin-to-drive feature, which is basically a second factor of authentication.
1082180	1084940	So you have to enter a pin each time you try and start the vehicle.
1085400	1088540	And a second option is to disable passive keyless entry.
1089920	1094740	None of these features are enabled by default, so if you have one of these vehicles, you should enable them.
1095420	1102920	I do want to point out that these features make it more difficult for me to steal your car, but they don't prevent me from doing it.
1104260	1108920	So if you disable passive keyless entry, this is actually a nice feature, and I think you should enable it.
1108920	1111420	Because it will stop the more common relay attack.
1112520	1117820	But in order to start the vehicle, they still have to use passive keyless entry. There's no other way.
1118600	1126360	Also, you might disable passive keyless entry on the car side, but the key fob will still reply to messages sent to it.
1127320	1135060	The pin-to-drive feature is also nice, but again, once I'm inside your vehicle, there's other ways to start it and drive off.
1136880	1145940	So another mitigation I came up with, and I did on one of the key fobs we have, is I basically added another button that allows me to disable passive entry on the key fob side.
1145940	1148200	So this makes it impossible to clone the key fob.
1149860	1154980	Now, Tesla was pretty cool about working with us to fix the issues.
1155220	1160400	And at some point, they even drove over a Tesla to our university, and we had to show that the attack actually worked.
1161160	1166120	We also tried contacting some of the other probably affected companies.
1167040	1170700	Karma and Triumph didn't really engage with us, they didn't really reply.
1170700	1179040	McLaren did eventually reply, but when we said that we wouldn't remove their name from our paper, they weren't very interested in talking to us anymore.
1180180	1184480	They did release a public statement online, which is quite funny.
1185320	1193620	So the statement was on that URL, they removed it from their website, but I indexed it on the Wayback Machine so you can still find it.
1194340	1196960	I'll point out some interesting facts from the statement.
1197300	1203440	So it starts by, we have been alerted, which is nice because they acknowledge that we contacted them, so we are off the hook.
1203900	1211160	And then they continue by saying, the relay attack, and we didn't do any relay attacks, so I'm not sure what they're talking about.
1211420	1218440	And then they try to explain what a relay attack is, and they say, if you leave your key close to the vehicle, it could be scanned.
1219320	1222380	Now, a relay attack doesn't work that way at all.
1222380	1228800	If you leave your key close to your car, I'm going to get in, I'm going to drive off, I don't care about the relay part.
1230620	1242960	So they continue, and they say, the second attack includes, it takes about 100 days, and it requires a skilled attacker, and skilled assembly and use.
1242960	1247120	So I was kind of flattered, because it means that they read the paper we sent them.
1248020	1252700	And then they continue reading, and they again explain how this attack works.
1253040	1257280	And they say that for this attack, you have to be close to the key fob.
1257660	1260800	Now, the attack is called a car-only attack.
1261380	1264180	So I never have to be close to the key fob.
1264520	1266980	This is a little section from the paper.
1267080	1272700	So the car-only attack is a little subsection in the paper, because it's not really a practical attack.
1272700	1277900	And the second sentence basically says, without ever being in proximity of the key fob.
1278860	1281720	Now, if you own a McLaren, there's no need to worry.
1282240	1286560	McLaren takes the security of all their vehicles very seriously.
1289620	1293100	So after this research, we can of course draw some conclusions.
1293380	1297540	I think everyone here knows, but don't use proprietary cryptography.
1298240	1305000	And if you're a chip manufacturer, secrecy of data sheets is simply annoying.
1305000	1308220	And it doesn't really stop any attacker.
1308460	1314660	It just makes it more difficult for legitimate researchers to find vulnerabilities and fix them.
1314960	1321140	And if you're a car manufacturer, just buying stuff from a tier 1 or tier 2 supplier is maybe not the best idea.
1321140	1325400	Maybe you should work with them and try to figure out what you're actually buying from them.
1326040	1333180	And if you're making a product that has a microcontroller with firmware in it, don't rely on the secrecy of the firmware for security.
1333260	1335540	There's always a way to get the firmware out.
1335700	1339180	But that also doesn't mean that you should make it easy to get the firmware out.
1340260	1344720	Now, there's a few other issues we've seen with similar systems.
1344720	1353240	So, Flavio Garcia, for example, he showed that Volkswagen was using only 7 keys for all of their remoteless entry systems.
1353240	1357720	So, this includes Audi, Skoda, I think, and all of the other Volkswagen brands.
1358620	1367200	And then, of course, if you're one of the designers of such systems, maybe read the papers that people have published about this kind of stuff, so that you know what kind of attacks are out there.
1367980	1371420	But then, most importantly, this is a tweet from one of my colleagues.
1371420	1380100	And Tesla got a lot of heat for using only 40-bit keys, but at least they did the effort of fixing it, and they replied to us when we emailed them.
1380260	1382440	And this cannot be said for the other manufacturers.
1384180	1390080	So, then I have a video we made to show how the attack works, if I can.
1392880	1397980	So, I will just talk through the video to explain again how the attack works, just to recapitulate.
1398640	1402200	So, it's actually quite easy to find these cars if you want to steal them.
1402200	1405680	They all have to charge, and they all do it in the same location.
1408860	1414360	So, what you do is you go to a supercharger, you hide there, and you wait for someone to charge their car.
1418100	1422300	Now, what most people do is it takes like 30 or 45 minutes to charge their vehicle.
1422580	1427200	So, they'll take a walk, or they'll go to a nearby coffee shop, so it's also easy to find your target.
1429000	1434680	Now, as an attacker, we need the car identifier, and the easiest way to get it is to just sniff it from the vehicle.
1434680	1441280	So, you walk up to the vehicle, and you just receive it, basically.
1443120	1446780	So, the output on top, the terminal output, is recorded from my phone.
1450110	1454670	Then you walk to your target, you send your chosen challenge, and your random challenge.
1456230	1462050	You record the responses, you download the candidate key file, you brute force the remaining keys,
1462050	1466110	and in about five seconds you have a perfect copy of the key fob.
1466790	1471610	You walk back to the car, you unlock it, don't forget to unplug it.
1480530	1485350	The protocol is the same for unlocking and starting, so once you can unlock it, you can also start the vehicle.
1485670	1487050	You start it, and you drive off.
