So thank you so much for coming. I know it's early on a Saturday at DEF CON. I talked to some people last night. They're like, when are you talking? It's at 11am. I don't get up until 3, sorry. So I appreciate the effort. Or maybe you're still up. So I want to move pretty quickly here. I've got a handheld mic. I might walk around a bit. I don't have a lapel mic because flippers and stuff like that. So we'll see what we do. But I've got a lot of slides and I want to make sure I get through everything. So I've got a quick agenda that I will start with. Let me quickly introduce myself for those of you who may not be familiar with who I am or my work. So my name is Stephen Sims. I've been a vulnerability researcher for going on 20 years now. I was lucky enough early on to have computers in the house and be able to have access to video gaming and all the fun things early on and using a hex editor and hacking. All the things you guys have already done. So let's move on beyond that. I've sold a lot of exploits over the past couple decades. I corrected myself there. I thought it was over 30 browser exploits but I didn't want to fib so I went back and counted and it ends up being 29 of them. Those are mostly used after free and type confusion vulnerabilities. I've always been someone who sells exploits. I don't typically disclose them publicly or through other programs. I will talk a little bit about that because obviously there are ethics associated with exploit sales. So I'll give you my position when we get there. I found a couple kernel vulnerabilities on Windows 1 RCE which you can get a lot of money for nowadays. Had I known a little bit more when I sold it, it would have been better. But lots of other vulnerabilities and different applications and hardware out there over the years have been lucky enough to have a lot of great relationships and such. I moved to San Francisco early on in the 2000s and lived on Treasure Island where we used to joke and call it Hacker Island because there were so many hackers there. People from Burning Man, people from all kinds of different backgrounds. But it was just a free for all and it was pretty incredible. Lots of people from CDC lived out there and others and you learn pretty early on to how to properly use a handle and not get yourself doxed out there. I'm also, like I said, a musician at the Sands Institute on the Offensive Operations Curriculum Lead and I have a couple courses there on advanced exploit development. I am one of the co-authors of Grey Hat Hacking, if you've heard of that book series. We're talking right now about doing a seventh edition so hopefully that comes to fruition. And then I also run a weekly stream you might have heard of called Off By One Security where I do my own stream solo and I also have a lot of guests on and I've been lucky enough to have some really amazing people on and that just makes it all great. I appreciate so many of you have come up and say thank you for the stream because that means a lot to me and that's what I do it for is to get back to the community. And if any of you are ever interested in being a guest, I'd love to hear from you. All right, so quick agenda. We're going to start off doing a quick history of mitigations. We're not going to cover all of them. There's dozens and dozens of them so we can't get through them all but we'll touch briefly on them, kind of show you where we were, where we are today. Microsoft MSRC was generous enough to get me some really cool cutting edge data that has not been published yet so you'll get to see some vulnerability information from Microsoft's perspective in relation to RCEs and local priv and other types of bugs. Then we'll quickly go through payouts. I did a stream last Friday on nothing but payouts and all the different types of buyers out there and I got a lot of hate and a lot of love from that one which I expected because again it involves your morals and it's very ethical considerations to have. We'll quickly look at the role of machine learning and AI in general in vulnerability research because that's obviously a hot topic as of late and will continue to be. And then we're going to switch over into being technical because I don't want to do a talk without being technical and we'll get into looking at one specific mitigation that is implemented in the Windows kernel. And my main point of wanting to show you that is so that if you yourself want to understand how a new mitigation works that comes out, if you want to figure out how to bypass it, how to work around it or other things or how effective it is if you're a defender, you need to go and debug it. It's really the only way you can learn other than taking other people's published information. So every time a new mitigation comes out I love to jump in to debuggers and disassemblers and go and understand it as best I can. And then we'll do some takeaways. That is the agenda. So the golden years, I'm not one, it's not my right to say what the golden years of hacking is but I have been doing it long enough and I remember reading, it was before my time, but I left one smash in the stack for fun and profit and other papers released around that time, open wall, work that Brad Spengler was doing, so many other brilliant researchers and when you, when I personally think about what the golden years is, it's before all these mitigations became really effective. You'll see on a diagram that I put together coming up in a moment that there are certain years where stuff got real serious and it's only gotten harder and harder since then. So I would say the golden years of memory corruption bugs is long over but still possible and those bugs are very valuable now and you'll see that in a moment. But you see here Windows up at the top and we can go way back to when trust from escape and wag that was what became Emmet or at least some of the controls and mitigations there became the enhanced mitigation experience tool kit which of course now today is exploit guard. But Windows it wasn't until XP service pack 2 where mitigations were a thing. I remember when that dropped and admins were freaking out because it was over a gigabyte update and there were a lot of new mitigations published. You can see them listed there. I'm not going to go through every one of them but notable ones like data execution prevention, that's huge. And in stack canaries. Linux down below, I was doing some research and thankfully Brad Spengler pointed me to some great talk from maybe a decade or so ago that really went through every single mitigation when it came out, the bug classes and gave credit where credit is due to all the brilliant researchers and that's a really hard thing to do. There's a lot of confusion when you go out there trying to find out who the original source was that published a technique for exploitation or some documentation and I try my best to give that credit. So the information there under Linux all the way back to 1997, I mean people were thinking about security way back in 1997 especially on the Linux side of the house which as expected is always first in that realm. But open wall was a big one for that one. Mac OS you can see was a bit late to the game. ASLR like randomization didn't come out until like 2011. That's way behind Vista even. So all the operating systems now though are at a pretty good state. Some notable mitigations, this is not complete by any means. I put this together, there's always possibilities, there's mistakes. A lot of times mitigations come out like before the official OS release of that mitigation. You might hear well low fragmentation heap that was around during XP service pack 2 or 3 but it didn't fully get implemented to replace the front end heap allocator until Windows Vista. And then they got rid of the look aside list except for in the kernel. So like a lot of this stuff can be fuzzy. So the arrows going back that means back ported. A lot of times mitigations come out, some of them get back ported, some of them don't get back ported. But you can see some other notable ones like Windows 10 obviously came out, control flow guard was a significant one. Microsoft was pretty proud of that one and made some pretty bold claims about it. But none of these mitigations by themselves are a one stop shop. They are complementary to one another. If there's one weak link in the chain, if one single mitigation is not working properly or if one library is not compiled to participate in a mitigation, it breaks the whole thing. So it can be difficult to get all of them there. I usually put up a Venn diagram that shows overlapping circles where you've got different categories of mitigations like those enforced by the operating system, those enforced by the compiler, those enforced by a tool kit like exploit guard or malware bytes or whatever you might be using. And if you get to the merged areas in the circles, you're taking advantage of multiple categories and that's where things become much more effective. Because depending on the type of exploit you're using or you're writing, a mitigation might not even matter. For example, font protection. Like they introduced font protection because I think it was Dooku or Stuxnet, it was a font based vulnerability. It was a sign extension bug and it affected the Windows kernel and was a brilliant exploit. That font mitigation just says you can't use any fonts unless it's in a system 32 fonts folder. So no third party fonts to come along. But obviously that only targets a very specific thing. So some of these mitigations don't matter when you're exploiting things. So this is not something we're going to walk through. It's a pretty ugly slide but it's something you can take a picture of. All it's showing is that with all of those mitigations and that was not comprehensive by any means, it's a cat and mouse game where you've got a mitigation that comes out due to a bug class or an exploit technique. For example, look at arbitrary code guard or export address table filtering. EAF specifically targets shell code and how it accesses the exports table inside libraries like kernel 32. So they target very specific things and it's that cat and mouse game because when a new exploit technique comes out or a new bug class, a mitigation goes in to try to kill it. And then a workaround comes out and then they update the mitigation. A perfect example is back in 2014 and I was just hanging out with Corlan Coder like a week ago in Amsterdam at a hack fest that we had out there. And he and I have something very in common with each other. Actually I'll show you in a diagram coming up very soon. It might be the next one. It is the next one. So this is the last version that Microsoft published outwardly that I've seen anyway from Matt Miller and other folks at MSRC. And you notice it only goes up to like 2013 or so. Or 2015, 16. I can't even see it. But what I want you to look at here is, and unfortunately I don't have a laser pointer on this thing, but look at the gray area to the right side and see how it's a very wide gap. And then all of a sudden after that it shrinks down. The reason that happened is because Microsoft in 2014 introduced a couple mitigations that really killed specific types of bug classes in the browser. Like type confusion, use after free. I brought up Core Lan Coder because he and I both were writing quite a few exploits per year against a browser and then all of a sudden in June, July 2014 they stopped working. The exploits stopped working. Because they put in deferred free, isolated heaps and then MemGC came shortly after. And I remember even seeing people like Skylines who was releasing lots of vulnerabilities or selling exploits or disclosing them, saying one time in a tweet, hey does anybody have a MemGC bypass? I'm literally sitting on a bunch of edge vulnerabilities that I can't exploit. So that's the job of the OS developers who work with mitigations is to identify and understand a specific exploit technique or bug class and try to kill it. Deferred free or MemGC I should say is so effective because it does validation of references. Microsoft used C++ smart pointers to do dynamic tracking of objects and reference tracking and the way in which they chose to track references allowed for a certain type of exploit to be quite possible. So by adding the MemGC control in deferred free, there's validation going on to make sure that there are no other references to the object that's about to get freed before giving it back to garbage collector for reuse to get recycled. And that's why it shrinks down so much. So Microsoft is very kind as I said before in getting me this diagram and the next one. This one is remote code execution CVEs by patch year. So you have to imagine that the majority of CVEs that come out are privately disclosed. Meaning that there is no public exploit code. And that's why there's a lot of exploit framework vendors out there like Rapid 7 with Metasploit and Core Impact and Immunity Canvas and Saint. There's all these different frameworks and what they want to be able to say is we have the most exploits for privately disclosed CVEs. Because if you're a red team or some other offensive group and you want to be able to break in obviously to targets, most companies are terrible about patching. So if we can get some really smart people to do things like patch diffing, identify the delta in the code and weaponize these end day vulnerabilities, then we're going to have a much more valuable framework because we're able to allow you to exploit things that no one else can. I would say close to like 90% of CVEs are privately disclosed. No public exploit code. So that is absolutely a profitable business to go and write or weaponize end day vulnerabilities. Because again organizations are terrible about patching. But you can see we're not going to walk through all the data. I'm going to tweet this afterward and the slides obviously will come out. But this is great stuff to use internally with your teams and your threat intel folks and SOC and everyone else to say hey these are some things we should be considering. How effective are the mitigations? What bug classes are the most popular right now? And this specifically is for RCE. And you can see the number in the middle. The next one here is overall CVEs by patch here. So this is not just memory safety or if you go back to that initial slide that I had up that was all memory corruption for the most part. All of it. And I remember some patch Tuesdays there would be like 50 patches coming out for Internet Explorer and Edge alone. It was a serious problem and they had to solve it with these mitigations and did quite an effective job. But this shows you memory corruption if you look at the left that's the big green one in the middle and if you look to the left it's getting less and less and sometimes it gets bigger and smaller but that is happening because obviously secured code initiatives, introducing rust into the kernel to protect critical components, the mitigations being very effective, that is what changes the trajectory here. And you can see things like deserialization and other types of bugs start to pop up and get more popular. Again, cat and mouse game and we're always trying to find new ways of getting in. So how mitigations have affected payouts? I'll quickly go through this one because again I want to make sure I have enough time. And if you want more information on this if you go to the off by one security channel on YouTube look at last week's stream I spent like two hours almost talking specifically about this process. But quickly going through there are different categories of buyers. You can always go to the vendor themselves like Microsoft, Google, Apple and they will pay you. Some companies have bounties, some don't. But they typically don't pay as much as third party buyers out there depending on where they sit on the realm of ethical boundaries. But they'll pay you and it's gotten better. Then you go a little bit further. Okay, we can go to ZDI, the Zero Day Initiative or go out to CanSecWest and participate in Pwn2Own or Bug Crowd, HackerOne, iDefense which I don't think are buying exploits anymore. But those are third parties who do work with the vendor and they get it patched. The exploit code never goes public. When you sell an exploit it's no longer your exploit. Typically they don't pay you. The money gets put into an escrow and you have to wait to get paid because they want to make sure you're not trying to double dip and sell it to multiple buyers out there until you build up a good trust. So we go out further and I'm not going to name any names because they get mad, but there are all kinds of different third party buyers on behalf of different intelligence agencies and governments around the world. Believe me, I've sat with them many times and they are looking for bugs from you. Now you typically don't go knock on the front door of the NSA, I don't advise that, but there are third parties out there and they will pay more than the below ones that we just talked about. How much? We'll talk about some money here in a moment. You go further than that, there are these third party companies that are exploit acquisition companies that refer to themselves as crowd fences, a relatively new one, you heard of Zerodium, I don't think they're buying anymore, they used to be Voopin. And there's Voln Point, I don't know anything about Voln Point, but there's some hefty amounts of money that you can make there. Millions, I think up to 9 million US dollars for an iOS bug. I mean full chain, obviously, it's got to be all the things. And then you've got kind of the most unethical place you can go, which are random people. This is where you've got to be really careful because you don't know who you're selling to and you don't know who they're selling it to. You don't know who the buyer is. But this could be over Tor, Telegram, people, if you start getting known for selling exploits or having the skills to find zero days and weaponize them, especially in today's climate with how hard it is, they will find you. But you've got to be really careful when you're selling this stuff to protect you and your family and other things. I really, again, recommend watching that stream if you're interested in that space because I go into some good detail about that. So examples of how much you get paid for some of this stuff. Now, this example is one for me personally. I've always sold things. I don't sell to unethical buyers, though. Personally, that's my choice. Yes, you get paid less, but that's, you know, your choice. So someone like iDefense or ZDI, back in 2014, before those mitigations I told you about dropped, you could expect to get $10,000 to $30,000 US dollars for like a USAPTA free exploit. And back then, you typically didn't need a big chain. Maybe one exploit or two, like an information disclosure bug to bypass ASLR if you needed it. But if anyone remembers, and I'm sure some of you do, JRE6, the Java Runtime Environment 6, MSVCR71.DLL. That made me a lot of money because they didn't add dynamic rebasing to that module. And it also had all the gadgets you need to get around data execution prevention. So it's a beautiful thing. So if you found one remote code execution, USAPTA free against the browser, that's all you needed. There was no sandboxing on Internet Explorer Edge back then. And so you could expect to get paid that amount. But now it's a lot harder. On the more unethical side of it, you can expect to get paid 10 to 20 times more. So you can see an example there from CrowdFence. They say offering up to $400,000. That's straight from the website. Another example is iOS. Zero click. Apple created something called Blastor to try to triage text messages coming in to make sure code execution isn't occurring. It's going to be a lot harder to jailbreak or root that phone because of Blastor. So you got to have like 4 to 6 zero days chained together at least. And it's not one person out there doing this anymore. Back in 2014, you and yourself could find enough to get around all the things and get code execution. But nowadays, especially in the kernel with HVCI and other cutting edge mitigations you could say, it's hard. The execute primitive is gone. You get read write opportunities but even that can be challenging with code signing and all kinds of other things. But that is why the price tag goes up so much. So you can see 2014, I remember Zerodium was offering up to $2 million, $2.5 million for iOS and Android full chain zero clicks. Now you can get up to $9 million with VulnPoint and CrowdFence I think I saw. And then this example here, if you've ever seen Operation Zero, it literally says on the Twitter page, on their home page, the only Russian backed exploit acquisition program. And it literally says, we are non-NATO friendly. But $20 million U.S. dollars, you could retire. That's amazing. But look who you're selling. You are literally doing treason at that point. I'll stop saying literally. And they will use that to attack your country. So I don't know if you want to be in that position, but it's an option for you. So we'll jump now into machine learning for vulnerability research. This one is one that I have a lot of interest in because it saves you time. You already know, but automation and machine learning, or the umbrella of AI in general, are things that aren't going away. And we don't want to fight it, we want to leverage it and use it to complement our skills. If you fight it, you will lose. When chat GPT was made public, I think it was November or December 2022, shortly after that spring, I believe, Project Zero started an initiative, of course, to go and see how AI in general, machine learning, can help with vulnerability research, specifically for memory corruption bugs. If you remember a long time ago, DARPA, back in like 2016, they had a challenge. And they paid, I think, 2 or 3 million U.S. dollars to the winning team, and the challenge was, we want you to write basically machine wars, automated hacking, automated detection and defense, where the machines are fighting each other, almost like a capture the flag. And back then there was a lot of universities looking into very basic exploitation techniques, like stack overflows. That's a pretty easy thing to weaponize. Okay, the buffer is overrun and you overwrite a return point, that's very basic. So it's not so hard to write something that will do that for you automatically. But when you're getting into harder bug classes, I gave a couple examples, like type confusion, those are difficult to find. Static analysis, dynamic analysis, manual code inspection, it doesn't matter. Those are tough to find. Because as a developer, you can't possibly get your code into the context or every possible situation where it might be run. Different libraries, different patch levels, different things people do to their computers, a developer can't anticipate what that code might run into in the future. So these vulnerabilities manifest thanks to things like C++. A lot of people ask, well, why aren't we already on Rust? Why isn't the Windows kernel rewritten entirely in Rust? I can't answer that 100% but I can give my opinion, which is, wow, theirs is louder than mine, that's amazing. All right, okay. Cutting me off. So Rust, remember when H.D. Moore and the Metasploit team, they were on Perl early on? Metasploit came out in 2003. And at one point they said, we need to get off Perl because the language wasn't growing at the same pace that they needed it to. And so they were going to choose between Python and what's the other one? Ruby, right? And they chose Ruby. And I remember talking to H.D. Moore at DEF CON a long time ago and I believe it was the Ruby developers were willing to work with that project because it became the largest open source Ruby project to improve the language to meet the needs of the developers. So the language developers working with the framework. I imagine it's a similar thing where C++ has been around for a long time. It's very mature, it's very powerful. So a couple things you get from that. You've got developers with decades of experience who can't just overnight over to Rust and you've got limitations in the language that might not allow it to do the things that C++ can do. And yes, Rust is mimicking like low level behavior with the speed and the power of being able to directly manipulate processor registers and memory, but unsafe languages tend to be extremely powerful. So it's those memory corruption bugs, they're difficult to squash and it's not going to be overnight where we replace everything. But it is slowly happening. I believe the first thing you saw in the Windows kernel was Win32K.SysDriver. Some implementation of that got put over to Rust. So anyway, from a high level, because I can't really go into what Google is doing at Naptime, I read the paper, that's what they called it, was Project Naptime. And I have been working on a similar thing, but as a single person, so they've got a team of people. I've also talked to multiple other teams out there who are doing the same thing. And that is, how do we create agents, different agents that serve different roles, they do different things. Because just like humans, if you try to give AI in general, and again that's an umbrella encompassing term for everything underneath it, if you ask a single agent or LLM to do everything for you, it's not going to do a great job. But if you break it down, just like humans, don't ask one developer to go rewrite Microsoft Office Suite, that's too much. Break it down into different groups, different agents and roles, it's going to be a lot more possible. And the gist of that, they did make some really impressive progress and they're going to continue working on it of course, but said, as it quotes on the slide, there's still a long way to go. We're not going to be replaced any time soon because there's so much nuance that it can't have, like humans can have, the way we think. It'll get better of course. But going into that a little bit more, this is an example of something called crew AI, if you've heard of that, there's multiple frameworks out there for such, open source, and it has this concept of the agents and these roles that things serve. So you can see on the right, we're saying we want you to be a threat intelligence analyst, this is what your job is. And you feed it information, it uses rag and other cool technology to ingest all kinds of threat intel data and other, and then it does a thing. And to put that in like a chain, you've got over on the left, like an agent that is the threat intel agent, and it's ingesting things like PDF documents and just threat intel data, everything it can get its hands on. And then the result of that, the output, like the list of MITRE attack TTPs as an example, because everyone knows that one, gets fed into two other agents, one's the red team side and one's the blue team side. One's doing detection engineering and generating Sigma or some kind of other rules out there, and the red team side is using it for continuous automated red teaming and pen testing. So they're consuming and ingesting the same data, using it for different purposes. A lot of companies are getting into this now, a lot of managed socks out there are doing exactly that. Here's your Yara rules, here's your Sigma rules, whatever, from it. This is a pretty ugly slide, but it's one that I put together because this is what I'm working on personally and I have been for some time now. I am not anywhere close to where I want to be, and if Google's not getting the best results in the world, like meaning it can replace humans with VR or the other way around, then I'm certainly not going to be able to do it alone. But I have made some good progress, which is I feed into an LLM all the different CVEs, all the project zero or other public research out there, all GitHub, anything I can feed it around exploits and patch diffing, binary diffing and all that data. So one thing I do a lot is end day vulnerability weaponization. I download on patch Tuesday unless I don't have time. You get used to looking at this stuff, you look at all the CVEs, you look at the knowledge base articles, you try to figure out which ones are most likely exploitable. You probably still wrong, and you learn a lot, so you have to keep telling yourself, because it's very frustrating when you spend two weeks looking at a patch vulnerability that you realize you cannot weaponize, because of mitigations or some other factors. Because even if a mitigation can 100% stop a vulnerability from being exploitable, they're still going to patch it. Because what if somebody turns a mitigation off? It's a good habit to clean that stuff up. So when you do a patch diff and you look at the delta of the code, use something like diaphora or bin diff, and you take a look at the changes at the function or the code level, you can give that information to the LLM and teach it how and why it's a certain type of vulnerability. And then the output from that can go into the next agent, which is really doing the patch diffing for new vulnerabilities that got patched. So it's taking the patch, it's extracting it, or grabbing it from Winbindex, doing the diffing, and it's looking at the delta. And it's knowledge of all the prior diffs that it has learned about and all the information about exploits that are public or private. It's using that to make a good guess as to what most likely is the vulnerability type. And then we have a corpus generation agent, which is trying to generate trigger files that you can then feed to whatever it is and hopefully trigger the vulnerability. And then of course you would have to go in and see if you can actually weaponize it. So it's automating the process of binary diffing and trying to find where the bug is and trying to help you generate malformed documents or whatever you need to send to the target to try and get it to crash. I've got this working pretty good, it's not great, but it's saving me a ton of time. I would say probably like 10 to 20 times it's saving me on that research effort, which is pretty damn good for me anyway. So understanding how mitigations work, we're going to jump into the more technical part now. There's so many mitigations, so I just chose one random one. And also on my channel I do a lot of exploit mitigation reversing, if you're interested in that stuff, there's videos on that. But a lot of these mitigations, especially the more classic ones that came out with emits and the initial exploit guard, what they do is they will hook something. So for example, there are things called critical functions on Windows. Critical function of one type will be any function that can change permissions in memory, like virtual alloc, virtual protect, heap create, write process memory, those are critical APIs. So we want to monitor those. So if we understand things about different bug classes out there and different ways in which people exploit vulnerabilities, then we can hook the flow of execution and before we allow the function to be called that will in fact change permissions in memory, we inspect it. And they can do that, you could do that by overwriting an entry in the imports table, so when it calls that function where it's linked, it'll actually call your code first, or more likely they're going to hot patch or put a patch in the very beginning of the function entry point, and it will first jump to another location, execute some code, typically points into something called payload restrictions dot DLL, and it evaluates the environment to make sure things look good. I'll give you one simple example, if you've heard of stack pivoting before, Microsoft had the blue hat challenge, and that was 2012, that was a long time ago, but they paid over a million dollars U.S. to the first place winner, and then they had three places, first, second, third, and what they were looking for is help from the community to stop return oriented programming. And one of the main things that we would do in use after free exploits on browsers, is we would pivot the stack pointer out to the heap, because the stack pointer is a register that only is supposed to point to the current thread stack at the top of it, let's not get into speculative execution and such, but you know what I mean, and we like the stack pointer because of three powerful instructions, push, pop, rep. That's the only register that those instructions exist for. So that power, we want that in other places in memory, so what we would do is use an exchange gadget and it would exchange or pivot the stack pointer with another register like the accumulator register. That would make it so the stack pointer points out on the heap somewhere, where maybe our ROP chain is, our exploit code is. So great, it works. So anti-ROP, which came out right before Blue Hat, was on Windows 8, all it did was it looked at something called the thread information block at the stack boundaries, the stack high and stack low limits, to make sure that the stack pointer points where it's supposed to before allowing a critical API to be called. Very simple thing and it was very easy to get around, but it showed you Microsoft was taking return oriented programming seriously. And then after that a whole suite of mitigations came out, like 6, 7, 8, simulate the execution flow, just many others. So again, a lot of these hook and then they inspect and you move on. Not all of them though, some of them are enforced in user LAN, some of them are enforced in the kernel, and other factors. So let's look at one more closely. So create process, a little C++ program I put together, lifted code of course too, and all it does is it calls create process. There was a mitigation that Microsoft came out with called, do not allow child processes. And that was called the calculator killer, because obviously a lot of times people would use shell code to pop a calculator to prove that it worked. Well this mitigation would kill that and prevent it from happening. So a lot of times if you're exploiting like Microsoft Word or a browser or anything else, you want to create a new process. This mitigation would stop you from being able to do it. So when I first saw the mitigation, I just assumed that it hooked create process in user LAN, somewhere around NTDLL or something, it grabbed it, and then payload restrictions would just inspect it and it would just prevent you from being able to do it. But this one ended up being a kernel in force protection. So first off, this is the code, you compile it, and great, simple. When you run it, so I'll make sure this seems to be acting weird here. All right, there we go. So when you run it, you can see on command line right there, a calculator pops up. Exciting, right? But that's what it's job was. That's what it was supposed to do, is just pass in an argument and it executes and creates a process with that argument. Simple. Then I go into exploit guard, that's a little snippet on the top right, and I turn that specific mitigation on. You can see there's audit mode and then there's enabled mode, and I just enabled it. And then when we try to run it, you can see the command prompt in the middle, it said create process failed. Okay, the mitigation is working. Down at the bottom, you can see that as a defender, you want to watch these things. So here's one thing, I'll take a step back. A lot of administrators are afraid to turn on these mitigations, the ones that aren't turned on by default by Microsoft. And Microsoft's kind of in a catch-22 situation because if they turn all the mitigations on that are available, they might break your applications. Because some of your developers have to adhere to the way in which these mitigations work. But if they don't turn them on, then you're mad at them because they didn't protect you. So they're kind of in a bad spot. So they wait until things are mature enough. A perfect example would be shadow stacks. If you've heard of shadow stack, it's a relatively newer mitigation though not in theory. Early 2000's someone mentioned the idea of that. It creates a copy of return pointers and it requires at least an Intel Tiger Lake CPU. So obviously not everybody's running one of the newest processors and they're not just going to turn that on by default. So they have to wait. So a lot of these, you do have to go on and turn them on. I remember Microsoft released a paper a long time ago and said the adoption rate for the enhanced mitigation experience tool kit, Emmet, was under 5%. So under 5% of organizations were actually using Emmet in any way shape or form. Because the admins maybe don't understand how the mitigations work at a very technical level and they don't want to do the screen test. There's also performance hits associated with these mitigations. One nice thing you can do though is turn on that audit mode. It's almost like an intrusion detection versus intrusion prevention where it tells you about a potential problem but it doesn't actually block it. So you've got the power to do that and then you can look in the event logs. There's a specific event log area for user LAN mitigations and kernel LAN mitigations. And that's what you're seeing at the bottom there. When I ran that program to execute the calculator, that new log popped up that said a mitigation was blocking it. That's right there what told me it was kernel enforced. So looking at the NTOS kernel here, when I set a break point on create process and let it continue, it went straight into the kernel. So it told me right there, validated that this is not a kernel, sorry user LAN enforced mitigation. So I went into hex, I used hex rays obviously and I used wind debug and went in and set some break points on those functions right there. Like PSP get no child process restricted policy or SC token is no child process restriction enforced. These are by symbol name because thankfully Microsoft gives us the symbols, the PDB files. We can go and look for things that look like they might be associated with the mitigation that we're curious about. So I set the break points on there and then we run it, it immediately gets hit. But look where it gets hit. It gets hit when I'm in the command prompt trying to start that C++ wrapper program, the create process program. Because that's the program we turned exploit guard mitigation on in the settings as you saw in the last slide. So it makes sense. So we hit a break point on the setting API, the one that sets the mitigation. Over on the right there, if you're not familiar with the Virgilious project, it's everybody I know's go to if you're looking at kernel structures. It is a brilliant resource and every single Windows version, kernel version, every build, every creator's update, whatever, is tracked there. Because a lot of times when you're doing things like token stealing in the kernel, you need to make sure that your offsets are correct. There might be a structure like E process or K process, K thread, E thread and you need to make sure that what you think like AP links at a certain offset is still there depending on the kernel version. So you can look at these structures, look at the members and you can update your shellcode accordingly. But either way, I saw an instruction and you can see in the code in the top middle, in the white area, it says move into racks, GS segment register, offset 188 hex. So the GS register, while under the context of the kernel, points to a structure called the kernel processor control region, a very large kernel structure. And nested inside of that is something called KPRCB, the kernel processor region control block, which is a mega structure. What it's telling us at offset 8 within that nested structure is what we're dereferencing. It ends up being the K thread pointer. K thread and E thread and K process and E process are kernel things. If you've ever heard of the process environment block in user land, the PEB, E process is like the equivalent in the kernel. If you've ever heard of the TIB, the thread information block, K thread, E thread, the executive and kernel thread, those are the relative entries in the kernel. Not 1 to 1, but it's pretty close. So either way, we're dereferencing and grabbing the K thread pointer for the current thread. So let me go in further and we're checking out our progress here. You can see that I run this fancy window bug command and we're basically saying, what is our current process? And it tells us that the current process is the, uh, which one, command.exe. That's not the process I want to be in. So we let it continue. We hit the break point again and then we look at the current process and now we're in the create process C++ program where we want to be. So now we know where we want to be, where we're at, where we want to be. It's important to mention that because when you set these types of break points, they will get hit often unless you set process specific break points as a kernel debugging session. So you want to make sure you understand what context you're under for each, you know, process. And then we hit our break point on the SC token set no child process restricted function. So this means that we're under the context of the create process C++ program and that mitigation function has just been called and it says set no child process restricted. So you go into hex rays and you decompile it and you say, hey, let's take a look at this function and that's what you're seeing on the right there. I know it's kind of small, again slides will be released. Put some circles around some variables because we don't know what those variables are. Thankfully we get symbols from Microsoft. Thankfully hex rays and IDA pro are brilliant, it's a brilliant disassembler and we get the function prototype data. As long as you know what the structure is, you can say, hey, I know this is a token structure because MSDN told me on the left, on the top there. And then once you do that, you see that it's able to then go in and add all the symbols, define everything that you want to see. On the right there, I did a stream a while ago on documenting undocumented structures and it was all about looking at different bit masks in the kernel and E process and the token structure to understand what the mitigation bits are and to show you kind of how to do that. This is a reference from Google that shows us that these different bit mask numbers, you'll see lots of booleans like ands and ors and those are either turning on or clearing bits in the bit mask so that the mitigation flags are set to the state that they're supposed to be in. So I went through here and I added a bunch of comments because obviously it's helpful especially if you're not used to debugging or disassembling and decompiling kernel structures. But that defines everything that's happening. Basically we're getting a token or acquiring a lock on the token. We're initializing a variable which ends up being the token, the current token. And then we're going in and we're checking bits that are set in the bit mask. And these bit masks bits are things like, is it in audit only mode? Should it be turned on and enforced? Is the low box token thing associated with it? What setting should I do? And through the boolean operations it turns on the appropriate bit which then sets the mitigation on. That is pretty much how that mitigation works and that's why it's being blocked because the next thing that would have happened had we kept going, the get function would have gotten called and it would have checked that bit to see if that program has the authority to spawn a new process. So that's kind of what we learned by going through that and that's how easy it can be to understand mitigations to see if you can get around them. So from that you're like, well then can I get around this somehow? Obviously the first thing you want to do is Google, go to chat GPT or your favorite AI LLM whatever and say, hey can you tell me about any bypass techniques that may be publicly available? But if there are no publicly available ones, hey you've got a great opportunity to do some cool research and make it public if you can find something. Some examples down there towards the bottom, there was a technique, I forget who discovered it but I put the link there where you can impersonate the anonymous token to get around the mitigation and spawn a new process. I don't think that still works but it was an option. You can use WMI like if you're in the context of Microsoft Office and you can use some cool PowerShell or WMI to get around the mitigation that way. There's process migration potentially, you can use reflexive DLL loading where you load from memory, something into memory. That also gets you around other mitigations like CIT, ones that are preventing you from loading an unsigned DLL from your Windows box. And again, setting it accordingly, enforcing the protection and getting around it with things like reflexive DLL. So, there's a bunch of ways we could potentially get around it and that's why it's so important that you put a bunch of these together. That you're not just relying on any one mitigation. I remember Microsoft made a pretty bold claim, somebody there, said CFG, control flow guard, should be a strong enough mitigation that it can prevent the majority of exploitation techniques where Emmet may not be needed as much. That ends up not being entirely true because CFG is another one you could potentially get around. People have demonstrated that even with V8 on Chrome. So, this right here, I just wanted to point it out. There are two fields and rest in peace to Jeff Chappelle, brilliant individual who passed away recently, sadly. But he maintained this site and I hope it stays up forever because every time Microsoft would make a structural change or add a new mitigation, like if you can see the ones towards the bottom on the right, mitigation flags too, you see things like control flow enforcement technology and shadow stacks. Those are relatively new mitigations. And these are bit masks that are set as a member of the e-process structure. And those are the things that are being checked. That's why a lot of times you might hear people getting around SMEP, like supervisor mode execution prevention, by setting a bit or flipping a bit inside a control register while under a certain context. Getting around patch guard by doing it fast and doing a race condition. So, the more you understand from an offensive perspective about these mitigations, the more you'll be able to get around them potentially or know when to call it a day. For me, it's all about saving time. If I know a mitigation is likely on and I'm doing a patch dip or find a zero day and I think it's not going to be fruitful for me to continue down that path, you got to pay your dues though. You will have those harsh, frustrating days. I still have them all the time. From a defensive perspective, it really helps you to understand how these mitigations work so that if you don't want to turn all of them on, you know which ones are going to be more beneficial, which ones have less overhead, which ones actually do stop an exploit technique and which ones are pretty useless. So, some takeaways, I think I went through some already, but it's a lot of nuance and I think that that gives us power where AI won't take over our jobs anytime soon because the circumstances in which you will be doing your research requires something that machine learning just can't do right now. And there's synergy there as well when working with other researchers. The golden years of binary exploitation can be behind us, but it's not going away anytime soon. People ask me, they probably ask you all the time, for how much longer am I going to be able to do this? As long as it's possible. People are going to keep doing it. It's a lot harder now, but I use an analogy like Tony Hawk, the skateboarder. What he was doing in the 1990s, there's like an eight-year-old kid able to do that today. We're just, all this information is out there to get you up to speed from all the research done in the past, fast, so that you can then go and bring about novel exploitation techniques and new zero days. And the ethical considerations are something that you have to understand and think about. There's new acts and new legislation out there, like Paul Maul and such, that we have to worry about. But as you probably know, the more you push researchers and say you can't do something, the more likely they're going to go unethical route and sell it on the dark net and make money that way. So, mitigations are a real thing. They're hard, but they're not going away and you just have to deal with it. You have to think about it as if there's always a way around it. And the prize will continue to grow. What was $10,000 is $500,000 now. So it is worth your time putting months into research. So references and thanks, there's always more people than I can remember to thank, but lots of researchers out there in the past. Jeremy Tinder, just a shout out to him for getting me those Microsoft documents or those updated charts, which is cool. Brad Spangler helped me out with going over some things, so I'm not going to go through everyone. Harun Mir is the individual I said that did a talk from 2010 that went through every single mitigation that ever came out. It's a beautiful document. Definitely check that one out. And a lot of other folks as well. Thanks to DEF CON for selecting a talk. That is it. I think I'm right on time here. I'm happy to, you know, chat out in the hall because I know I've got to make way if you have any questions, but thank you so much for coming to my talk. I really appreciate it.