Please join me in welcoming Matt King. Thank you. So I'm here to talk today about a tool I wrote called micro renovator. It's for patching CPU micro code and I really hope none of you have to use it. So I'm Matt. Some quick things about me that become relevant real quick here. I used to actually work designing CPUs. Currently I work at a cloud doing hardware security things. And in between I did product security validation for desktop CPUs for a very popular CPU vendor. And about that. Sorry. I may have missed something. Didn't see it coming. So this was a really big deal. The bugs were actually in the hardware. Real hard to fix. So I was able to fix it. And then I was able to fix it. But there were patches. And there were several different kinds of patches for the different kinds of bugs. And so that's really what we're talking here today is about some of those patches. A little bit of background. Right? So everybody remembers meltdown. That was fixed by patching the operating system kernels. And that was all there was to it. You go, you patch your kernel. It fixes the issue. You're not vulnerable to the exploit anymore. So kernel patching, not fun, but pretty straightforward. Spector V1 required more patching. Because you had to go patch everything that had the new speculation gadgets in it. So not just kernels. Browsers, sandboxes, daemons, and anything that could potentially be used. We just saw net specter, which was exploiting specter in a network connected daemon. So lots of software to patch. But still just software. Still pretty straightforward. We know how to patch it. We know how to fix it. We know how to fix it. We know how to patch software. It's inconvenient. But we can do it. But some of the other variations, two, if you don't trust the retpoline fix, and four, required microcode changes. And this means you have to actually go patch the CPU firmware in order for the software fixes to take effect. So you have to do two things, which is you have to get the kernel patches to use the new microcode. But then you have to actually update the processor firmware. So that the new capabilities of the new capabilities are exposed to the operating system so it can use them to protect you from these bugs. So what is microcode? We have to patch it. But not a lot of people really understand much about microcode or what it is. For today, we're just going to treat it like firmware. Right? It's firmware that you load onto your processor. I'm not going to go into a whole lot more depth about it. That is a link on the slides. You can click it. It is very inaccurate. It is not brief. There's a lot there. And it would waste my whole time slot to go into it. But like other kinds of firmware, it can be patched. And it happens semi-regularly to fix bugs and other errata. And this was not really any different. Spectre wasn't using any new capability in the CPU that didn't exist before. It was just using the standard microcode patch to load this to add the new capabilities. The big difference between the two is that you don't have to go through the process. The big difference about microcode versus other types of firmware, processors don't have persistent storage. So when you load a microcode patch, it only stays until the next time you reset the CPU or turn it off or reboot. Even going to sleep causes the microcode patch to get lost because it's just stored non-persistently. So any time the CPU loses power, it goes away. And you have to reload it when the system comes back up. So that's a little bit of a surprise. That means that some bit of software has to store this patch file and reload it very early on when you turn the system back on. This is generally then done by either your BIOS or your operating system. And it happens every time you boot, right? Either BIOS does it or the operating system does it on every boot, every reset, every wake from sleep. Anything that really changes the state of the processor and causes that to go away. So they have to be aware of the patch. They have to know it's there and they have to remember to reload it. Because if the system is depending on that patch and you go through a sleep-wake cycle and you lose it and it's not there when you come back and something is expecting it, it will halt the system. So because these patches are being reapplied by either BIOS or the OS, that's generally where we get them from, right? When you need new microcode, you can go to Intel's website and download it. But that doesn't do a lot because you still have to get some of your software to load it. And so BIOS updates are the most reliable way of doing it. But like quick show of hands, who goes to their laptop vendor's website, you know, weekly checks for BIOS updates and then downloads them? Okay. I see at least a couple liars in the audience. The common way is so really unless you're running like a Mac book or a surface where your OS updates are also your firmware updates, it tends to not happen reliably. The other common method is your operating system will distribute the updates. They'll get them from Microsoft. They'll drop them in a package and they'll redistribute them through the normal OS update mechanism. This has been working pretty well on Linux. But it's been going less well on Microsoft. It took Microsoft about two months before they started redistributing the microcode updates. And it was, you know, it was a lot of work. But it's been a lot of work. It was four or five months before they were doing it for most of the Intel CPUs. They sort of rolled them out slowly for older and older generations of CPUs. And they're still only doing this in Windows 10. So if you have an older version of Windows on your laptop, you can't actually get fully patched for Spectre. Even though Intel has issued the patches, Microsoft has patched their kernel, you have no way to apply the microcode. I have a system at home that is in this state that I can't actually patch it. So I'm not going to be able to do that. I'm going to be able to do it on my own. I'm not going to be able to patch for Spectre using any officially supported tool right now. Even though all the patches I need exist. And that is a little frustrating. So there are, and I say many systems. So I went digging. There's not just a system. There's millions. And really the only fix right now is go buy a new computer if your vendor is not doing a BIOS update or go buy a new operating system if you're still, if you're new enough to be supported by Windows 10. This is Windows PCs that were about three to nine years old. Anything older, Intel has said they can't actually issue microcode patches. So they don't exist. Anything less than about three years old shipped with Windows 10 initially. So it's not a problem there. But BIOS updates are not going to be a problem. They're not coming quickly from a lot of these things. So there are at least a couple third-party microcode update drivers that you can run in Windows. But they don't actually work to patch Spectre. They will update your microcode. But by the time they do so, the Windows kernel has already started up, tried to find the new capabilities, failed to do so early in boot and decided it can't use them. So it will run along and you'll have the new microcode but the kernel will not be making use of it at that point. Based on the publicly available data, I can find there's somewhere on the order of two and a half billion Intel CPUs that shipped core I series which are the ones getting patches. And something like half a billion of them maybe can't actually update right now. If anybody has better data, I'm happy to update my spreadsheet that I used to generate this. But if you look around, and I did go look around, most laptops, most CPUs that I used to generate, are getting BIOS updates. Most systems less than or sixth generation and beyond, which is Skylake, are getting BIOS updates. Fourth and fifth generation, it's kind of spotty. It's a mix. Some vendors have done it, some haven't. And anything third generation or older, I have only seen BIOS updates for Xeon platform. So no laptop or desktop systems are really getting updates there. So this sucks. Right? That's a lot of systems that can't patch. In my case, I only have one that I actually can't patch that I care about. But that's still one too many. So I started thinking, when can these microcode updates be applied? Right? BIOS can do it. But I can't actually go modify my BIOS. It's a signed package. If I change the microcode file in there, it won't work. It will fail the signature check. The same thing with the OS. The built-in files are all signed drivers by Microsoft. I can't change them or they'll stop working. And so I went looking. So where else can I do this? Maybe in the bootloader? So I went looking. And unfortunately, there was no EFI utility in existence earlier this year that could actually do a microcode load from an EFI shell or an EFI environment. The code to do it is already part of the open source UEFI code base. But it basically had hard pointed the data file to use to the, you know, known location that I was working on. So I went looking. And unfortunately, there was no code that I could modify. But this is all open source code. Right? And the code is there. How hard could it be to turn it into something I could run myself? And I see people in the front snickering because the first time I tried to actually build something in EFI, it took the better part of a day to get a working build environment. So when I asked myself how hard could this be, I knew what I was going into. And I expected this was going to take me months of effort just to, like, get hello world to build. But it didn't. And so I went looking. And I was like, okay, I'm going to do this. I'm going to do this. I'm going to do this. But it didn't. EDK2 has come a really long way. I hadn't functioning build environment in less than half an hour. And that was mostly because I screwed up installing a couple dependencies on the first try. So I started cutting and pasting code from the existing update routine into a standalone app that I could run myself. And it worked. That was, I expected this to be a more interesting part of the talk. But it really wasn't. Because it's a few hundred lines of code that I cut and pasted. And it worked. Because it was a few hundred lines of code that I copied. Okay. So now I've got this. I need to run it. BIOS, you know, has a UEFI now because this only works for UEFI boot. But it's a pretty simple flow. It does a whole bunch of stuff we don't actually care about right now. We don't have to understand. And then it goes and runs an EFI application. Right? Normally, that EFI application, you're going to have a lot of code. But it was a is your Windows bootloader but it doesn't have to be. You can change that and we can run our application first and then run the Windows bootloader after it finishes. So let's try that. So you can see this is the Windows booted up. You can see from the top line that's in red that the hardware support provided by the new microcode was not there. That's what the top line meant. It just said the hardware support wasn't ready. So we're going to reboot and we're going to drop into an EFI shell. There it is. And you're going to see it parses the microcode file. That's the section in the middle that's telling you about it. And that section at the bottom, there's four threads in this system. It loaded the microcode to all four threads. And then we start running the Windows bootloader again. I added some break points in there so you could see it because without them it only takes like maybe a second and you wouldn't have had time to see it. So it does make boot a little bit longer but not substantially. And now back in Windows, hopefully this will get up soon. There we go. And now you can see it's green. The hardware support is there. It detected the new microcode. And we are patched. So I wrote some scripts to install this automatically. And I'm going to show you some of the things that it does. It goes and it modifies the EFI boot partition on a Windows system to load the microcode loader app. It runs off a Linux live CD so you can just take, like an Ubuntu or a Fedora live CD image based off their website, boot into it, check out this repo from GitHub and run the installer. And it will go and it will detect your CPU version. It will try and find updated microcode for it. And then it will copy that and all the EFI apps it needs. And we're going to go on to the boot partition and set them as the default boot target so that it will run before the Windows boot loader on every startup. There are some limitations. So as I mentioned earlier, this breaks sleep. Hibernation still works, but because you don't go through the normal boot flow on a wake from sleep, this doesn't get run and the kernel panics and locks up real hard. I don't currently support secure boot with this yet. I just haven't gotten around to adding support for that. I've seen some inconsistent behavior from Windows after booting. Sometimes I suspect I've left some things in memory that I shouldn't have in my application. Rebooting tends to fix that. And I can't promise this will continue to work for very long. Microsoft has already once started reverting the changes I've made to the boot partition. About a month and a half ago, a Windows update started rolling back my changes on every Windows boot. So I had to make some modifications and it works now, but I also haven't run Windows update in a couple weeks. So to summarize, right, I get it. Firmware patching is real hard. And I know Microsoft is not going to be able to do that. But I know Microsoft is going to be able to do that. And I know Microsoft is trying. The change from BIOS to UEFI should have made things better with regards to patching. And it really didn't. But, you know, we're not writing security patches for things just to put out a press release saying we wrote a security patch. That's not the point, right? The point is to make end users more secure. And going around and, you know, say either not issuing patches or making it even harder to apply updates when you're not supporting them really seems not helpful. And as an industry, as a security industry, if we're not, like, enabling users to make their systems more secure, we're failing. We're failing really bad. And so as I said at the beginning, I hope nobody has to use this. Because really what should happen is, you know, BIOS vendors, OS vendors, should be including these patches themselves. And we shouldn't be going around hacking bootloaders just to patch our systems from security bugs. Questions? So, yeah. So the question is, have I considered installing on the driver chain instead of as a boot action? So the problem is the Microsoft, you know, I don't know if you're familiar with the micro code driver. It's a signed package that includes both, like, the driver component and the micro code component. Oh, the UEFI driver. Oh, so no, I have not tried installing it as a UEFI driver. It might. I will look into that. So, yeah. So, yeah. So, yeah. So, yeah. So, yeah. So, yeah. So, yeah. So, yeah. So, the question was, are micro controllers also affected by this? So, this is for design for basically desktop, laptop, server CPUs that have micro code patches that need to be applied. So anything x86 that loads micro code, this should work with, although most micro controllers were not really impacted by Spectre. Any other questions? Thank you very much.