00:00:00.400 --> 00:00:02.603 Good morning, everybody. How are we feeling? [ applause & 00:00:02.603 --> 00:00:08.809 cheers ]. >> Nice. If you feel like crap now wait until 00:00:08.809 --> 00:00:14.815 tomorrow. We've heard a lot of problems in the hallway and we 00:00:18.318 --> 00:00:26.994 made some small changes. We made another kind of substantial change today. 00:00:26.994 --> 00:00:37.638 What we did is Defcon 101 that has moved to Balley's gold. 00:00:37.638 --> 00:00:43.877 Track 4 moved to 101 was and if we need to corral all of you 00:00:43.877 --> 00:00:48.348 fine folks, it will be where it used to be. Hopefully this will 00:00:48.348 --> 00:00:54.354 make con injection better today. Some of the big talks Tesla. 00:01:05.332 --> 00:01:11.171 Keep playing along and we will all have a good time. Let's talk 00:01:11.171 --> 00:01:17.978 about mac. How many people use mac? Nice hardware. Depending on 00:01:17.978 --> 00:01:23.984 who you ask, some people have I sense of I'm so safe because I 00:01:26.586 --> 00:01:32.526 have a mac. We will learn once again why that kind of idea is 00:01:32.526 --> 00:01:36.463 false. And we will reinforce the rule of and say this with me, 00:01:36.463 --> 00:01:42.469 "physical access is total access." no. I guess it's early 00:01:45.105 --> 00:01:51.111 still. Let's give our guys a big hand [ applause & cheers ]. >> 00:01:57.484 --> 00:02:03.423 Good morning. Macbook. Also some security. I'm Trammell Hudson 00:02:07.427 --> 00:02:13.033 and I really like to take things apart. I do reverse engineering. 00:02:13.033 --> 00:02:19.039 To let folks run their own programs on it. I really enjoy 00:02:23.043 --> 00:02:26.113 digging through old roms, the old mac hid in their rom back in 00:02:26.113 --> 00:02:32.119 the 1980s. My employer wanted point macbooks and rootkits and 00:02:44.898 --> 00:02:50.537 I was asked to use my reverse engineering skills if it's 00:02:50.537 --> 00:02:54.908 possible to defend against them because we are concern about 00:02:54.908 --> 00:03:00.847 security physical and software. >> I'm Xeno Kovah. Corey Kelly 00:03:04.785 --> 00:03:12.726 Berg can't be with us at the con. We were basically the only 00:03:12.726 --> 00:03:20.267 company focus on pc firmware security. Mac and all the 00:03:20.267 --> 00:03:26.006 peripherals as well. Firmware all that other stuff people talk 00:03:26.006 --> 00:03:30.644 about at conferences and nobody get around checking, that's what 00:03:30.644 --> 00:03:38.285 we do. >> This talk sort of, it started last year at ccc. I 00:03:38.285 --> 00:03:43.824 presented thunderstrike which is now called thunderstrike 1 which 00:03:43.824 --> 00:03:49.930 is the first firmware rootkit for macbook what protection 00:03:49.930 --> 00:03:53.800 apple had on firmware and how we could generate files to write 00:03:53.800 --> 00:04:01.341 into the rom. The day before my talk, the others presented on 00:04:01.341 --> 00:04:04.444 security and I found it interested. And if it's possible 00:04:04.444 --> 00:04:10.450 to import it to mac. And it is possible from windows system and 00:04:24.564 --> 00:04:32.372 mac system. And that's the key message of this talk is that 00:04:32.372 --> 00:04:38.378 most vulnerabilities are agnostic and vendors and 00:04:42.349 --> 00:04:48.355 everyone needs to be aware of that. Thunderstrike 2 is 00:04:51.124 --> 00:04:54.861 improvement of the original thunderstrike and now physical 00:04:54.861 --> 00:04:59.166 access is no longer require to initiate the infection. It's 00:04:59.166 --> 00:05:04.171 possible with remote code execution it can then whatever 00:05:04.171 --> 00:05:11.244 exploit to root. And once root it can install to write listed 00:05:11.244 --> 00:05:17.250 kernel extension which is possible to map flash memory. On 00:05:21.955 --> 00:05:25.992 some machines, macbooks it's able to immediately unlock the 00:05:25.992 --> 00:05:30.463 flash and immediately write into it and this is from 00:05:30.463 --> 00:05:35.802 thunderstrike 1 talk how firmware organized and integrity 00:05:35.802 --> 00:05:42.342 checked. And in this case we've appended payload into the free 00:05:42.342 --> 00:05:47.714 space and we update the crc. While we are scanning the memory 00:05:47.714 --> 00:05:53.854 we scan through bus looking for devices in the option rom and 00:05:53.854 --> 00:06:01.461 write payloads into those. And in this case much like 00:06:01.461 --> 00:06:06.166 thunderstrike 1, we are using the gigabyte ethernet adapter as 00:06:06.166 --> 00:06:11.338 a payload transmission vector. The option rom contains the 00:06:11.338 --> 00:06:17.344 payload and macbook has written payload to flash. When we reboot 00:06:19.446 --> 00:06:24.150 the machine we will see the thunderstrike logo come up. We 00:06:24.150 --> 00:06:26.686 are deliberately not be sith. This is from the first 00:06:26.686 --> 00:06:32.692 introduction that it executes. The viral transmission means we 00:06:42.168 --> 00:06:46.439 can put the laptop aside and share with another one. Now the 00:06:46.439 --> 00:06:52.445 efi firmware loads the exploits from the option rom and in this 00:06:58.685 --> 00:07:03.823 mac it's not able to unlock the flash immediately. What it can 00:07:03.823 --> 00:07:08.995 use is the darth anonymous attack to hook the sc boot 00:07:08.995 --> 00:07:15.735 script. So then kernel boots normally. And at some point 00:07:15.735 --> 00:07:21.741 later the system goes to sleep. Either via software or the user 00:07:24.244 --> 00:07:29.316 poses it and the vulnerability is when the cpu enters the low 00:07:29.316 --> 00:07:33.553 power bits all the flash protection bits gets reset. So 00:07:33.553 --> 00:07:39.559 when the system wakes back up the sc script writes 00:07:43.697 --> 00:07:46.700 thunderstrike into the motherboard boot rom. And this 00:07:46.700 --> 00:07:52.772 is not on the hardware so you reinstall os x doesn't fix it. 00:07:52.772 --> 00:07:58.778 And swap to a new computer, you can reinfect the peripheral you 00:08:01.581 --> 00:08:08.989 would take. So at this point we are not still think. When the 00:08:08.989 --> 00:08:16.062 system reboot you see the logo. So [ inaudible ] few years ago 00:08:16.062 --> 00:08:22.068 to really do a good job from hiding attempts undetected. This 00:08:24.571 --> 00:08:29.442 laptop is now infected. And the other apart infection that's new 00:08:29.442 --> 00:08:34.247 that it's watching or clearing thunderbolt after it gets 00:08:34.247 --> 00:08:39.018 plugged in and it writes exploits into those adapter so 00:08:39.018 --> 00:08:43.990 that they can then spread to other machines. Possibly 00:08:43.990 --> 00:08:50.463 crossing air gap security. What we've demonstrated with this 00:08:50.463 --> 00:08:53.733 proof of concept. Firmware starts exploits is able to write 00:08:53.733 --> 00:08:55.735 into the motherboard, and infect thunderbolt and other removal 00:08:55.735 --> 00:08:58.004 option rom and hook resume script and write themselves into 00:08:58.004 --> 00:09:03.943 the boot flash of the machine and continue the infection. >> 00:09:08.748 --> 00:09:14.754 so that's the black magic attacks and let's get into how 00:09:18.525 --> 00:09:21.060 it works. The key point is, it cross many systems. They would 00:09:21.060 --> 00:09:27.067 effect many pc and affects mac as well. Background on the 00:09:33.106 --> 00:09:39.112 transition of firmware. You will hear us use the term or when we 00:09:41.414 --> 00:09:47.420 say bios we mean genetically firmware. So intel started efi 00:09:49.889 --> 00:09:52.325 back in the late 90s. They try to create a non backward 00:09:52.325 --> 00:09:58.331 compatible is64 architecture. They want to get rid of this and 00:10:03.102 --> 00:10:06.239 things from the '80s. For new architecture, new modular 00:10:06.239 --> 00:10:14.013 firmware. They did that. When apple moved from power pc chip 00:10:14.013 --> 00:10:20.887 to intel chip back in early 2000. This new type of firmware 00:10:20.887 --> 00:10:24.624 that intel recommends. So in 2005 intel was trying to bring 00:10:24.624 --> 00:10:30.630 people in the adaptation. So they created the uefi to collect 00:10:37.437 --> 00:10:43.109 up many more players get all their buy in and contributions 00:10:43.109 --> 00:10:49.115 and people start using it. The original 1.1 and new people are 00:10:51.117 --> 00:10:56.289 talking about the efi development kit. So, of course, 00:10:56.289 --> 00:11:00.760 when got industry buy in they didn't just go ahead and rewrite 00:11:00.760 --> 00:11:04.397 everything from scratch. They just continue to evolve with 00:11:04.397 --> 00:11:10.637 people's input. And apple's implementation to generally 00:11:10.637 --> 00:11:13.473 diverge from the rest of the world but still there's going ob 00:11:13.473 --> 00:11:19.479 millions of lines of code that are similar. The way that the 00:11:21.581 --> 00:11:28.521 whole uefi system there's a single source implementation edk 00:11:28.521 --> 00:11:34.527 2. Efi developer kit 2. Which is then modified. They add value to 00:11:40.733 --> 00:11:46.306 the system. And compete amongst what new features that the other 00:11:46.306 --> 00:11:52.912 guys haven't added and that's how they will get oem to buy 00:11:52.912 --> 00:11:57.550 them. If they have enough bios the oem be do further 00:11:57.550 --> 00:12:03.056 customization on this. That means fixes that happens 00:12:03.056 --> 00:12:10.997 open-source implementation take a long time to trickle down. A 00:12:10.997 --> 00:12:17.804 big point of this talk is nobody a unique and beautiful 00:12:17.804 --> 00:12:23.076 snowflake. Everybody looks the same. So we took a machine, we 00:12:23.076 --> 00:12:29.082 did analysis, we show all of these places, systems that are 00:12:31.317 --> 00:12:37.323 out there today. We analyze it and control float graph, it's 00:12:39.759 --> 00:12:43.296 bigger because it has comments in it. And you take macbook air, 00:12:43.296 --> 00:12:49.335 the thing is they look all the same. The control flow graph is 00:12:49.335 --> 00:12:55.341 the same, there has to be level of similarity for the systems to 00:12:58.144 --> 00:13:02.181 implement that firmware interface. There's a speck out 00:13:02.181 --> 00:13:06.452 there that says how that works. So call the same function in 00:13:06.452 --> 00:13:12.458 same order. No firmware if efi derived is unique and beautiful 00:13:17.563 --> 00:13:26.305 snowflake. That means there's shared vulnerability. Does it 00:13:26.305 --> 00:13:37.250 effect mac? Yes. This means that all these vulnerabilities which 00:13:37.250 --> 00:13:44.357 are out there and a lot of vendors pull in the code and fix 00:13:44.357 --> 00:13:48.261 and hear there's this pc effect and maybe it doesn't effect me. 00:13:48.261 --> 00:13:55.301 I'm a mac. Beyond this there's problem. Intel on protection 00:13:55.301 --> 00:14:04.310 mechanism that all vendors should use. Decade of legacy 00:14:04.310 --> 00:14:08.347 decisions which lead to inherent built in vulnerability. So we've 00:14:08.347 --> 00:14:15.388 considered a bunch of vulnerabilities. We took old 00:14:15.388 --> 00:14:21.461 works and ask do these apply to all macs. Publically disclose at 00:14:21.461 --> 00:14:26.933 conferences and yet when we say let's take a look at the macs 00:14:26.933 --> 00:14:32.772 are they still there? Yes they are. That's not cool. So the 00:14:32.772 --> 00:14:35.908 speed race vulnerability. This is vulnerability in intel 00:14:35.908 --> 00:14:40.847 hardware. This is not the kind of thing you would expect any 00:14:40.847 --> 00:14:45.518 vendor to say I'm not vulnerable to. The vulnerability is in 00:14:45.518 --> 00:14:52.692 intel and the fix is to use intel protection bit. The 00:14:52.692 --> 00:14:55.795 hardware race condition. And we will see why exactly that 00:14:55.795 --> 00:15:00.733 happens. If you look at the bios control in intel hardware this 00:15:00.733 --> 00:15:05.004 is the oldest protection mechanism for firmware: it says 00:15:05.004 --> 00:15:09.275 am I allow to write to the bios. There's a bios enable bit. That 00:15:09.275 --> 00:15:12.145 must be set before you are allowed to write to the bios. If 00:15:12.145 --> 00:15:21.154 a vendor wants to stop malicious attacker to write in that, 00:15:21.154 --> 00:15:26.726 everybody this to bio lock enable bit. I want to cause the 00:15:26.726 --> 00:15:30.930 system interrupt and system management mode, I want to catch 00:15:30.930 --> 00:15:37.003 anyone set the bios set enable and probably stop them from 00:15:37.003 --> 00:15:42.108 writing into the bios. So that's the oldest common functionality. 00:15:42.108 --> 00:15:47.446 What this disclose is there's hardware race condition once we 00:15:47.446 --> 00:15:53.452 have multithreaded hardware, back then it was single, core 00:15:53.452 --> 00:15:58.724 hardware so that protection mechanism worked great. Once you 00:15:58.724 --> 00:16:05.765 have multi and hyper hardware you can have an attacker just 00:16:05.765 --> 00:16:10.002 continuously hammers on the write enable bit. Set it 00:16:10.002 --> 00:16:14.640 writable and in a separate thread they continuously say 00:16:14.640 --> 00:16:20.780 write this valuable to the bios. And the core race these two 00:16:20.780 --> 00:16:27.620 threads continually write to the bios and we've found they will 00:16:27.620 --> 00:16:35.294 succeed. There's no penalty for failure and if you do long 00:16:35.294 --> 00:16:44.470 enough you are almost guarantee to win. Corey talked about this. 00:16:44.470 --> 00:16:52.111 This was disclosed privately to intel so this has been out there 00:16:52.111 --> 00:17:03.656 for quite a while. Intel response to this okay. Well we 00:17:03.656 --> 00:17:06.526 recognize this can be potentially a problem but we've 00:17:06.526 --> 00:17:13.332 added this protection bit to our platform controller hub. Even if 00:17:13.332 --> 00:17:21.707 it's equal to one somehow I will stop attacker write the bios. So 00:17:21.707 --> 00:17:26.746 this bit says you might be at smm before you can do that. They 00:17:26.746 --> 00:17:31.250 just race from kernel space and set and write to the bios. This 00:17:31.250 --> 00:17:34.553 is basically the intel say it should be and recommends bios 00:17:34.553 --> 00:17:39.258 vendor set their protection bits. So you got layers of 00:17:39.258 --> 00:17:46.365 protection each of which provide protection value. They get to 00:17:46.365 --> 00:17:51.671 amend attempt to write to the bios and that will be stopped 00:17:51.671 --> 00:17:58.711 and check. The speed racer bypasses that. If vendor sets 00:17:58.711 --> 00:18:06.852 smm-vwp you must be in that before you can write. And 00:18:06.852 --> 00:18:10.923 protective range register and these allow the bios maker to 00:18:10.923 --> 00:18:23.102 set in none contiguous places to write firmware, none writable. 00:18:23.102 --> 00:18:28.341 It will be lock down and you want that to be stopping 00:18:28.341 --> 00:18:33.913 attacker to write into the flash chip. And when we go back and 00:18:33.913 --> 00:18:39.051 let's consider this and see if apple is vulnerable. We check 00:18:39.051 --> 00:18:41.988 vulnerability disclosure. The nice thing about vulnerability 00:18:41.988 --> 00:18:48.060 disclosure, for our coordination, even when we have 00:18:48.060 --> 00:18:54.033 cv available to us. It tells us these vendor are vulnerable and 00:18:54.033 --> 00:18:57.203 set vulnerable. It's nice because certain handles 00:18:57.203 --> 00:19:02.708 coordination for you and asks different vendor, are you 00:19:02.708 --> 00:19:08.247 vulnerable. Usually they will say yes and there's a fix on 00:19:08.247 --> 00:19:13.953 their full disclosure and some will say no. And some vendor 00:19:13.953 --> 00:19:21.560 will say not say anything. If they don't care about 00:19:21.560 --> 00:19:30.336 disclosure, they are probably vulnerable. We look at apple, it 00:19:30.336 --> 00:19:37.043 says it's not effective. All the intel cpu have this. If vendor 00:19:37.043 --> 00:19:46.218 don't respond to these and don't hold them accountable, they just 00:19:46.218 --> 00:19:57.329 airport going to say anything. So we need to check is apple 00:19:57.329 --> 00:20:11.977 vulnerable to this problem. So you go in, you look at control 00:20:11.977 --> 00:20:14.947 register, the bios controller register set to 8. The result is 00:20:14.947 --> 00:20:17.049 bios lock enable not set. Smm vwp not set. So they are not 00:20:17.049 --> 00:20:20.820 using those protections. In the technically accurate, apple is 00:20:20.820 --> 00:20:27.560 not vulnerable to speed racer because you don't need to use 00:20:27.560 --> 00:20:29.361 exploit to get around protection that's just are not there. [ 00:20:29.361 --> 00:20:33.165 applause ] so this is what protection looks like on a new 00:20:33.165 --> 00:20:43.209 mac system. I went to buy the new mac mini. They have a single 00:20:43.209 --> 00:20:50.015 point of failure. And beyond the that there's gap in this region. 00:20:50.015 --> 00:20:56.355 The first gap points at efi variable. You can twiddle and 00:20:56.355 --> 00:20:59.258 even some variable prevent access by e. Rom. If an attacker 00:20:59.258 --> 00:21:07.233 knows how to write to the command chip, write directly to 00:21:07.233 --> 00:21:10.336 the flash chip and modify any variables that they want. Beyond 00:21:10.336 --> 00:21:15.574 that there's additional gap it within that protection and we 00:21:15.574 --> 00:21:20.346 don't know what that does as testing this attack, we go ahead 00:21:20.346 --> 00:21:27.653 corrupt that and write all x into that. The system a break. 00:21:27.653 --> 00:21:32.291 And it will never ever boot again. That's undesirable 00:21:32.291 --> 00:21:46.805 behavior. There's a video you can online. So we decided to 00:21:46.805 --> 00:21:55.447 skip that. The second thing we need to look at. Darth 00:21:55.447 --> 00:21:59.451 vulnerability. Darth anonymous vulnerability. We saw the 00:21:59.451 --> 00:22:01.620 deflection mechanism still has the protected ranger registers 00:22:01.620 --> 00:22:08.561 attacker would like to get around that modify the code and 00:22:08.561 --> 00:22:15.401 stuff. That's actually what the darth jedi attack because 00:22:15.401 --> 00:22:20.606 basically darth plagueis defeated darth venamis, killed 00:22:20.606 --> 00:22:27.346 him and continued to resurrect him and kill him and resurrect 00:22:27.346 --> 00:22:31.450 him. I'm not, I don't know the exact story and it's been said 00:22:31.450 --> 00:22:36.822 that just like maybe you didn't kill him. Put him in the coma. 00:22:36.822 --> 00:22:43.229 The analogy is we want to continuously kill and resurrect 00:22:43.229 --> 00:22:48.167 the system and find the vulnerability. So the darth 00:22:48.167 --> 00:22:55.941 venamis vulnerability is the situation when you put the 00:22:55.941 --> 00:23:01.847 system to sleep, not hibernate, not deep sleep, close the lid 00:23:01.847 --> 00:23:05.851 you go into scpi, low power mode, power off much of the 00:23:05.851 --> 00:23:12.825 motherboard as it can. Some of the stuff that it powers off 00:23:12.825 --> 00:23:18.430 parts of the chip says which allowed these protected bits 00:23:18.430 --> 00:23:22.268 become unset. Low power you lose all of your electricity and the 00:23:22.268 --> 00:23:28.040 bits get [ no audio ]. This can be manipulated by an attacker. 00:23:28.040 --> 00:23:31.410 This vulnerability was disclosed to cert. And the newly formed 00:23:31.410 --> 00:23:45.024 uefi response team. And publically disclose December of 00:23:45.024 --> 00:23:49.261 2014 trammell said the day before his talk. So I recommend 00:23:49.261 --> 00:23:53.232 you go watch the actual talk. At the highest level the detail of 00:23:53.232 --> 00:23:56.769 darth venamis is this: a normal system when it's booting is 00:23:56.769 --> 00:24:02.541 going to take that top path. The normal boot path you are going 00:24:02.541 --> 00:24:06.145 to execute efi phases. As the system is booting to save 00:24:06.145 --> 00:24:14.453 information which hardware configuration bit is set to 00:24:14.453 --> 00:24:18.757 cheat sheet. Boot script s 3 boot script stored in rom 00:24:18.757 --> 00:24:23.829 somewhere. It is stored to unprotected rom. When you go 00:24:23.829 --> 00:24:27.032 into sleep and wake back up, resume execution path said 00:24:27.032 --> 00:24:31.937 instead of executing all of my normal boot code which from 00:24:31.937 --> 00:24:36.909 resume from sleep as a normal boot, I just want to consult the 00:24:36.909 --> 00:24:40.846 cheat sheet and it has these type of option you can write to 00:24:40.846 --> 00:24:46.285 os and memory. Go down the line and interpret this boot script 00:24:46.285 --> 00:24:53.692 it will make the hardware reconfigure the same way as the 00:24:53.692 --> 00:24:59.798 full boot but much, much faster. Quick wake from sleep. There's a 00:24:59.798 --> 00:25:06.505 problem. The vulnerability is twofold. One the script stored 00:25:06.505 --> 00:25:09.508 in none protected rom and why? Because you look at the speck 00:25:09.508 --> 00:25:12.778 document from 2004, you can see they are recommending in ecpi 00:25:12.778 --> 00:25:18.884 none volatile memory. That's just memory like any other 00:25:18.884 --> 00:25:22.888 memory an attacker can attack and compromise. There's this 00:25:22.888 --> 00:25:31.630 catch all opcode. This dispatch opcode says it's too complicated 00:25:31.630 --> 00:25:36.802 to combination of reads and writes. So instead I'm going to 00:25:36.802 --> 00:25:41.573 jump off and I'm going to jump to some arbitrary by the 00:25:41.573 --> 00:25:46.879 dispatch opcode. So a script arbitrary code plus somewhere 00:25:46.879 --> 00:25:51.316 rom means an attacker can compromise the script, get rid 00:25:51.316 --> 00:25:55.587 of the protective range registers and have access to 00:25:55.587 --> 00:25:58.924 everything. Get access to the code, right from the very 00:25:58.924 --> 00:26:02.861 beginning the codes are compromise to the attacker. 00:26:02.861 --> 00:26:06.765 So the result is the darth venamis attack. So when we go 00:26:06.765 --> 00:26:11.069 back did apple say they were vulnerable or not. Look at the 00:26:11.069 --> 00:26:16.074 full disclosure in this case like our past our is weird is 00:26:16.074 --> 00:26:19.211 effected vendors only the vendors replied and effected. So 00:26:19.211 --> 00:26:31.523 at first we didn't know. But by running to ground that sith 00:26:31.523 --> 00:26:37.196 hadn't contacted them. It's coordinated uefi security 00:26:37.196 --> 00:26:43.068 response team. And since apple is uefi board member you would 00:26:43.068 --> 00:26:47.873 expect them to listen to the response team, right? So again, 00:26:47.873 --> 00:26:50.776 the big finding from this is that previously trammel's attack 00:26:50.776 --> 00:26:59.084 show that you can write apple firmware. There had been some 00:26:59.084 --> 00:27:04.123 thought that somehow apple firmware was protected trammel 00:27:04.123 --> 00:27:09.795 showed that that's not the case. And once you do that you can 00:27:09.795 --> 00:27:16.301 write do it. But thunderstrike 1 requires physical access with 00:27:16.301 --> 00:27:21.073 the thunderbolt device. So darth said no more physical access is 00:27:21.073 --> 00:27:24.409 required anyone who can get remote access can manipulate 00:27:24.409 --> 00:27:29.915 script in memory and sleep and wake back up, you can compromise 00:27:29.915 --> 00:27:39.591 it. Sorry it's so small. This is showing just a plain jane 00:27:39.591 --> 00:27:51.103 software attack for this. Once you use a root privilege 00:27:51.103 --> 00:27:53.305 exploits. You are protecting the code. But then you find the boot 00:27:53.305 --> 00:27:58.277 script in memory. You find one of these dispatch opcode and you 00:27:58.277 --> 00:28:01.547 point it at some other address where you are going to put code. 00:28:01.547 --> 00:28:08.086 So do that insert code into that address. The code we did here 00:28:08.086 --> 00:28:11.390 was to set a lock early. So basically the bootscript is 00:28:11.390 --> 00:28:17.296 going down and interpreting down. The protection range 00:28:17.296 --> 00:28:22.167 register somehow low. Somewhere higher is dispatcher opcode. So 00:28:22.167 --> 00:28:29.708 we lock down the register and say no one is allow to modify 00:28:29.708 --> 00:28:34.980 and do doing they get lock into default zero when they clear, 00:28:34.980 --> 00:28:45.724 because you lost power. Back to sleep and wake back up. It can 00:28:45.724 --> 00:28:54.900 be changed until the next. After that we've taken out protective 00:28:54.900 --> 00:28:57.970 range register. That means go to in the attacker can write 00:28:57.970 --> 00:29:03.875 anything into the firmware. Here we show hello world, where we 00:29:03.875 --> 00:29:07.412 knew it wouldn't break the system. Another vulnerability 00:29:07.412 --> 00:29:12.384 similar to this is called [ inaudible ] so we actually, in 00:29:12.384 --> 00:29:18.724 the past and other vendors and told cert about it. The vendor 00:29:18.724 --> 00:29:28.267 fixed before cert. And it's been fixed. So they post this thing. 00:29:28.267 --> 00:29:37.809 And he found the same vulnerability on apples so pay 00:29:37.809 --> 00:29:45.117 zero came and found vulnerability. Deer cert you can 00:29:45.117 --> 00:29:55.427 start coordinating this now. Pay zero didn't gave it a name. This 00:29:55.427 --> 00:30:09.207 poise kiss wakes you from sleep. He had seen the title for this 00:30:09.207 --> 00:30:11.810 talk. Thunderstrike 2 sith strike. Sith strike probably has 00:30:11.810 --> 00:30:18.684 something to do darth venamis. We were probably saying 00:30:18.684 --> 00:30:24.523 thunderstrike, sith, darth venamis. So he has been looking 00:30:24.523 --> 00:30:27.893 at that on mac and using proof of concept code that was put out 00:30:27.893 --> 00:30:32.064 there, and when he looked into this he found the prince harming 00:30:32.064 --> 00:30:37.769 vulnerability. And it's more severe than darth venamis 00:30:37.769 --> 00:30:42.174 because you didn't have to do anything special as attacker you 00:30:42.174 --> 00:30:46.945 just put the system to sleep and wake back up and everything is 00:30:46.945 --> 00:30:52.617 unprotected. They are not setting any protection bit on 00:30:52.617 --> 00:30:58.223 resume. So he was concerned about this as a mac user. It 00:30:58.223 --> 00:31:02.828 leaves something to desired when an attacker to put your machine 00:31:02.828 --> 00:31:10.302 to sleep and wake back up and write into your firmware. We had 00:31:10.302 --> 00:31:14.306 not reported this to apple. Because we were testing on our 00:31:14.306 --> 00:31:20.412 macbook pro 112s and turn out to not have vulnerability. So 00:31:20.412 --> 00:31:26.485 prince harming was fixed at some point. So apple basically 00:31:26.485 --> 00:31:33.125 silently fixed this at some point and they didn't back port 00:31:33.125 --> 00:31:36.995 it to older machine. What that meant was accidentally this blog 00:31:36.995 --> 00:31:46.171 post went live. He thought apple had already known about it. No. 00:31:46.171 --> 00:31:49.474 Apple didn't know about it. Apple zero day. Now anyone can 00:31:49.474 --> 00:31:55.180 break into the firmware. The question is why are there zero 00:31:55.180 --> 00:32:04.122 days that can be found on mac. Now there's a full disclosure 00:32:04.122 --> 00:32:08.393 vulnerability out there in the wild, apple turned around a 00:32:08.393 --> 00:32:15.100 patch relatively quickly. They put out uefi update. They 00:32:15.100 --> 00:32:19.971 patched 24 different models and the models they passed were 00:32:19.971 --> 00:32:24.376 basically from 2011 and newer. If you have that system, 00:32:24.376 --> 00:32:31.583 hopefully you are applying apple updates as you go. But how did 00:32:31.583 --> 00:32:41.393 they fix this? By improved locking. What does that mean? >> 00:32:41.393 --> 00:32:46.932 what is this improved locking? You dug into their update. They 00:32:46.932 --> 00:32:51.870 moved the protective range register and flash lock down 00:32:51.870 --> 00:32:57.008 register setting out of the boot script and in pei before they 00:32:57.008 --> 00:33:01.046 executed it. This is the right place to do it, because you 00:33:01.046 --> 00:33:07.085 don't have the protective range register ever unset. This 00:33:07.085 --> 00:33:12.724 prevents the demo that we showed to write directly to the boot 00:33:12.724 --> 00:33:15.594 flash. However, they are still not using the bios control bits. 00:33:15.594 --> 00:33:18.930 So it's still possible to break the system. The s3 bootscript is 00:33:18.930 --> 00:33:27.873 still unprotected. There's also some features that we discussed 00:33:27.873 --> 00:33:36.915 in the darth venamis attack, they were left unlock which can 00:33:36.915 --> 00:33:45.690 then get code execution in-system management mode. And 00:33:45.690 --> 00:33:52.731 the worry is [ no audio ] usbc is protecting the bootscript in 00:33:52.731 --> 00:33:57.102 some ways this means that there are now two classes of machine 00:33:57.102 --> 00:34:04.075 some are vulnerable to darth venamis and some are not. >> the 00:34:04.075 --> 00:34:09.414 4th vulnerability that we take advantage of is really legacy 00:34:09.414 --> 00:34:19.524 feature of option rom and this goes back to original pc 8080 00:34:19.524 --> 00:34:21.526 the bios in that era socketed rom chip and there's also empty 00:34:21.526 --> 00:34:26.665 socket on motherboard or optional expansion feature. 00:34:26.665 --> 00:34:29.768 Basic interpreter or hardware controller. The is expansion 00:34:29.768 --> 00:34:33.438 bust also allow cards to contain option rom. This allow card into 00:34:33.438 --> 00:34:42.480 your system bios able to play onto it. Unfortunately because 00:34:42.480 --> 00:34:50.188 this gives you code execution early in the boot process it's a 00:34:50.188 --> 00:35:01.566 great place to put that and this is not a new idea. John heisman 00:35:01.566 --> 00:35:07.038 present in 2007 pci card and in 2012 snare gave an amazing talk 00:35:07.038 --> 00:35:13.578 at blackhat showing how to build efi rootkit out of ethernet 00:35:13.578 --> 00:35:22.887 option rom. His talk started my research into macbook security. 00:35:22.887 --> 00:35:27.625 Intel realized that this was a problem. Trustworthy booth. So 00:35:27.625 --> 00:35:32.230 part of the secure boot they require all expansion rom 00:35:32.230 --> 00:35:39.270 cryptographically signed publically stored in the 00:35:39.270 --> 00:35:46.911 motherboard. And they required this for secure boot uefi 2.3. 00:35:46.911 --> 00:35:53.418 Apple frozen on uefi 1.10 which doesn't support the boot concept 00:35:53.418 --> 00:35:59.691 and they still unconditional load option rom from internal 00:35:59.691 --> 00:36:04.496 and external device like thunderbolt. Heisman's talk in 00:36:04.496 --> 00:36:09.801 2007 despite snare's demo in 2012 and despite my 00:36:09.801 --> 00:36:14.973 thunderstrike demo in 2014. And what it really means is 00:36:14.973 --> 00:36:17.709 architectural fix. The security conscious user need to be able 00:36:17.709 --> 00:36:22.814 to disable option rom or white list option rom or signature on 00:36:22.814 --> 00:36:30.522 option rom. There are quite a few steps to be done there. In 00:36:30.522 --> 00:36:36.394 my talk thunderstrike I hypothesize that option rom use 00:36:36.394 --> 00:36:43.001 malware virally. And this is improvement over john heisman's 00:36:43.001 --> 00:36:50.708 talk on cpa talk on system. Devices can be shared between 00:36:50.708 --> 00:36:56.214 machines. At the time of my talk it was mostly hypothetical 00:36:56.214 --> 00:37:00.218 because to rewrite the option rom so far to the move to dos 00:37:00.218 --> 00:37:09.394 and adapter what we realize is the linux perl bar code 57 00:37:09.394 --> 00:37:13.865 device driver had all of the hooks for read and write in the 00:37:13.865 --> 00:37:19.604 option rom. So we import that to os x, and now it's possible to 00:37:19.604 --> 00:37:27.445 install new option rom into these removal device just are 00:37:27.445 --> 00:37:35.687 root access. In the dxe environment so it's possible for 00:37:35.687 --> 00:37:39.090 thunderstrike to rewrite from the boot rom. So the way that 00:37:39.090 --> 00:37:43.995 this could be use maliciously is you can remove shell somehow. 00:37:43.995 --> 00:37:49.167 Whatever exploit. Install this white listed driver and you are 00:37:49.167 --> 00:37:53.004 able to flash code into the thunderbolt device. We use 00:37:53.004 --> 00:37:58.276 thunderbolt device because they are very easy and very small and 00:37:58.276 --> 00:38:04.849 cheap. But lots of other devices have option rom. A lot of wifi, 00:38:04.849 --> 00:38:14.092 gpu and satellite controller ssd have them as well. >> so again 00:38:14.092 --> 00:38:18.329 back to the main point of the talk. Uefi vulnerabilities 00:38:18.329 --> 00:38:21.766 shared across many systems. It's highly likely any vulnerability 00:38:21.766 --> 00:38:23.768 found is going to report everywhere. So ultimately in 00:38:23.768 --> 00:38:29.374 this work we can fix vulnerabilities that were all 00:38:29.374 --> 00:38:34.312 old and publically disclosed and privacy disclosed. Which of 00:38:34.312 --> 00:38:50.428 these effect the mac. Prince hamming. That's completely gone 00:38:50.428 --> 00:38:59.404 now. Darth c. Godspeed racer were still vulnerable. Apple 00:38:59.404 --> 00:39:06.978 doesn't use that. The queen's gambit we introduced before. 00:39:06.978 --> 00:39:17.522 Corey presented before because it affected hundreds of pc. [ 00:39:17.522 --> 00:39:23.995 inaudible ] apples is working on a patch for them. So although 00:39:23.995 --> 00:39:27.165 they patched the basic thing that allow our proof of concept 00:39:27.165 --> 00:39:31.803 thunderstrike this vulnerability can do exactly the same thing. 00:39:31.803 --> 00:39:39.811 >> so that's out there in open. So previously invisible thing if 00:39:39.811 --> 00:39:43.047 you break in smm that doesn't imply you can break into bios. 00:39:43.047 --> 00:39:56.394 You can break into bios from smm in some systems just to say that 00:39:56.394 --> 00:40:04.502 this was a possibility. Another thing is vulnerable common to 00:40:04.502 --> 00:40:08.172 uefi system. Configuration bit system which will effect secure 00:40:08.172 --> 00:40:17.382 boot. Apple doesn't have one. Even if they have this variable 00:40:17.382 --> 00:40:19.183 it doesn't matter. A lot of pc and if you corrupt the variable, 00:40:19.183 --> 00:40:30.395 you can corrupt the system. This vulnerability does not effect 00:40:30.395 --> 00:40:34.632 apple. They don't use this at all. 5/6 public old vulnerable 00:40:34.632 --> 00:40:35.700 all effected apple system. That's not what we wanted to 00:40:35.700 --> 00:40:42.674 find but that's what we found. What can vendors do. We go 00:40:42.674 --> 00:40:48.212 around and help vendors understand intel recommendation 00:40:48.212 --> 00:40:50.148 should thought of requirement. The reason why intel said you 00:40:50.148 --> 00:40:53.584 should set all these protections. You don't have a 00:40:53.584 --> 00:40:57.388 single point of failure when you are only using one of them. A 00:40:57.388 --> 00:41:02.994 vendor has to test all of these. Go look at the full disclosure 00:41:02.994 --> 00:41:07.699 whether you are currently running at and your vendor 00:41:07.699 --> 00:41:16.274 doesn't respond to vulnerability, they are probably 00:41:16.274 --> 00:41:22.814 vulnerable. They've been privately passed around in order 00:41:22.814 --> 00:41:26.984 to fix vulnerability before they ship and they made it public for 00:41:26.984 --> 00:41:34.625 researchers to play around with. You have to write it from uefi 00:41:34.625 --> 00:41:38.196 or install windows. If you run it chip this system is 00:41:38.196 --> 00:41:43.901 vulnerable. If apple were using chip sec the system is 00:41:43.901 --> 00:41:46.771 vulnerable. And things like smm lockbox, the chip is not just 00:41:46.771 --> 00:42:00.918 sitting around, you lock into system management mode. At the 00:42:00.918 --> 00:42:06.124 original darth venamis attack they showed that some intel 00:42:06.124 --> 00:42:10.294 system were using that to hide your stuff away in rom if it 00:42:10.294 --> 00:42:17.869 jumps and read unprotected memory. Intel boot card has 00:42:17.869 --> 00:42:27.011 stronger root of trust. Instead of the instruction coming from 00:42:27.011 --> 00:42:30.982 potentially manipulatable firmware, come from sign code 00:42:30.982 --> 00:42:36.220 cpu verify the digital signature on that code. It's stronger up 00:42:36.220 --> 00:42:43.795 front. Option rom. Digital signature are the good first 00:42:43.795 --> 00:42:49.100 step is not end step. And it would be nice you are setting a 00:42:49.100 --> 00:42:53.271 firmware password maybe you wouldn't like all of these 00:42:53.271 --> 00:42:58.776 un-trusted and unsigned code be sucked in and introduced in the 00:42:58.776 --> 00:43:04.082 bios. Those who are not bios engineers. What can you do? It's 00:43:04.082 --> 00:43:08.619 not about hard drive, ram, memory forensics. You have to do 00:43:08.619 --> 00:43:24.902 firmware forensics. No one ever seem to do anything about it and 00:43:24.902 --> 00:43:29.474 provide availability for this. But in order to not leave you 00:43:29.474 --> 00:43:38.182 empty handed here we but out an option rom checker. You plug in 00:43:38.182 --> 00:43:41.619 ethernet adapter into your machine and then run the script 00:43:41.619 --> 00:43:47.225 we've provided using the stuff that's imported from linux dump 00:43:47.225 --> 00:43:49.894 the option rom. It turns out everyone's option rom that we've 00:43:49.894 --> 00:44:01.005 seen is they all look the same. This gives you first order. If 00:44:01.005 --> 00:44:09.714 you check yours and there's an error either a our tools are 00:44:09.714 --> 00:44:16.654 broken, it's possible, or b you actually have some attacks. The 00:44:16.654 --> 00:44:21.893 false positive or true positive, we like to hear about it. The 00:44:21.893 --> 00:44:26.864 other thing you can do, is go get smart on firmware, so learn 00:44:26.864 --> 00:44:31.102 about rootkit, security training, free classes get smart 00:44:31.102 --> 00:44:34.872 on things and go do your own firmware security research. >> 00:44:34.872 --> 00:44:36.207 thank you so much for attending our talk this early saturday 00:44:36.207 --> 00:44:42.213 morning. [ applause ]