1 00:00:00,000 --> 00:00:14,420 So we are Ben and Vladan from IBM X-Force Red and we are involved in a lot of stuff but we like to hack hardware, software and especially if something has wheels and it's moving it is interesting target for us. 2 00:00:14,420 --> 00:00:25,660 So we spend a lot of time actually working with vehicle security testing and today we are here to share a little bit of of stuff that we encounter through the years with you. 3 00:00:25,660 --> 00:00:34,100 So what we are going to cover today is about hacking car infotainment system and how far we can actually go with it. 4 00:00:34,100 --> 00:00:42,800 So where are the dangers and what is the approach that we have discovered which is different than everybody else is using. 5 00:00:43,040 --> 00:00:45,420 So why it is important. 6 00:00:45,420 --> 00:00:52,760 So unfortunately cars are becoming a lot more cars are becoming a lot more complex than they were before. 7 00:00:52,760 --> 00:01:04,660 So this screen we can see different number of lines of code that are used to develop specific systems and we see that Facebook is something about 6.7 million lines of code. 8 00:01:05,040 --> 00:01:16,440 Boeing 787 is a 7 million and we have Ford F150 150 million lines of code including all systems in the car. 9 00:01:16,440 --> 00:01:22,660 So current modern car can have more than 200 kilos of just electronic and wires in it. 10 00:01:22,660 --> 00:01:27,700 So you will find like a hundred different smart computing units. 11 00:01:27,700 --> 00:01:42,340 So i'm not saying computer because they are of different level but smart computer units which control specific functions from your entertainment system from your convenience systems until the suspension motor ignition and and everything else. 12 00:01:42,340 --> 00:01:52,620 So cars become a really complex multi-computer systems which are all connected and they're becoming more and more connected and exposed even to the internet. 13 00:01:52,840 --> 00:01:58,620 So we all like our infotainment system because it gives us constant access to everything. 14 00:01:58,620 --> 00:02:14,360 So we have we can watch movies while we stand fortunately, we can gain information from the internet, we can retrieve data from systems about roads, states of situation on road, if there are congestion, non-congestion, we can do a lot of stuff. 15 00:02:14,360 --> 00:02:18,040 So it needs to be complex in order to support all of this. 16 00:02:19,460 --> 00:02:21,100 What is infotainment system? 17 00:02:21,100 --> 00:02:35,420 It is a not so simple thing that we can think what we see in our car is just a small screen which is presented to us and we interact with this screen by touching it, moving it, abusing it to different ways, spilling our coffee on it. 18 00:02:35,420 --> 00:02:38,940 But it is just what is exposed so we can actually see. 19 00:02:38,940 --> 00:02:42,780 What is behind it is usually much much more complex than it. 20 00:02:42,780 --> 00:02:50,780 So it can contain different features radio, bluetooth, control cameras inside, outside, recording. 21 00:02:50,780 --> 00:02:53,260 In autonomous car it can have even more stuff. 22 00:02:53,260 --> 00:02:58,020 So if you have lane assist it is used to do this lane assist. 23 00:02:58,020 --> 00:03:08,740 So cameras will be picking up the data, sending it to your infotainment system and it will do processing and help you stay out of the lines. 24 00:03:08,740 --> 00:03:11,780 So to keep you straight on. 25 00:03:11,780 --> 00:03:16,260 So there is a lot of stuff that is integrated, that is connected. 26 00:03:16,260 --> 00:03:18,380 We see a lot of radio communication. 27 00:03:18,380 --> 00:03:22,440 So for example your tire pressure monitoring system, it is all wireless. 28 00:03:22,840 --> 00:03:33,080 You can have bluetooth, you can have wi-fi, you can have a lot of different technology and car is becoming actually like mobile phone on the wheels. 29 00:03:33,680 --> 00:03:38,600 So that's unfortunate because we know how bad we are surviving our mobiles. 30 00:03:38,600 --> 00:03:44,120 They take all of the time, we are looking at them all the time and we can hit stuff while we are walking. 31 00:03:44,120 --> 00:03:46,060 Imagine that happening while you are driving. 32 00:03:46,060 --> 00:03:48,180 Not the best situation for sure. 33 00:03:49,480 --> 00:03:56,720 So as I mentioned, what we see is just a single head unit usually, which is displaying all information. 34 00:03:56,720 --> 00:04:05,980 But behind it we have a plethora of different systems which are used to collect this information and to process and in the end to present it to us. 35 00:04:05,980 --> 00:04:19,560 So in a specific case that we are mostly discussing today, we saw that it is a multi-system which has multiple different boxes which are dedicated to different things. 36 00:04:19,560 --> 00:04:38,660 Some of the functionality can overlap between different boxes because for example in a one car manufacturer you can have one level which is basic or you can buy another option which is advanced functionalities or third one which are superb functionalities and all offer something that might be better than the previous box. 37 00:04:38,660 --> 00:04:42,760 And all of them together are connected and communicate between each other. 38 00:04:42,760 --> 00:04:52,520 So they collect information about your car, about the way you are driving, about your location and even maybe some of your personal information which we are going to show a little bit later. 39 00:04:52,660 --> 00:04:55,700 The problem with this is we have a lot of software as I mentioned. 40 00:04:55,800 --> 00:04:57,900 150 million lines of code. 41 00:04:57,900 --> 00:04:59,840 Do you think it is bug free? 42 00:05:00,560 --> 00:05:01,580 No. 43 00:05:01,720 --> 00:05:13,360 And problem is that updating car is much more difficult than updating your mobile or windows operating system or linux or whatever operating system you are using. 44 00:05:13,360 --> 00:05:15,840 So this is a part of the problem. 45 00:05:15,840 --> 00:05:23,120 So manufacturers make it very difficult for you to change your car computer software and beat it. 46 00:05:23,120 --> 00:05:30,260 It's a little bit easier to update your infotainment system but it might be even not done because customers are not used to it. 47 00:05:30,260 --> 00:05:37,000 You need to go on the line to log in with some specific credential that should be provided to you by your vendor. 48 00:05:37,000 --> 00:05:41,400 I hope they are not providing it free for all so you can just download update on the internet. 49 00:05:41,400 --> 00:05:43,100 We saw even that happens. 50 00:05:43,420 --> 00:05:51,360 So it can be really dangerous and long-standing process which might not be done in time. 51 00:05:51,360 --> 00:05:52,900 So you might be exposed. 52 00:05:52,900 --> 00:06:00,780 In worst case, manufacturers need to recall the cars so they can update them and change the software in case of serious problems. 53 00:06:02,480 --> 00:06:13,660 So as I mentioned, in the head unit we have some basic functionalities and we have another box which is hidden behind the dashboard which provides additional features. 54 00:06:13,660 --> 00:06:29,280 It might be connectivity, it might be better FM receiver with more functions, it can be GPS receiver for navigation and all these boxes are connected to each other with their own bus. 55 00:06:29,500 --> 00:06:37,800 So they are using their own bus to connect to each other to exchange information because in the end you always see the basic device screen. 56 00:06:37,800 --> 00:06:40,240 So there is only one device which has screen. 57 00:06:40,240 --> 00:06:49,000 Other device, when connected to it, will communicate and take over the screen from the base device, so from navigation unit, from head unit, sorry. 58 00:06:49,140 --> 00:06:55,380 So it uses some inter-equipment communication protocol which can be vendor specific. 59 00:06:55,380 --> 00:07:01,060 There are few that are open and known but mostly they are using some proprietary communication protocols. 60 00:07:02,780 --> 00:07:07,400 When we open these boxes we can find different hardware inside it. 61 00:07:07,400 --> 00:07:11,440 So in this case what we commonly see is the Texas Instruments chip. 62 00:07:11,440 --> 00:07:23,360 It's big SoC which is optimized to run fun and nice operating system called QNX which some of you might know was running on BlackBerry devices some time ago. 63 00:07:23,360 --> 00:07:30,360 Now they are upgrading it and maintaining it and they are selling it as the main car navigation platform. 64 00:07:30,360 --> 00:07:36,380 So it is new neutrino platform which run on ARM, ARM v7 in this case. 65 00:07:36,380 --> 00:07:40,040 And this chip is very powerful and can do a lot of stuff for you. 66 00:07:40,040 --> 00:07:50,700 It can do a lot of DSP processing, so it can do video processing, it can process network information, it can interface with other stuff. 67 00:07:50,700 --> 00:07:57,520 So it is really a powerful device with complex architecture and it is implemented in such systems. 68 00:07:57,520 --> 00:08:01,680 So what we found on these devices is stuff like NAND flash. 69 00:08:01,680 --> 00:08:09,740 We have identified a lot of positions where we can connect and see what the information are there. 70 00:08:09,740 --> 00:08:15,980 So on these pins there can be a lot something interesting something not we don't know until we verify. 71 00:08:15,980 --> 00:08:24,040 So as I mentioned, the main operating system which you can find on most of these cars are Android and QNX. 72 00:08:24,040 --> 00:08:34,400 QNX is becoming really dominant in this place because it is micro-kernel based, unfortunately it's proprietary, so it is very difficult to obtain anything open source. 73 00:08:34,400 --> 00:08:39,600 If somebody has any information about any open source tool chain for QNX, let me know. 74 00:08:39,600 --> 00:08:41,300 I'm interested. 75 00:08:41,300 --> 00:08:47,780 Otherwise licenses for QNX for developers are somewhere like 10k dollars per license. 76 00:08:47,860 --> 00:08:50,280 So it is really expensive. 77 00:08:50,700 --> 00:08:55,240 What we also see that these devices are on top of the QNX. 78 00:08:55,240 --> 00:09:00,640 They are running some user interface. 79 00:09:00,640 --> 00:09:15,860 It's based on SWF, Flash User Interface, and it utilizes known technologies which are a little bit modified and customized for specific purposes like Lua scripting, Dbus, Java, XLAT. 80 00:09:15,860 --> 00:09:24,240 So all of these are standard but they are usually just enough modified so it's difficult to use pre-existing tools to do anything with this. 81 00:09:24,280 --> 00:09:33,500 So also during this we have discovered that one of these devices has more than one single partition. 82 00:09:33,600 --> 00:09:43,140 So these partitions are all custom QNX file systems and they are optimized in order so when you're updating you overwrite only a single partition. 83 00:09:44,720 --> 00:09:54,660 So as I mentioned QNX is similar to Linux but it is a little bit different because it implements a little bit different approach to the kernel. 84 00:09:54,660 --> 00:10:01,940 So it is microkernel which is monolithic and in contrary to Linux which is modular. 85 00:10:02,000 --> 00:10:09,420 So everything should be already in the kernel itself but some of the drivers which are needed are loaded from user space. 86 00:10:09,980 --> 00:10:27,620 So it is a little bit different than the Linux kernel where everything is running in ring zero so everything every driver run in the kernel space unless you're using some hacks and you fuse or something that enables you to use user space drivers. 87 00:10:27,920 --> 00:10:34,520 So problem it is everything is proprietary as I already mentioned proprietary file systems which are mount as read only on device. 88 00:10:35,140 --> 00:10:37,400 There is not much documentation. 89 00:10:37,400 --> 00:10:48,660 We spent a few months researching about QNX but as I said expensive licenses closed source proprietary there is not much to find open. 90 00:10:48,660 --> 00:11:03,380 So we were spending a lot of time reading development manuals trying to find something that that exists so few people done something but they are limited so we built on on other existing tools. 91 00:11:05,220 --> 00:11:13,580 Problem is that it is impossible to cross compile for QNX anything unless you have QNX development tools which are costing 10k as I mentioned. 92 00:11:13,860 --> 00:11:18,040 So what we started we started to analyze the boot process first. 93 00:11:18,060 --> 00:11:24,560 So boot process starts with IPL which is like your Linux loader. 94 00:11:24,640 --> 00:11:27,920 So it will load first and then load everything else. 95 00:11:28,080 --> 00:11:34,540 It will load this image file system what is actually Z image in Linux. 96 00:11:34,540 --> 00:11:43,960 So it is kernel and then it will start loading user space programs and finally it will load flash partitions from flash memory. 97 00:11:43,960 --> 00:11:46,980 So it has fully running system in the end. 98 00:11:50,090 --> 00:12:05,610 So what we see while reading this documentation that I mentioned we have discovered one interesting recommendation by the vendor and that is actually what we find really interesting and that is to eliminate everything that can slow down the booting process. 99 00:12:05,610 --> 00:12:18,070 So all security features like checksums, signatures, CRC, whatever you have they strongly advise you to disable it so device boots quickly. 100 00:12:18,070 --> 00:12:26,190 You don't want to be sitting in your car for 20 minutes waiting it to come up to check image before it loads it to check if it is consistent. 101 00:12:26,190 --> 00:12:29,870 So it is just optimized for quick boot because we are impatient. 102 00:12:29,870 --> 00:12:34,250 We like to be driving from point A to point B and waiting for our car to boot. 103 00:12:34,250 --> 00:12:35,690 We have Windows for that. 104 00:12:37,610 --> 00:12:51,110 Also what we saw that there is no secure boot, file systems were not encrypted so there was a lot of security features which are missing and which made our life a little bit easier easier than than it would be otherwise. 105 00:12:53,770 --> 00:13:00,430 So also one interesting thing devices that we tested were customized for different car manufacturers. 106 00:13:00,490 --> 00:13:07,750 So we have checked not a single vendor but we have checked every car that we can find and that people will allow us to play with. 107 00:13:07,930 --> 00:13:11,550 And you would be surprised that not many people will allow you to play with their car. 108 00:13:11,550 --> 00:13:12,650 I don't know why. 109 00:13:13,150 --> 00:13:23,870 But we saw that they all use OEM devices which are kind of similar to each other and they are just a little bit customized and optimized for each specific cars. 110 00:13:23,870 --> 00:13:32,650 In some specific cases we saw that a car vendor asked for additional security features to be included in such devices. 111 00:13:32,650 --> 00:13:48,650 So it is possible that the same device which runs in one car is vulnerable and the same device with same level of hardware version runs differently in another car because car manufacturer asked for additional security features to be on. 112 00:13:48,950 --> 00:14:00,090 So when we dumped the firmware from these devices and we have done analysis we found references actually that the same firmware is actually baseline for a different car manufacturers. 113 00:14:00,090 --> 00:14:03,870 So we found strings that are relevant for anything that you can imagine. 114 00:14:03,870 --> 00:14:05,630 So I believe they are selling to everybody. 115 00:14:07,030 --> 00:14:17,150 So problem in this area is that you don't you're not sure even if it is the same hardware if it is the same level of software and feature packs that are implemented on this hardware. 116 00:14:18,470 --> 00:14:24,550 So our idea is to see what we can do first without actually dismantling the car. 117 00:14:24,550 --> 00:14:38,110 So we reviewed all access vectors, so radio signals, available interface for USB, CD, available applications on the on the devices. 118 00:14:38,110 --> 00:14:43,790 So they are having some kind of market where you can download and install your own applications. 119 00:14:43,790 --> 00:14:48,970 Some of them you need to pay, some of them are free of charge and can be just downloaded. 120 00:14:48,970 --> 00:14:54,830 After we were done with this part then we started dismantling the devices. 121 00:14:54,830 --> 00:14:57,530 So we pulled them out of the dashboard. 122 00:14:57,530 --> 00:15:01,250 We had wires everywhere so we started analyzing devices. 123 00:15:01,250 --> 00:15:12,110 We saw there are flash chips, there are EPROMs, there are consoles, there are soldier points, test points where we can maybe do something with it. 124 00:15:12,710 --> 00:15:17,190 But unfortunately car is not the best laboratory that you can work. 125 00:15:17,190 --> 00:15:18,270 This is poor Ben. 126 00:15:18,270 --> 00:15:22,470 Ben was not hurt during this work. 127 00:15:22,610 --> 00:15:23,690 So he's safe. 128 00:15:23,690 --> 00:15:24,610 He's here. 129 00:15:24,910 --> 00:15:27,070 He's just very cold in this picture, I know. 130 00:15:27,330 --> 00:15:30,110 So we were working in the UK in the winter. 131 00:15:30,110 --> 00:15:33,410 It was not the best possible way. 132 00:15:33,410 --> 00:15:39,850 It was around zero and we are sitting on car park with everything open because car is small and there is two of us and we are not so small. 133 00:15:39,850 --> 00:15:40,910 We need a room. 134 00:15:40,910 --> 00:15:42,250 Especially me, yes. 135 00:15:42,590 --> 00:15:44,110 Thanks for pointing that out. 136 00:15:44,110 --> 00:15:45,630 It was not obvious. 137 00:15:46,330 --> 00:15:57,150 So we removed just the plastic covers of the dashboard so we can actually access the wires and connections behind the devices. 138 00:15:57,190 --> 00:16:02,310 And we started analyzing how these devices interact with the car. 139 00:16:02,630 --> 00:16:10,690 So our idea was we don't like to work outside on cold in a very, very low space. 140 00:16:10,690 --> 00:16:14,330 So our idea was can we move the car inside? 141 00:16:14,350 --> 00:16:16,870 Guys maintaining our lab say no. 142 00:16:17,530 --> 00:16:20,010 We will not allow you to drive car in. 143 00:16:20,430 --> 00:16:23,910 Elevators might be a little bit smaller than you need. 144 00:16:23,910 --> 00:16:29,710 So then we get another idea and that is let us try to emulate the car outside of the car. 145 00:16:29,710 --> 00:16:37,950 So we need to replicate enough so devices are operational but without actually needing to have the car. 146 00:16:37,950 --> 00:16:44,990 In very, very old times I would go to the junkyard and I would try to salvage ECU with everything. 147 00:16:44,990 --> 00:16:51,110 But today we do not need to do that because modern cars are not operating on the same principles. 148 00:16:51,210 --> 00:16:55,070 Even modern cars do not have lately proper OBD interface. 149 00:16:55,070 --> 00:16:56,430 This is emulated. 150 00:16:56,750 --> 00:17:01,930 So even in the car you have emulation OBD and behind that it runs whatever you want. 151 00:17:01,930 --> 00:17:05,330 So there are different protocols and standards that are used. 152 00:17:05,330 --> 00:17:13,190 But in order to make devices operational at this point we needed to check status of the holy grail, CAN bus. 153 00:17:13,510 --> 00:17:17,070 So how device is interacting with the car? 154 00:17:17,730 --> 00:17:23,490 We started by discovering where CAN bus is connected to device and start with sniffing. 155 00:17:23,710 --> 00:17:29,450 In order to find out what device needs from the car so we can set it up in our lab. 156 00:17:30,430 --> 00:17:38,570 But we discovered that we might not need to do anything because device is not communicating on the CAN bus. 157 00:17:38,690 --> 00:17:46,710 So device is just listening but at that point in time we could not find any single packet injected by device on the CAN bus. 158 00:17:46,710 --> 00:17:55,190 So what we saw, we started first, device was removed, we started sniffing the CAN bus, collecting what information we can see. 159 00:17:55,190 --> 00:18:00,510 Then we connected everything, start running, comparing and we see exactly the same stuff. 160 00:18:00,570 --> 00:18:03,830 So device is not interfering with CAN bus at all. 161 00:18:05,070 --> 00:18:09,870 Anyway we just captured this traffic so we can replay it back in the lab. 162 00:18:09,870 --> 00:18:14,830 So if we missed something it will still work so we don't have a problem with that. 163 00:18:15,130 --> 00:18:18,210 So this is a little bit of hardware that I like to use. 164 00:18:18,210 --> 00:18:21,050 It is all small hardware and it is pretty cheap. 165 00:18:21,050 --> 00:18:21,990 I like Blue Pill. 166 00:18:21,990 --> 00:18:24,510 It is very cheap STM platform. 167 00:18:24,890 --> 00:18:31,450 It is less than two dollars on your favorite Chinese supplier and it is cheaper than Arduino. 168 00:18:31,450 --> 00:18:34,110 It can be programmed Arduino but it is much more powerful. 169 00:18:34,210 --> 00:18:41,190 And what I like it, it has USB and I was very happy when I discovered it has CAN bus on it. 170 00:18:41,430 --> 00:18:48,670 When I started developing a sniffer that I needed, I had one sniffer, it is on the right corner, but I needed to have two of them. 171 00:18:48,670 --> 00:18:50,170 One to sniff, one to inject. 172 00:18:50,170 --> 00:18:54,090 So I needed to create another tool and I like to have my own tools anyway. 173 00:18:54,150 --> 00:19:06,810 I discovered one very disappointing thing and that this platform cannot work on USB and CAN at the same time because of some memory overlaps in the architecture of device and you can use only USB or CAN. 174 00:19:06,810 --> 00:19:12,250 But luckily I had a CAN shield from Arduino which worked really well in this case. 175 00:19:12,350 --> 00:19:22,330 So we have collected all information from CAN bus and started creating our environment in the lab where we had standard power supply units. 176 00:19:22,330 --> 00:19:23,870 We have everything else. 177 00:19:23,870 --> 00:19:29,410 What we didn't have are actually cameras, antennas, and speakers. 178 00:19:29,410 --> 00:19:33,850 But that was not important because devices were fully operational even without that. 179 00:19:34,190 --> 00:19:40,110 So we were very lucky because now we can work in much hotter and better environments. 180 00:19:40,110 --> 00:19:43,030 Our hands are not freezing, we are not hurting ourselves. 181 00:19:43,450 --> 00:19:52,890 Our CAN bus simulation is working, device is happy, not complaining and everything is just fine so we can focus on to the operation. 182 00:19:52,890 --> 00:19:59,570 So as I mentioned devices are using wireless connectivity but not on themselves. 183 00:19:59,650 --> 00:20:03,010 So they need to connect to your phone. 184 00:20:03,010 --> 00:20:08,190 So you as a driver need to set it up, set up the connectivity on your phone and share. 185 00:20:08,190 --> 00:20:13,690 So it is like a hotspot or bluetooth depending on devices. 186 00:20:13,690 --> 00:20:16,470 Some of them require wi-fi, some of them require bluetooth. 187 00:20:16,470 --> 00:20:24,850 But it will use that as a communication channel in order to establish connectivity to the internet and to go to download everything it needs. 188 00:20:25,010 --> 00:20:34,470 Applications, configurations, to enable you access to to app markets so you can buy applications that you like to install. 189 00:20:34,470 --> 00:20:45,210 So what we see is the device is now having standard IP address which enabled us to to play with it without actually connecting to wires. 190 00:20:45,210 --> 00:20:54,790 So we have set up a rough access point which is controlled by us based on host APD, DNS mask, IP tables and our favorite burp tool. 191 00:20:54,790 --> 00:21:03,730 And we connected to these devices to our access point and just intercept the traffic to see what device is doing. 192 00:21:04,970 --> 00:21:14,250 We have discovered that devices are devices that are using bluetooth were a little bit more pickier than wi-fi devices. 193 00:21:14,250 --> 00:21:25,090 So they needed to establish first, before they establish PAN connectivity, so private area network, it needs to be set up as hands-free device. 194 00:21:25,090 --> 00:21:33,610 So it needs first to connect your target device that you're sharing with your car as a hands-free device and then it can use it as a network standpoint. 195 00:21:33,690 --> 00:21:46,770 So that made our life a little bit complicated but not too much because it was easy for us to create a small Python tool based on PyBluesy which we use to emulate phone in both profiles. 196 00:21:46,770 --> 00:21:55,190 So that enabled us to actually establish connection and to sniff the traffic that goes from device to the internet and back. 197 00:21:55,470 --> 00:22:03,610 So we implemented only necessary devices, only necessary features in order to have this device connect and operate. 198 00:22:06,730 --> 00:22:08,790 So now Ben, I'm tired. 199 00:22:08,790 --> 00:22:13,150 So now Vladan has introduced the device, how they work and their specificities. 200 00:22:13,310 --> 00:22:17,830 I'm going to detail you what kind of attacks we have conducted on the device. 201 00:22:17,830 --> 00:22:26,850 But first of all, because we have described our tool, our talks, sorry, as a new approach, why previous attacks don't work anymore. 202 00:22:26,970 --> 00:22:36,130 You remember a couple of years ago here at DEF CON and Black Hat, some researchers have introduced vulnerabilities present on Jeep cars. 203 00:22:36,130 --> 00:22:47,190 So these vulnerabilities were exploiting connectivity, they were connecting to the device using Telnet, the password were well known and present on the internet. 204 00:22:47,190 --> 00:22:59,410 They were also using Dbus over TCP to connect to the device and last but not least, they were abusing the firmware upgrade process by passing uh, the um, content signature check-in. 205 00:22:59,590 --> 00:23:08,210 So now for our test, we still have the IP connectivity to the device, so they have not configured any software firewall to prevent us to access the device. 206 00:23:08,210 --> 00:23:15,010 But Dbus over TCP is closed, Telnet is closed and the firmware upgrade process has been hardened. 207 00:23:15,030 --> 00:23:21,050 So we couldn't reuse any of the previous vulnerability described uh, on the web and here. 208 00:23:21,450 --> 00:23:26,270 So the angle we chose was the third party applications. 209 00:23:26,450 --> 00:23:41,010 So on the device we have been testing, we realized that the vendor has provided an app store and when they designed the solution, the goal was for them to open the devices to third party vendors and they could create their own application and they could sell it on the store uh, 210 00:23:41,010 --> 00:23:44,770 like for example the Android app store or the app store for iOS. 211 00:23:45,210 --> 00:23:56,170 In the reality, uh, there is only a limited set of applications which are on it and they have never I think released uh, the software development kit for third party applications. 212 00:23:56,170 --> 00:23:59,330 Which is good, you will realize why a bit later. 213 00:23:59,610 --> 00:24:05,910 So the first thing we did is we intercepted the communication between the software app store and its backend. 214 00:24:05,910 --> 00:24:08,550 So it was using HTTPS which is good. 215 00:24:08,550 --> 00:24:20,410 Problem is uh, the encryption is broken when we try to intercept and replace the certificate by a self-signed certificate, the device did not show any warning and it was continuing operating as normal. 216 00:24:20,470 --> 00:24:21,950 So, first problem. 217 00:24:21,950 --> 00:24:33,450 The second problem is the device is communicating with its backend using XML messages, a bit like soap, um, and we could easily intercept the content and modify the content on the fly. 218 00:24:33,450 --> 00:24:47,670 So, for example, when the device requests the software catalog, the server will reply uh, with a full catalog including the links uh, to the URLs for the install package and just with a status which is buy, install, or installed. 219 00:24:47,730 --> 00:24:52,710 So if the status is buy, the device when you will click on it will offer you to buy and pay for it. 220 00:24:52,710 --> 00:24:58,090 But if the status is just replay by install, the device will install it without having to pay for it. 221 00:24:58,090 --> 00:25:06,270 So the logic control is done at the client side which is very bad and it might remind you the first mobile apps you have been testing a couple of years ago. 222 00:25:06,430 --> 00:25:07,770 So, good stuff for us. 223 00:25:07,770 --> 00:25:10,670 We could get uh, access to paid apps for free. 224 00:25:10,670 --> 00:25:13,450 But our goal is to to go deeper. 225 00:25:13,870 --> 00:25:15,770 So, here is an illustration. 226 00:25:15,770 --> 00:25:24,170 You see we have just reply, replaced, sorry, the buy status by install and we were able to install the application um, on the device. 227 00:25:24,930 --> 00:25:31,890 Now, um, we did some analysis on what was an install package for a third party application. 228 00:25:31,890 --> 00:25:36,950 So, in the previous screenshots you've seen that we have the URL for the install package. 229 00:25:36,950 --> 00:25:38,650 So we downloaded a couple of them. 230 00:25:38,650 --> 00:25:45,570 Uh, you don't need any authentication so just a double you get with the URL and you could access uh, the third party application package. 231 00:25:45,570 --> 00:25:49,430 So we downloaded all of them and we started analyzing them. 232 00:25:49,510 --> 00:25:51,510 Uh, so what's an installation package? 233 00:25:51,510 --> 00:26:03,570 Basically it's a zip archive with inside a jar file so a java archive and one signature file which is a signed message digest uh, using RSA signature. 234 00:26:03,570 --> 00:26:10,790 So, we have tried to spend a little bit of time but we were not able to break the signature encryption which is good. 235 00:26:10,790 --> 00:26:20,250 Uh, once we opened the jar file we realized that the source code is not obfuscated which means with any of your favorite java decompiler you can access the source code which is good. 236 00:26:20,250 --> 00:26:24,970 However, the jar file by itself is signed uh, with some private keys. 237 00:26:25,050 --> 00:26:30,670 So, here we are facing a system with two different levels of code signature. 238 00:26:30,670 --> 00:26:33,650 So, does this mean game over? 239 00:26:34,010 --> 00:26:42,330 So, what we first try our first attempt uh, was to to play with the process of zip extraction. 240 00:26:42,330 --> 00:26:43,670 You will understand why. 241 00:26:43,670 --> 00:26:57,810 The very first step that the pro the app store is doing when you install an application is storing the zip file in a temporary area and extract it before because to check the checksum of the file its signature it first need to extract it. 242 00:26:58,470 --> 00:27:04,530 So, this is the piece of code in charge of unzipping the install package. 243 00:27:04,590 --> 00:27:16,690 And if you are good hackers and I believe you all are, you will immediately notice that if you have used a zip entry name you might be able because it's concatenated to do arbitrary file writing. 244 00:27:16,690 --> 00:27:23,530 So, what happens if you had a file to the archive with a zip entry something like dot dot slash dot dot slash something. 245 00:27:24,830 --> 00:27:27,050 So, we wanted to validate this. 246 00:27:27,050 --> 00:27:30,330 Obviously this is not going to work with zip with zip and zip. 247 00:27:30,330 --> 00:27:33,390 You will get the message removing trailing slash or whatever. 248 00:27:33,470 --> 00:27:36,330 But what happens with this dirty Java code? 249 00:27:36,330 --> 00:27:44,490 So, we created a crafted zip archive using any Python lib and you remember we don't yet have control on the device. 250 00:27:44,490 --> 00:27:49,670 So, if we want to see if this was successful we need to write somewhere we can check the file is created. 251 00:27:49,670 --> 00:27:56,450 So, so far the only thing we can do is plug a USB stick and check if we are able to extract a file to a USB stick. 252 00:27:56,450 --> 00:28:05,610 On QNX if you read a little bit of documentation you will find that the location of the USB stick is slash FS USB zero and then your USB device. 253 00:28:05,610 --> 00:28:12,730 So, we created this crafted zip file with a directory traversal uh writing an empty file on the USB stick. 254 00:28:12,730 --> 00:28:13,470 And you know what? 255 00:28:13,470 --> 00:28:14,230 It worked. 256 00:28:14,230 --> 00:28:22,330 So, this means that we have an arbitrary file writing without uh creating any warning on the device once you install a crafted installation package. 257 00:28:22,330 --> 00:28:24,110 So, good start. 258 00:28:24,290 --> 00:28:31,450 But now to take control on the device what we need to do is to be able to copy a file to a place where it can be executed from. 259 00:28:31,450 --> 00:28:33,930 So, it it brings you two problems. 260 00:28:33,930 --> 00:28:43,610 As we said most of the file system of the device are read only because if the device loses power it need to restart without having to do content integrity, file system checking and whatever. 261 00:28:43,610 --> 00:28:48,310 So, most of the file system are read only under normal operation excepting some of them. 262 00:28:48,310 --> 00:28:56,390 And the place where third party apps are stored is a read-write file system because you can install the applications, you can remove them, you can upgrade them. 263 00:28:56,390 --> 00:28:59,130 So, the file system has to be mounted as read-write. 264 00:28:59,130 --> 00:29:02,350 So, we need to write at this place and we need to find this location. 265 00:29:02,670 --> 00:29:08,930 The second thing is so this java archive those are uh Vladan mentioned Xlets. 266 00:29:08,930 --> 00:29:12,790 So, this is one of the G2ME uh implementation. 267 00:29:12,810 --> 00:29:20,830 The problem is we cannot build any application or rebuild the application if we don't have the vendor SDK or API or libraries. 268 00:29:20,910 --> 00:29:26,490 So, this is also one of the problem we have been facing and we will explain how we solved it. 269 00:29:27,270 --> 00:29:31,790 So, it is possible to decompile the java source code but impossible to recompile it. 270 00:29:31,790 --> 00:29:33,050 This is what we just said. 271 00:29:33,050 --> 00:29:35,070 But how about backdooring, patching? 272 00:29:35,230 --> 00:29:46,790 If you all have done some testing training, you have been doing disassembling, x86 modification, changing instruction, repacking and whatever. 273 00:29:46,790 --> 00:29:48,650 And what about doing the same with java? 274 00:29:48,650 --> 00:29:51,930 Because basically java what is that is java source code compiled. 275 00:29:51,930 --> 00:29:53,390 So, it is java bytecode. 276 00:29:53,390 --> 00:29:58,910 It is known as this and this is a portable code to be executed by the java runtime environment. 277 00:29:58,910 --> 00:30:05,570 But basically the bytecode is just assembly but for a different kind of machine and the machine is just java runtime. 278 00:30:05,630 --> 00:30:15,610 So, if you use java bytecode and you modify it with kind of a disassembler which exists, you can patch the java code without needing the SDK nor IPI. 279 00:30:15,770 --> 00:30:16,890 This is what we did. 280 00:30:16,890 --> 00:30:25,990 But remember what we said, the java archive itself is signed which means that if we modify the bytecode, the java runtime environment should refuse to execute it. 281 00:30:25,990 --> 00:30:32,830 So, because we didn't want to lose too much time, our first attempt was just to change a png icon from the java package. 282 00:30:32,830 --> 00:30:41,730 And when we installed the application, it refused to start which means that the jvm, the java virtual machine, refused our modified application which is good. 283 00:30:41,730 --> 00:30:43,890 So, here again, game over? 284 00:30:44,430 --> 00:30:47,090 No, we tried something desperate. 285 00:30:47,670 --> 00:30:52,430 We said, okay the signature is not good but what happens if we just remove the signature? 286 00:30:52,650 --> 00:30:53,830 So, guess what? 287 00:30:54,150 --> 00:30:55,310 It worked. 288 00:30:56,150 --> 00:31:00,330 So, if there is a signature and the signature is not good, reject the program. 289 00:31:00,330 --> 00:31:02,970 But if there is no signature, no problem, just start it. 290 00:31:02,990 --> 00:31:04,130 And it worked. 291 00:31:04,990 --> 00:31:13,190 So, now we are able to write on the file system and we are able to execute malicious code that we have created. 292 00:31:13,190 --> 00:31:15,810 So, the next steps are pretty straightforward. 293 00:31:15,850 --> 00:31:18,690 We just have to create a malicious payload. 294 00:31:18,690 --> 00:31:21,050 So, it is basically java source code. 295 00:31:21,050 --> 00:31:23,910 So, you just use the standard java sdk. 296 00:31:23,910 --> 00:31:27,530 You just have to pay attention to the java minor and major versions. 297 00:31:27,530 --> 00:31:31,370 So, basically your code has to be executable by the target. 298 00:31:31,390 --> 00:31:37,730 So, what you do, you analyze the source code you extracted and you are compiling with the same target version and it should work. 299 00:31:38,050 --> 00:31:44,050 And then you have to hijack the normal execution flow to redirect it to your malicious payload. 300 00:31:44,270 --> 00:31:53,430 So, here we've been using massively the USB connector of the car because we didn't want to recompile at every time our program. 301 00:31:53,430 --> 00:31:58,470 So, what we did is we just did a payload executable script shell which is on the USB stick. 302 00:31:58,470 --> 00:32:00,210 So, if we want to modify it, it's easy. 303 00:32:00,210 --> 00:32:07,090 You just plug the USB stick on your computer, modify the script shell and re-execute the application without having to reinstall or doing nothing. 304 00:32:07,890 --> 00:32:09,850 So, haltering the java bytecode. 305 00:32:09,850 --> 00:32:12,750 I told you modifying the assembly. 306 00:32:12,750 --> 00:32:13,910 So, it's pretty easy. 307 00:32:13,910 --> 00:32:20,990 You just have to basically add the invoke starting static, sorry, method which is calling your payload. 308 00:32:21,790 --> 00:32:25,790 For various reasons, I'm not going into how the GVM works. 309 00:32:25,790 --> 00:32:32,570 You also have to add the instruction to map your assembly code to some virtual line numbers of the source code. 310 00:32:32,570 --> 00:32:34,170 This is the way it works. 311 00:32:34,170 --> 00:32:38,390 So, it's not just one line but three instructions for it to get it work. 312 00:32:38,390 --> 00:32:44,410 But the fundamental instruction here is the invoke static which brings you to your malicious code. 313 00:32:45,890 --> 00:32:55,270 So now, every time the patched application is started from the user interface, it executes the script.sh located on our USB key. 314 00:32:55,370 --> 00:33:03,110 Um, I'm not going through the details because we have performed maybe hundreds or several hundreds attempts because we have no idea on the device. 315 00:33:03,110 --> 00:33:04,530 We are doing blind attack. 316 00:33:04,530 --> 00:33:05,770 We don't have the response. 317 00:33:05,770 --> 00:33:07,990 So, we were having iterative approach. 318 00:33:07,990 --> 00:33:14,270 We were writing commands in the script and collecting the output every time, editing the script and starting over multiple times. 319 00:33:14,510 --> 00:33:20,470 Um, in the end, our goal is still to get uh connectivity to the device with an interactive shell. 320 00:33:20,530 --> 00:33:26,430 So, remember the target device is using QNX and QNX provides something which is called QCon. 321 00:33:26,430 --> 00:33:31,550 And QCon is a debugging daemon for QNX used during the development phases. 322 00:33:31,550 --> 00:33:36,450 It allows you to do some profiling but more interesting for us to do remote code execution. 323 00:33:37,250 --> 00:33:40,830 Uh, problem, the QCon daemon was not part of the build. 324 00:33:40,830 --> 00:33:49,510 Because when you do production build, you remove any useless stuff that you won't need in production because you need to save space and time and whatever. 325 00:33:49,690 --> 00:33:52,110 So, QCon was not part of the build. 326 00:33:52,110 --> 00:33:54,150 But Telnet was for some reason. 327 00:33:54,190 --> 00:34:00,910 So, we couldn't use Telnet as is because Telnet requires authentication and we don't have the root password. 328 00:34:00,910 --> 00:34:02,470 But QCon does not. 329 00:34:02,510 --> 00:34:09,770 What we were able to do because we still don't have QNX license and our managers were not willing to buy us the license. 330 00:34:10,830 --> 00:34:12,890 We found QCon on the web. 331 00:34:12,890 --> 00:34:25,270 We were just downloading a Raspberry Pi image for QNX which was using the same distribution and fortunately the Raspberry Pi is using the same CPU instruction which is ARM v7. 332 00:34:25,290 --> 00:34:30,670 So, we desperately copied the QCon from the device and we executed and it worked. 333 00:34:30,670 --> 00:34:34,650 So, we had a QCon daemon working and we could interact with the device. 334 00:34:34,970 --> 00:34:38,330 So, obviously the first thing we tried is getting the root password. 335 00:34:38,330 --> 00:34:42,850 So, we got the shadow file and we managed to crack the password. 336 00:34:43,450 --> 00:34:46,490 So, now maintaining access and post exploitation. 337 00:34:47,230 --> 00:34:55,310 Because we don't want to repeat all of those steps every time we want to get access to the device, we needed to find a way to get persistent access. 338 00:34:55,490 --> 00:35:00,830 So, basically that means starting automatically either QCon or Telnet or both. 339 00:35:00,830 --> 00:35:03,890 We crack the root password because it's using Descript. 340 00:35:03,890 --> 00:35:07,230 The password length is limited to to eight characters. 341 00:35:07,230 --> 00:35:12,410 So, this could be cracked with a reasonably powerful system within few hours. 342 00:35:12,450 --> 00:35:18,890 This is optional because you can use QCon but it's nice because Telnet is much better for interactive shell than QCon. 343 00:35:18,890 --> 00:35:22,390 Because QCon doesn't have for example the background and whatever. 344 00:35:22,930 --> 00:35:32,750 So, we have to find a script on the device which reside on the read-write partition and which is executed at every boot time. 345 00:35:32,750 --> 00:35:35,550 So, it makes a lot of conditions but we still find one. 346 00:35:35,550 --> 00:35:45,150 When you're doing that, you need to be very careful because if you mess with a startup script, there is no reset to factory option because you will prevent the device to boot properly. 347 00:35:45,150 --> 00:35:52,370 So , you can't even go to upgrade mode and reinstall it and there is no reset to factory that will restore the content of your flash. 348 00:35:52,370 --> 00:35:54,250 So , if you mess, you crash the device. 349 00:35:54,250 --> 00:35:59,830 So, you have to be very careful during this step unless you will get a break. 350 00:36:02,030 --> 00:36:05,510 So, during the post-exploitation step, we were having some fun. 351 00:36:05,510 --> 00:36:11,730 First of all, we realized that all the personal data are stored in SQLite which is very common. 352 00:36:11,730 --> 00:36:14,790 This is the same for Android and and many other systems. 353 00:36:15,210 --> 00:36:34,250 So, what was funny if you are in a rental car and there has been several drivers before you pairing their phone with the system, you will get all their phone's names, MAC address, Bluetooth MAC address, phone books and if it's Android phones, you will also get the content of SMS inbox which is fun. 354 00:36:34,530 --> 00:36:55,490 The second thing is there is a lot of logins so you know where was the car and when with the GPS location, time and date and some events which is also interesting and it has been used in France for a criminal investigation where they could demonstrate that the killer was at the right place because the car had recorded this in the logs. 355 00:36:56,690 --> 00:37:07,490 For example, you can do some tuning, customizing the color, get a different GUI because it's just Flash and HTML5 HMI so you can customize it very easily and it's fun. 356 00:37:08,010 --> 00:37:09,610 And you can also play with the services. 357 00:37:09,610 --> 00:37:17,710 You remember when Vladan introduced the software architecture, it's using Dbus, so a common bus with a lot of services plugged on it. 358 00:37:17,710 --> 00:37:30,990 So, for example, the FM tuner, so from the command line you can change the station, you can change the volume from the command line, you can use the text-to-speech service which is used by the navigation to make the car speech to you and it's very fun. 359 00:37:31,010 --> 00:37:36,690 It's especially very fun if you re-enable Dbus TCP and remote access to the car. 360 00:37:36,690 --> 00:37:47,090 So if it's a rental car and somebody else is connecting the car after you and you get access back to the device, you can talk to the guy for the car which is very fun and that might be very scary for the guy. 361 00:37:48,330 --> 00:37:55,110 Most of the systems, uh, so all those services, Dbus services, are written in Lua. 362 00:37:55,570 --> 00:38:08,690 It's a modified version because everything is non-standard, but if you modified the decompiler, Lua decompiler, to bypass some checksums, some magic numbers, verifications, you are able to reverse it and obtain the source code. 363 00:38:09,130 --> 00:38:12,030 So it was very interesting for the, for the next step. 364 00:38:12,670 --> 00:38:21,010 Now the holy grail, the CAN bus, because all of this, we did it, uh, in the objective of getting access to the CAN bus and to the car critical systems. 365 00:38:22,790 --> 00:38:30,530 CAN bus is allowing access, we've told you, to the engine ECU, something less critical, air conditionings, uh, windows, whatever. 366 00:38:30,770 --> 00:38:33,990 And here we were facing a big frustration. 367 00:38:33,990 --> 00:38:38,490 The system we have tested did not have a full access to the CAN bus. 368 00:38:38,490 --> 00:38:44,830 It was actually going through a gateway and this gateway was responding to a proprietary protocol. 369 00:38:44,950 --> 00:39:00,430 So it was only giving access to, for example, the fuel consumption, the speed of the car, accelerometer, so that, for example, if the car is driving in the tunnel and there is no GPS signal, the GPS navigation system still knows which speed the car is going on. 370 00:39:00,670 --> 00:39:05,630 But it was a lot of frustration for us because we were not able to jump on the CAN bus. 371 00:39:06,570 --> 00:39:18,770 It was even more frustrating because the reason why it was not possible was not for, it was not a security countermeasure, it was not because, it was just because the device had a whole poor device design. 372 00:39:18,770 --> 00:39:24,030 So they had to put this gateway because the device itself didn't have the CAN transceiver on the board. 373 00:39:24,030 --> 00:39:27,030 So it was a lot of frustration for us. 374 00:39:27,350 --> 00:39:35,850 Now because we are at the hardware hacking village and we've many, we've mainly talked about software, we're gonna talk a little bit about hardware. 375 00:39:35,850 --> 00:39:38,670 So the box was dismantled. 376 00:39:38,810 --> 00:39:51,950 We have been using standard tools such as clamps, power supply, logic analyzer, oscilloscope and all the tools you can get to your favorite Chinese provider still. 377 00:39:51,950 --> 00:39:59,590 And we have been able to identify the pins you see, but we had no idea what was their purpose. 378 00:39:59,590 --> 00:40:06,350 So using the logic, the logic analyzer, sorry, we could quickly identify the console. 379 00:40:06,570 --> 00:40:12,250 So it's a serial console at 115 200 bow. 380 00:40:12,770 --> 00:40:16,730 Unfortunately, once you boot, you have authentication required. 381 00:40:16,790 --> 00:40:23,490 You know, if you do this on a standard Linux, you can boot in single user mode just by, by altering the kernel command. 382 00:40:23,490 --> 00:40:26,550 But with QNX, with the IPL, you cannot do that. 383 00:40:26,550 --> 00:40:32,970 The IPL, so initial program loader, which was on the device, did not offer this option. 384 00:40:33,250 --> 00:40:34,950 Authentication was required. 385 00:40:34,950 --> 00:40:37,710 So here we had to have the root password cracked. 386 00:40:37,710 --> 00:40:41,050 Otherwise, we were not able to get into the device. 387 00:40:42,590 --> 00:40:44,790 So this is what I just said. 388 00:40:44,790 --> 00:40:45,790 We had a problem. 389 00:40:45,790 --> 00:40:47,270 We needed this root password. 390 00:40:47,270 --> 00:40:51,290 So what other option doing the physical hardware attack? 391 00:40:51,290 --> 00:40:52,370 There was a FRAM. 392 00:40:52,370 --> 00:40:56,750 So the FRAM is a small uh memory chip using SPI. 393 00:40:57,010 --> 00:41:05,750 Because when the device is booting, it doesn't have the drivers to talk, to communicate with the big flash NAND, it needs an intermediate step. 394 00:41:05,750 --> 00:41:07,870 And this is what the IPL is doing. 395 00:41:07,870 --> 00:41:13,390 The IPL is loading the driver to communicate with the large NAND uh chip. 396 00:41:13,650 --> 00:41:27,470 And we found out that in this small eight kilobytes FRAM, there is obviously some uh persistent information such the MAC address of the device, Bluetooth, Wi-Fi, the serial number, maybe the build version. 397 00:41:27,470 --> 00:41:33,070 But there is mainly the QNX IPL, which is the driver for the next step. 398 00:41:33,070 --> 00:41:50,670 And our idea is if we modify the IPL, if we recompile it, offering the support to boot in single user mode by changing um the initial program from login to just KSH, then we can get access to the device without needing authentication using the serial console. 399 00:41:50,790 --> 00:41:59,670 So here, the work is still in progress, but we found the QNX IPL source code because it is provided by Texas Instrument on their website. 400 00:41:59,670 --> 00:42:04,510 So you just have to modify it, recompile it, and rewrite it in the FRAM chip. 401 00:42:04,550 --> 00:42:09,590 This is not a problem because if you remember, there is no secure boot because everything has been disabled. 402 00:42:09,590 --> 00:42:13,610 So you just have to recompile, write it in the device, and then you're good to go. 403 00:42:14,890 --> 00:42:19,530 Work is still in progress, maybe in a future talk we might be able to demonstrate it. 404 00:42:20,410 --> 00:42:30,390 So just to summarize, because some of you might be a little bit frustrated, our idea is if you are a good software and a good system hacker, don't be afraid of embedded and hardware hacking. 405 00:42:30,390 --> 00:42:45,810 Because here, hardware is just basically a computer, a normal computer with some specificities because the operating system is a bit different, you have a bit of constraint, but it's basically a computer which you can hack using the old techniques you've been learning for 10 years. 406 00:42:46,290 --> 00:42:51,610 So thank you for attending our talk, and if you have any questions, you're welcome. 407 00:43:09,740 --> 00:43:12,880 So the question was, are these disclosed to manufacturers? 408 00:43:12,880 --> 00:43:15,100 As far as we know, yes, they should be. 409 00:43:17,800 --> 00:43:26,400 So it's disclosed to the manufacturer, but if you remember the problem of OEM, the manufacturers don't necessarily have the capability to patch the firmware themselves. 410 00:43:26,400 --> 00:43:41,120 So they might have to go to their OEM provider, ask them to fix the problem, get a build, get it, and push it to the cars in operation, which might be a problem, because you might have maybe one or two millions of cars with vulnerable systems. 411 00:43:45,930 --> 00:43:49,610 Okay, if anybody has any questions later, we will be around. 412 00:43:49,990 --> 00:43:52,670 So thank you everybody, and see you around. 413 00:43:52,670 --> 00:43:53,350 Bye.