I'm Zeno Kova. This is Corey Kallenberg. And we're going to be talking about detecting code integrity attacks today. So we work at the MITRE Corporation, which is a nonprofit company that runs five federally funded research and development centers for the U.S. government. And the main place you would have probably heard of MITRE is from CVE. So we run CVE. So most of our stuff is not public facing type things. So we're happy to be able to talk about this publicly. And so like I said, the problem we're going to talk about today is code integrity attacks, knowing when someone is compromising your code and modifying it. So the way that the security game plays out today is that you've got malicious software and you've got security software. And the security software is supposed to just tell you of the presence of the malicious software and hopefully get rid of it. Well, so at such time as the security software is actually good enough to... to get rid of malicious software, which I don't think we're really there today, but in a future world where we have security software which actually impedes the attacker in some meaningful way, then the security software will start to become the target by the malicious software itself. So they need to keep doing their job. And so they can start instead of going after, you know, just generically bypassing signatures and going after the operating system to compromise, you know, the stuff below the security software, they can go after the security software directly. And they can use code integrity attacks. That means things where you're putting an inline jump in some code which jumps out to stuff and filters results as you see in root kits. It can be things like no upping out checks within code in order to force it always down some path like you see potentially with software cracks and things like that where you want to bypass a key. So the point is the security software will now lie. The security software when it's targeted specifically it's going to lie because they're not really built to handle an attacker at the same privileged level being able to modify them. So what we do is we, you know, we can add some additional software to try to deal with this problem. We can add more software which doesn't necessarily solve the problem, but we can check the security software. Well, that's not going to solve the problem. Well, if we do this, then the attacker is just going to play the same game. You know, adding more software that's not fundamentally different is not going to make any change. They're going to do the exact same thing against our security software as well. And so our program is called Checkmate. Checkmate has, it's checking the security software. But the important thing is that now we're adding a self-checking mechanism so that we tell you, our software may be forced to lie and it may say the security software is okay, but it's not going to check. But then when it checks itself, it's going to say, but don't believe me, I'm not actually okay. And so some security software does incorporate some element of self-checking into it. But we would argue that the current self-checking mechanisms are pretty naive. And they really, you know, when you're doing a self-checking mechanism and you're evaluating it on the system that's being checked, that's the expected compromise system, that just leads to problems where ultimately it's bypassable. So, I mean, if we add this sort of self-checking mechanism as a way to check, as I said, some security software does have a type of this, while the attacker can just again play the exact same game, go down to the self-check software and manipulate that. So the point is you can just keep playing this game at infinitum and it's not going to make a difference. So, but the key difference that we're going to talk about with Checkmate that differentiates this from other security software is that we build the self-checking mechanism in a very specific way where we're constructing the self-check explicitly to build an attack against the attacker. So we're using a timing side channel in its execution. So here we're using a timing side channel to help us in defense rather than you typically see it used in offense to extract keys and things like that. We're making it so that with our self-check, if you try a code integrity attack against it, it will lie just like the attacker wants. It will calculate that, you know, the check sum is good. But it will lie in such a way that the timing is manipulated. So this is analogous to the case if you ask someone if they're okay and they say, I am okay, you don't believe the content of that message, right? There's something wrong about the timing of that message that indicates that the person is not actually okay. So that's the key point. There's a lot of work that has to be done in order to get this software in this specific way and we'll sort of talk through the design parameters that are necessary. So as I said, Checkmate is two components, but we're only going to be talking about one today. There's the measuring other security software and we're going to talk a little bit more about that in a little bit. We're measuring the operating system itself. This is analogous to other memory integrity verification things. Patch guard in Windows does some Windows OS self-checking. Companies like Mandiant and HB Gary have things which do memory integrity verification because obviously they're concerned with that. Having done, you know, having good experience with root kits, they know that that's a necessary component. So we're focusing on the self-checking mechanism. This is what the other security software doesn't have. So you can take, you know, any kind of defense, any of those, if you're targeting them specifically, you can make them lie. And the point is they don't care about that because they said, well, in some future world where the attacker cares enough to target us, then we're winning. But until we see that, we don't care. But of course you're not going to see it because they're making you lie. So why would you see it? So we call this timing-based attestation. Attestation is just a fancy way of saying that you're providing some evidence about the state of something. You're attesting to the integrity of your code, for instance. And so this is based on academic work called Pioneer by Seshadri, et cetera. If there's any academics in the crowd, this is out of A.G. and Parag's group at CMU. And so the key point is we kind of consider our specialization area of research to take other people's research and make it more practical. So this was, Pioneer was good. It was for Linux. It was, it had some assumptions that we wanted to loosen so that we could get this to work in basically our corporate environment. And so we independently recreated this just to confirm that this academic work actually does what it says it does because you can't always believe that. And importantly, the source code is available. So, you know, as we're going through here and you're thinking to yourself, what if I do this, what if I do that, well, you can go actually do it and you can see if you can write the assembly more optimized than us and prove that you actually can compromise it. So with that, I want to cordially thank you for your time. It's great to start talking about the design. Okay. Thanks, everyone, for coming. Can you all hear me okay? Good? Okay. So you may be asking yourself why do we even want to do this? And just keep in mind the goal here is we want to build tamper-resistant software. If we're building some type of malware detection capability, like Zeno pointed out, the malware will eventually come and try to tamper with us. So we want to be able to detect that. So a very primitive case will be something like this. You might have seen this before. This is a very primitive case. You might see this in some current commercial software where they'll be doing a basic checksum of their own code. And then, you know, if the checksum is good, it will continue. And if it's bad, it will be some type of fail case. And often with malware, you'll also see like, you know, RDTSC command. And if it's not within expected time constraints between point A and point B in the code, it will go to a fail case where it's being debugged. So this is naive because obviously anyone that knows anything about X86 assembly can just come in and do something like this. You know about the call to this assembly. You know about the call to this self-check. And then you just hard code, you know, the expected correct self-check sum there, the correct hash. And then the code would have no idea it's been tampered with, right? So unfortunately at this point, most sort of commercial software out there kind of gives up. And they either just rely on, you know, something simple like this or they don't do it at all. And maybe to improve it, they'll just try to obfuscate the hell out of it. But they never really try to improve upon that method and make it more hard. And that's what we're trying to do here. So that's what we want to do. We want to make this style of self-attestation better and more resilient to attack. And so in order to do that, we have to fundamentally change our approach from what I just showed you. So first of all, we have to make our self-check, our hash that we're doing over our own code a function of a nonce, a random value sent from a verifier. That way the attacker can't just hard code the correct value, right? Because it's going to be different depending on the random value coming from the verifier. Another key point is with things like patch guard that are sort of trying to measure themselves and attest to their own integrity. The verifier also exists on that system. So with patch guard, you know, it's trying to verify itself and determine whether or not it's been compromised. And all that's happening on the compromised system. So the attacker, if they can compromise the system, they can just compromise the verification software and patch guard as well. And patch guard would have no idea that it's being tampered with. So we incorporate this trusted server that we assume is not compromised. And it's going to get the results of that self-check sum, send back to it from the client, and then, you know, in a secure environment, what we assume is not compromised, take the results of that self-check sum to try to make a determination about whether or not it thinks the software has been tampered with on the client side. So our framework, as opposed to what I showed you previously, looks a little bit more like this. Obviously it's not the real deal, but just a pseudo code here. And so we have our check sum and then it's going to be waiting for a request from the verifier, some type of server. It's going to get the nonce from that server, which point it knows, okay, the server wants me to attest to my integrity so it can know whether or not it should believe any measurements I sent it so it knows whether or not I've been tampered with. It's going to do a self-check sum based on that nonce and then obviously send the results of that back to the server. All right. So the first thing, like he said, the first thing the nonce gives us is just there's not a one-to-one mapping of, like, this is the correct self-check. So we're going to have to do a self-check sum. So now if we have a nonce that's 32 bits, we know that there has to be at least, you know, two to the 32 possible combinations. When we have a larger self-check sum that's not just, you know, a single 32-bit value when it's actually 60 words, that means you've got actually an attacker would have to pre-calculate 96 gigabytes worth of data and, like, keep that on the machine that he's compromising. If he does that, then he can, you know, definitely respond in the correct amount of time. He can just say, oh, let me look that up in my table. This input nonce equals that output check sum. Let me just send that along. But, you know, for our laptops and things like that, we don't have 96 gigs of memory on them. So we consider this a good enough initial thing for 32-bit systems. You know, maybe a big huge 32-bit server wouldn't be. But then you go to more 64-bit systems. On the 64-bit systems, it's just completely infeasible that they're going to do a pre-calculation of all the possible inputs to outputs. So that's the first good thing you get by adding a nonce and making it so that every different self-check sum is there. So that's the first good thing you get by adding a nonce and making it so it's fresh and it's a function of a nonce. So now we want to talk about, you know, what is the actual data that we need to attest to in order to say that our code is untampered? Well, the first and most obvious thing is we have to read our code itself. We have to measure our code and somehow mix that into the self-check sum and then, you know, that will ‑‑ you can think of it like, you know, in the naive case, you do a CRC over your own code in order to say my code is good. Or you do a hash over it, et cetera. But, you know, it's not going to be good. We're doing, you know, a sort of special checksum that has some additional criteria that we'll talk about next. So the first thing is you need to read your own code. The second thing, sort of the second and third thing is that you want to say something about that the code that's reading your own code, the self‑checking code itself, you want to say something about it's in a range that you expect and everything sort of matches up. So first of all, you have the pointer that's pointing to yourself. You include that pointer because that says something about where in memory your code is actually reading itself. So where in memory is your code stored? And then you include the instruction pointer next because that says where in memory your code itself is executing. And those two things should kind of, you know, match up and be in the same memory range. Otherwise, you know, you could potentially have an attack. So now if we expand this a little more, we dive down into the self‑check and we say, okay, what do we need to incorporate? So now a self‑check, our pseudocode here would look like, you know, get the start of my code, get the end of my code, and now inside of a while loop, and this while loop is a very critical component of it, inside of my while loop, I'm going to loop through and I'm going to just somehow incorporate the nonce that I got in the start, the star DP, that's the dereference data pointer, that's my actual, you know, four bytes of code. The data pointer itself. I'm going to calculate the EIP using, you know, the typical assembly mechanism of just calling zero bytes ahead and then popping the return address off the stack which gives me, you know, my current EIP. And then going to mix that in as well. And then finally there's just this generic mix that we're talking about here and that is basically it's a rotate and that's because some of the previous academic work had found that, you know, if you don't ‑‑ it's some of the previous academic work said you can kind of think of this self‑check sum like a stream cipher and you want to add confusion and diffusion and so this mixing is the diffusion. You want to rotate the results so that if there's like just a change in one bit, it will eventually rotate through and affect all the bits. So there's some additional problems with even this. So ‑‑ Even this code right here, this pseudo‑code, there's a couple of problems that we have here. The first is that it's potentially parallelizable. We said, you know, think back to the very first thing we were talking about. We're trying to get code where when it lies to you, it lies to you in a suspicious way. The timing of it is different. And so the problem here is we want to get it to, you know, there's some fixed amount of time that this thing should take and you should never be able to go faster than that. Well, the problem is the code is potentially parallelizable. So that means an attacker could break the code. You know, it's not going to be able to go faster than that. If I'm just writing this code and running it on my CPU, an attacker who knows more than me can go, you know, parallelize it off on the GPU. Well, so you can actually get around that. That's one of the first things a lot of people think of is I'll go faster by parallelizing. You can get around that by computing the self‑check as what the original pioneer paper called a strongly ordered function. I haven't been able to find any reference to this in other works. I don't think this is the correct term. But strongly ordered function just means the order of operations matters for the output order. And that means you can't rearrange the order of operations. And so you can do the math on it and see that if you take A plus B and you take the quantity A plus B and then you XOR it with C and then you take that quantity and then you add it to D and so forth. If you're accumulating this building up this checksum, if you do it in that order as opposed to you take A and B and you go do it on one core and you do C and D on another core and then you try to XOR those results together, with high probability the results are going to be different. And so by doing doing this, just making sure that when we incorporate things into the self checksum that it's this add XOR, add XOR, and you want to make sure you're always maintaining that, then we're successfully making it non-parallelizable. So that takes that off the table. Then the other problem is one of just optimization. So we said we want to make it so that our thing is the fastest possible implementation. We're running as quickly as possible so that if the attacker adds overhead, it makes it take longer and it's lying in a strange way. And so this is kind of a problem which you can't really get around. There's no formal way. The academic sort of got side tracked here with saying we're going to formally prove that this is the optimal Intel assembly and that's a very hard thing to model. So basically we did the same thing that the previous work did, which is you guess and test it and you say, all right, let me change this assembly instruction and let me reorder these two instructions. You just keep trying it until you think what you have is the fastest possible way to calculate this add XOR. So that's kind of the problem. So this is kind of a problem which you can't really get around. You're just going to have to add XOR, add XOR, sort of checksum over the data pointer, the data pointed to by the data pointer and the instruction pointer. So that would potentially this is what one attack would look like. Okay. With this new solve checksum in mind, an attack against it would look something like this. So we have the same sort of loop set up where we're iterating over our own code and incorporating these key components like the data pointer, star DP, the data to data pointer, the EIP and so forth. So if an attacker wanted to forged that checksum while still tampering with the code, you would basically have to keep track of where the data pointer is currently and if it's pointing to some of his code that's tampering like an inline hook or a software break point or something like that, instead of actually incorporating the data at star DP, he would want to incorporate the clean copy of those bytes. So instead of incorporating his inline hook, incorporate what was there previously before he had tampered with the code. And notice, while this isn't a lot, this sort of if branching in x86 would only amount to a few x86 assembly codes, if we were doing this loop over millions of times, like 2.5 millions of times, that would actually cause the attacker to have to execute 2.5, 5 million, 7.5 million extra instructions in his calculation of this checksum. And that would induce a noticeable time difference and that's actually the time difference between the two. And so that would actually cause the attacker to have to execute 2.5 million times. So under normal circumstances, this is what the self-checksum typically looks like. So on the left we have the server and what's going to happen is it's going to send a nonce to the client and the client is going to use that as the input, the seed to its self-check and then that self-check is going to go back to the server. And then notice the server is basically incorporating the total network round trip time that it took for the client to respond to that self-checksum. And so it's going to say, okay, your checksum is correct because I calculated this on my own side and I know this is what your code should look like when it's been hashed correctly. But also the time it took you to respond to my request was within our acceptable limits, so I actually believe you. And based on that determination, it would basically trust or not trust the results of this next measurement. The next measurement would be something like, you know, a measurement of N2S kernel, or your security software or something like that. So this is what the diagram would look like if we were actually attacking and tampering with the software. So it starts off the same where we send a nonce to the client and then the client uses the nonce as the input for its self-check and then the self-check goes back. In this case the self-check is correct because the attacker has, you know, forged the value. He's done that, you know, keeping track of where DP is and if it's pointing at bad, tampered with data, he's going to replace that with good data. And then we have the check sum. And so the check sum checks out. But then the server notices, okay, look, your network round trip time has increased somewhat. You can see that on the left side, the delta T is larger than expected. So, yeah, your check sum is correct, but I know that something is up because it took too long for you to respond to me. And so this measurement of your system that you also sent, the measurement of N2S kernel or whatever, I'm not going to believe it because I think you're being tampered with. Okay. In general, this is sort of an iterative process where we're going to be working on the check sum and then notice some problems with it and then we'd have to change the design based on what we discovered. And so another problem we noticed with this approach was that when we're incorporating the instruction pointer, it's the same at every iteration in the self-check sum. So instead of doing this goofy trick where you have to, you know, call ahead, then pop off the stack to get your current EIP and x86, the attacker could actually just hard code that instruction pointer. So notice in this case he's actually gained a few x86 instructions that he does not have to execute. So, you know, we're going to be working on the execute. He's made the self-check sum smaller. And so he's gained some instructions by optimizing this instruction pointer being inserted into the check sum. So that would allow him to go over here and forge the data pointer and so he would be able to tamper with our code and have a net result of zero additional time into the calculation of the self-check sum. So with this in mind, we had to go and sort of redesign how we are going to actually calculate this check sum. So what we need to do is make it so that it's not a fixed instruction pointer which is always incorporated in the check sum. And so how this can be done and how it was actually done in some related work is you make it so that you break up your code into multiple blocks. Each independent block is still doing the same sort of thing that you just saw on the previous slide. It's incorporating the data pointer, start EIP, instruction pointer. But the key thing is that you pseudo randomly choose which location you're going to go to next. So basically what we're basically what this sort of diagram is trying to show, if you can see my mouse, is that when you start out at block one, you go down to the end and the first loop through, block one may choose to go to block two. Or sorry, go to block three. Then block three will get done and it will go somewhere else. But the second time you get through block one, it will pseudo randomly choose that it's going to go to block four. And so the key point here is the attacker can't hard code the location where you're going next because it's chosen differently each time. So to do that, we need to add a pseudo random number generator. We use the same one Pioneer did and it's basically you see it with your nonce. That's easy. You've already got some fresh seed for it for every single measurement. And then you just basically do it. This is nice and simple in assembly language. You basically take your current value times the current value squared or with five. And so this works as a pseudo random number where it will cycle through all the possible values before looping back to the one where it started. Then we can also do some things like making the data pointer a function of this pseudo random value that we now have available. So instead of doing a strict linear sweep over our entire memory, we can bounce around and we can go to different locations each time. And that potentially makes it so that the attacker can't say, well, I know that when you get to loop, you know, 4,086, you're going to hit my data that I compromised. You're going to start reading that. And so I'm just going to like, you know, pop in just in time at 4,086, maybe I'll use some other processor to like change this stuff just in time. He can no longer have an expectation that for any given nonce, he doesn't know when we're going to be reading any change that he potentially made to our own code. So this is the closest thing we're going to show to the real code. We'll show the real code next. But this is just again, this is still really just pseudo code. But this is almost real pseudo code. And so how it works is we've got eight macros, block zero, block one, block two, through block seven. Each of the macros that we're using does the same thing. They're basically going and now we're not having that while loop just as straight up regular C code like you're used to. We're saying, you know, there's going to be some loop counter that we're keeping track of as we go. As Corey already mentioned, we do two and a half million iterations through this loop. So we'll hit one of these blocks, you know, two and a half million times. And so if the attacker wants to compromise this, he has to, you know, modify things within this and make sure that he fixes up all the values and that adds instructions which when multiplied by two and a half million equals many instructions. So basically look at the loop counter. If we're done with looping, just jump to the end. Then, you know, in the real assembly language kind of thing, we already have like two forms of the instruction pointer. We have one of them just already sitting in the ECX register because that's what we use at the end of the block. And then we have one that got pushed onto the stack. So we've got like a target destination EIP, which is the start of a block, and we've got a source EIP, which is what gets pushed onto the stack. So we've got like a target destination EIP, which is what gets pushed onto the stack by a call instruction at the end of each block. And so we start mixing these things together and all we're doing is we're going to do an add XOR, add XOR with each of our values that we said we care about. Starting with the EIP and the next thing, add in the pseudorandom number, which we changed through each loop, add in the data pointer, the data pointed to by the data pointer, go ahead and update your pseudorandom number with that X equals X squared over five, and then update the data pointer so that we choose a new pseudorandom location with our own code. That's going to be the next step. So that's the next place that we're going to read ourselves. And then mix it all together with rotate. And then finally we're going to calculate the next location to jump to pseudorandomly. And so you can think of these blocks, they're all just code in an array in our own kernel module. And so you can think of it like an array of eight of the blocks of this assembly language. So we're going to start at the base of the array, block zero base, and then we need to pick the new index pseudorandomly. So we take the pseudorandom number, we OR, we EIP, and then we're going to end it with seven in order to get the bottom three bits, right? So that gives us potential eight possible values that we're going to index to in this array of code. And so that basically says take the size of each block plus this index, zero to seven, and then that's the next place we're going to go. Just calculate that all, put it in ECX, that's where we're going next. So you can read the real paper, you know, this has academic paper behind it, 16 pages of goodness and plenty of assembly. And then we're going to take the size of each block plus this index, zero to seven, and basically all of this stuff looks exactly like that sort of code I just showed. The only difference is we show the actual rotates here, and then there's some additional state that we want to keep about the system that we don't have time to go into. But there's additional stuff you want to do. Otherwise, there's additional attacks the attacker can do. Okay. So defense is boring. So let's talk about offense a little bit. So what would the attacker have to do if he actually wanted to try to break this system? Well, you know, we're going to try to break this system. Now, the original paper that we mentioned, the academic paper out of CMU, outlined four attacks, or I guess really three attacks that you can do against this style of a self-checksum. And so keep in mind that we're incorporating things like the data pointer, star DP, star DP, the program counter, into the self-checksum. So if the attacker wants to forge the checksum, he's going to have to, and be manipulating the code, he'll have to forge some subset of those components we're mixing in, star DP, DP, or the instruction pointer. So if the attacker wants to forge the checksum, he's going to have to do that. Notice if he wasn't forging any of those values, if DP was the same, if EIP was the same, if star DP was the same, he would just be running our untampered code and we would be winning already. So he's going to have to forge some of those values. So in the naive case, the worst case for the attacker is basically where he is forging most of those, the more components he has to forge, the worse for him. So in the worst case you can see on the bottom right is when he's forging the data pointer and the program counter. So how this attack typically works is the attacker would create a clean copy of our self checksum code, what we're measuring over, and then he would point DP at that code and he would have some custom, his own version of the self checksum that is going to point DP at that code. And then notice if DP is pointing at that clean copy, star DP will already be good, since it's good and untampered. But he'll have to be, you know, DP is having to be forged because it's not pointing at the real copy of our code. It's just a clean copy. It's not where our code actually is. So it's going to be a clean copy of our self checksum code. So that's the worst case for the attacker. And then you have to forge the program counter, the instruction pointer, because he's not executing the real authentic self checksum. He's executing his own custom version that is forging these values. So that's the worst case for the attacker is having to forge all of those components. The best attack we could come up with was in the bottom left where the attacker does not have to forge star DP because he's using a clean copy, like I outlined before. And also he does not have to forge DP. So he's using a clean copy. And the reason being we're running this on a Windows environment as a Windows kernel module. And even in Windows XP that doesn't have ASLR, we have something that we have to deal with called foe. We call it foe ASLR. And that's because the Windows kernel module loader doesn't respect the base address that you put into the kernel driver. So you could tell the kernel, hey, I want this driver loaded at address OX deadbeath. But the kernel is going to totally disregard that. So we actually rely on the, you know, the, you know, the, you know, the, you know, the, you know, the the self checksum code to report back where it's located in memory. And this introduces an attack into our system where the attacker can also lie and say, hey, guess what, you're actually located where your clean copy is. And this allows them to not have to forge DP. But they're still having to forge the program counter because they're running their own custom version of the self checksum code. Hopefully this will be a little more clear when I show you the diagram next. Okay. So once again, this is what the self checksum looks like. On the left we have the server, where the verifier and on the right is the client. And on the right is the server. And on the client. So the measurement request comes in to the client, including the nonce for the self-check sum. We have this main switch case that's receiving all these packets and it says, okay, I've got a self-check sum request. Let's go ahead and do that. Here's my nonce. The self-check sum occurs, goes back to the server. The server is like, okay, everything is all good. Your self-check sum is good and it took the expected amount of time, so I believe you. And then obviously the whole reason we want to do this is because we can measure other important parts of the system, like the kernel, and also believe those measurements. So the system is also going to do a measurement of NTOS kernel and send back to the server and the server says, okay, NTOS kernel looks good and I believe what you're telling me about it because your self-check sum was good as well. All right, now let's switch back to attacker mode. This is what would happen. Notice the main thing the attacker is concerned with, again, is corrupting this general system measurement. So he wants to install hooks into NTOS kernel, things like kernel loggers, and that's where keyboard loggers are. So he wants to install hooks into NTOS kernel, things like kernel loggers, and that sort of thing, and have them be undetected by our measurement system. So that is what he is interested in protecting and not have show up in the measurement values. Okay. And so to pull this off, first the attacker installs an inline hook at the beginning of our self-check sum. That way he can gain control of EIP. He has this custom version of the self-check sum that is going to forge the self-check sum value, even though the original code has been modified. He still wants to produce the correct self-check sum. So he's going to do that. The measurement request comes in from the server. We naturally call the self-check sum code, but look here, we have the inline hook, so the attacker gains control of EIP. He is now running his custom self-check sum code. Over on the right we have the clean copy of the kernel module, the unadulterated copy, not tampered with. The attacker points DP at this clean copy. And he also lies, notice on the response back to the server, he's saying, hey, guess what, my base address is actually this is allowing him to not have to forge the data pointer. Because we don't know on the server side where our code should actually be located in kernel memory because of that FOBASLR. So then the attacker wants to execute his corrupted system measurement call. That way he can lie about what NTOS kernel actually contains. That goes back to the server. The server says, okay, NTOS kernel looks good. The self-check sum matches up with what I calculated. on my own side but you took too long to do this so I don't really believe you so we would flag that as something that needs investigation. All right. So that was the design and justification kind of thing in a nutshell and now we want to say does it actually work. So we ran experiments on our actual corporate intranet and we're going to show you data for two types of experiments. The first one is we wanted to see like over the maximum hop count that we can find at our campus, you know, does this attack still detectable. You know, what about network jitter and things like that, is there too much noise in the network that we can really see this attack. And so that's the first thing, does it work over the maximum hop count? And the second thing is, does the same, you know, is there a single bound that we can set to say this is the good self-check time and can we use that same bounding at different locations on our network. So we're going to take two hosts, we're going to take the same network and we're going to put them at the ten links and physically move them to eight links away and physically move them to three links away and measure them again. So these were desktop systems. So here's some raw data. So we had 31 different hosts over in a lab that's used for our training. And so 31 hosts, you can see that basically the first thing here is that all 31 hosts basically behave the same way at the same time. So when we have the no attack present, all 31 hosts basically take about 111 milliseconds to do this round trip time. So we send a request from our server, they're ten links away, they calculate the self check sum, they send it back in 111 milliseconds. When the attacker is there, so we have the ability to turn on our reference attacker, just like toggle it on with a request. When the attacker is there, clearly the attack is a much different thing. So when the attacker is there, the attack is a much different thing. So when the attacker is there, the attack is a much different thing. So when the attacker is there hacker, it's always going to take him 1.7% longer in order to do this. So if instead of doing 2.5 million iterations, we do 25 million iterations, then instead of taking an extra 2 milliseconds, it's going to take an extra 20 milliseconds. So you can always increase that, but it's at the cost of this thing taking more time. But you see a graph like this and the first thing your eyes are drawn to are the outliers and you say, what is that? What does that say about your results? And so first of all, you say when there's no attack present, it actually sometimes goes faster than the quote baseline correct good thing. And so we think that's just initial evidence that we haven't sufficiently optimized this or that we're not potentially taking some caching effects and things like that into consideration. But the important thing is that first of all, the amount of magnitude that this pulls a good guy down in these best case runs is not enough to pull an attacker down into the good area. And so we're going to be looking at this as a way to see if an attacker could somehow take advantage of this. And the second thing is that, like I said, this is 31 hosts and this is actually just one off measurements here. It's basically, you know, this one host, this one time somehow got lower. And so we basically think this is just, like I said, we're not necessarily taking all potential caching effects and stuff like that into account. And so maybe in some cases it's just getting lucky and it's hitting, you know, the perfect, all the cache and everything is just lined up and everything runs a little bit faster. And I should say we validated these network round trip times against RDTSC self-reported self amount of time, which we don't, we wouldn't use in real system. But for experiments we confirmed that these are not like network abnormalities. These are actually on the host. It definitely took less time. And so the next thing you're going to ask is what about the things where in the attack case it's getting pulled up. So you see there's no attacker data where he gets, like, pulled down accidentally. There is attacker data where he gets pulled up. We think that's, again, the same thing. We optimized the thing as best we could through guess and test. And we know that when the attacker is adding in additional instructions, clearly it adds overhead. But then he's maybe having more opportunities to get unlucky on the caching and side effect type things as well. So the next thing was just to say something about, you know, is there a single value that we can say in baseline, like, this is the correct time that it should take for, you know, core two duo running at three gigabit per hertz, you know, this particular revision of the hardware. And so the answer is, yes, there is some upper and lower bound we can set. But, of course, as you would expect, the more network hardware you go through, the more potential there is to pull up the amount of time that is the quote good time. And so all this is showing basically is that when you're one link, when you're connected through a crossover cable, your measurements are down there in the, you know, 110.25 range. And when you're over ten links, you're up closer to the, you know, you know, the 110.75 range, things like that. So this is saying we can have ‑‑ we do have a wider range in this sort of case. But the key point is we can use a single baseline and it's still sufficiently distinguishable from the attack traffic as you can see at the top of the graph. And so that worked for us, network time within our intranet. But obviously when you have jitter and things like that, we don't expect this to work over the Internet. We don't expect this to work over wireless. So Corey is going to talk about what we can do. Okay. So like Zeno pointed out, this scheme obviously wouldn't work over like a VPN over the Internet because of the large amount of network jitter. Lucky for us, these academics proposed a similar protocol that used the trusted platform module as sort of a trusted stopwatch is the best way to think of it. And so that way you can push the timing to the client side. And you can actually trust that timing because the TPM is signing the times. Unless you're Chris Tarnowski and have a fib or something. Hopefully you can't forge your own time values. So the way the system works is it's very much the same. It comes in to the client. The client before calculates a self check sum, it does a tick stamp which is asking the TPM okay give me a signed current time value. Then it incorporates bits from that signature as its nonce just to avoid some possible attacks there. And then it calculates a self-check sum with that as a nonce and when it's done it does one more. Asks the TPM, sign me the time one more time and that way we have the signed time for the beginning of the checksum and the end and the server can obviously just verify the signatures on the server side to make sure the times haven't been tampered with and then take the delta the difference between the two times and say okay this is how long your checksum actually took. And so this is great in theory because it would all the timing is on the client side we don't have to worry about network jitter at all. Unfortunately things with the TPM if you've ever worked with TPM are kind of crazy and don't work very well. So let's talk about some of those results. Alright so here's that TPM implementation on the single host and you can see it's much like a diagram I showed you before. The attack is installed in the middle obviously and we have a very distinguishable attack is installed attack is not installed so they can detect that. Notice down here on the right the median goes down after the attack is installed and we really have no idea why that's happening because there's a lot of mistakes. Let's talk about let's look at this diagram. So this is a 32 host running a self checksum protocol with the TPM as well and notice they're all exhibiting this okay the time goes up when the attack is installed but also notice that all of their baselines are completely different, right? So these were all identical systems, identical CPUs, identical trusted platform modules and everything. But what we discovered was that each TPM exhibits different timing characteristics which is kind of bizarre. And even weirder for some of you people that do side channel attacks is that the TPM will actually each TPM key will exhibit different timing characteristics. So anyone that's into side channel attacks that's something you should investigate. And you can also see there's this one host up here, you know the crazy blue line towards the top and we really have no idea what the hell was going on with that TPM. It was just totally broken or something. We think we actually broke the TPM from overuse. We were using that specific system for previous experiments where we were just like hammering it with a bunch of TPM tests. So we somehow broke it. All right. So at this point this is where most academics would claim success and move on. You say I have proven that I can detect, you know, I can detect when you're tampering with my software. I can detect it over my intranet and I can detect when you're tampering with your computer. If I want to detect it, you know, using this TPM mechanism, yes, with the TPMs I have to baseline each system individually, but you already have to go around to every TPM anyways to install keys or to tell it to generate keys, so when you're generating the keys you can potentially, you know, do a timing baseline anyways. But when we were doing this, you know, we were concerned with, you know, how can we actually get around our own system? And so what we found is that the ‑‑ what we've been doing here is we've been trying to channel the attacker to this very narrow place. We want to force him, if you want to hook the kernel, you've got to hook the security software and then you've got to hook us and then you've got to hook our self-check, but aha, it's a trap, the self-check will actually behave differently once you hook it. Well, it turns out that the attacker doesn't have to hook any of that or he can change the way he's hooking in order to get around us. And you can do this with talk to attack, time of check, time of use. So when we're checking the system, it will look different from when the system is running normally. So there's three conditions that have to be met for a talk to attack. And if we can break any of them as defenders, we can break the whole talk to attack and, you know, different systems have different assumptions which break some of these. But in our case where we're assuming we're at the exact same level as the attacker and we're in the Windows kernel where there's a lot of flexibility, this can be pretty difficult. So the conditions are the attacker has to know when you're about to measure something. And so if you're at the same privilege level, that's pretty easy, right? They can always know when you're about to start a measurement by just putting a set of numbers on the screen. So if you're at the same privilege level, that's pretty easy. They can put a hook into your code, right? They're always going to bounce out to their code before you ever even have a chance to measure your own code, right? Way up in the prologue, way up in the code that listens for network packets. So the attacker has to know when you're about to start. They have to be able to move themselves to some unmeasured location or they have to remove their existing hooks for the duration of the measurement. So they basically have to clean things up so that at the time that you check it, it looks clean. And they have to be somewhere that's not measured. And then the third thing is that they need to reinstall as fast as possible after the check is done. Because if they don't reinstall right when you're done measuring, then the system is running for some period of time where they're not in control. And that's kind of a problem that, you know, leaves them vulnerable to things, to other just regular detection mechanisms. So, you know, this is what it would look like in our first sort of picture. We left off with, you know, the attacker has fallen into our trap. They've gone after the self-checking software. But, you know, if he's being clever about this, he actually doesn't have the ability to do that. What he's going to do is he's going to say, you're about to do a self-check. You're about to do, you know, a measurement of NQS kernel. Or you're about to do a measurement of, you know, McAfee. I see you're about to do a measurement. I'm just going to go ahead and erase all of the things that you're about to measure. Everywhere that you would detect me, I will erase that. And only that. He can still have hooks elsewhere in the system. He just has to target it to the specific measurements you're doing right now. And so in that case, you do a measurement and there's no changes detected. Once you're done with that, you can go back to the server. Once you're done, he reinstalls himself immediately at the end. All right. So we really found that there's actually a bunch of academic work that is talk-to attacks, but it doesn't, like, claim it explicitly. And so that's why we kind of thought it was important to pull out this because you look at things like academic and non-academic work as well. I mean, if you're thinking in a talk-to sort of sense of things, you can look at, like, where did Joanna Rakowska leave off the, you know, virtualization-based rootkits and things like that. She left it off with, okay, yeah, you can do this. You can do this. You can do this. You guys can go time me in order to detect that I've got a malicious hypervisor. But I'm going to watch for you timing me. And if you do that, I'm going to uninstall myself, let you do the timing check, and then once you're done, I'm going to reinstall myself. And so she called that blue chicken, but it's really a talk-to attack. And so this is sort of a problem for any sort of measurement system. There's the potential here, and you have to design with it explicitly in mind. And so we don't think that most things are doing that, and we certainly didn't do that. And so now we're going back and trying to figure out how to do that. And so we're going back and trying to figure out how we can deal with talk-to attacks to break things. And so most economic work will just say, like, you know, I'm in the kernel. You're in user space. You can't see when I'm about to do a measurement. I'm in a hypervisor. You're in kernel space. You can't see when I'm about to do a measurement. I'm in SMM. You're in a hypervisor. You can't see when I'm about to do measurement. You can break it by violating the assumption that they don't know, or you can break it by saying there's no unmeasured location. I'm just going to measure everything. And that will work on, you know, some limited systems, embedded systems, things like that. But for desktop systems, we're not going to measure all four gigs of memory or, you know, if it's a 64‑bit system, however much memory. We're not going to do that every single time, so that's not reasonable. So we're sort of focusing more on the, you know, preventing them from reinstalling themselves deterministically, having some window where they've let go of the system and taking advantage of that. The other just minor point is that we've said this talk is about code integrity, protection, detection. Control flow integrity is something that we've been talking about for a long time. We've been talking about code integrity, just meaning, you know, if there's other ways besides hacking the code that they can get ‑‑ they can start running their stuff, the most common one being changing function pointers and things like that. Those are kind of enablers for talk‑to‑attacks. That's why they can see that you're about to start doing things. All right. So in conclusion, what we've basically shown in this work is that, you know, we have a more practical system, runs on Windows XP, runs on Windows 7. We have a system where we can detect if you're modifying our self‑checking code. You can detect it on Windows 10, you can detect it on Windows 11, you can detect it on the intranet based on the round trip time. And we can detect it, you know, sort of arbitrarily based on TPM, trusted stopwatch, if we baseline the time for your specific system. And we know that the attacker can get around it with talk‑to‑attacks, but the key point is, we ‑‑ he's doing a talk‑to‑attack, our code is unmodified. So in the academic sense, we've won, but, you know, we're still concerned about this. So we still want to find ways to mitigate talk‑to‑attacks. So thank you for coming. You can go check out the code, on Google code page. And we've actually got videos, rather than read‑me files, we've got videos that show you exactly what you should do in order to install our software and validate our results, run it on your own machines, tinker around with the assembly code, see if you can make it go faster than we can. And so speaking of videos, the last thing we're going to pimp here is open security training.info. That's a site that we contribute to on our free time, where we put up class material that we use for monitoring our software. So if you're interested in MITRE internal training, and then we put up the materials itself and videos. So I've got eight days' worth of material on things like X86 assembly, architecture, virtual memory type things, PE binary format, root kits. Corey's got two days currently up on exploits, intro exploits, but he's got three more days of videos that we're going to be editing after this. So we've got things on that. We've got a TPM class in the works, which will sort of make TPM not a black magic voodoo DRM box. So we're going to be editing that. So we're going to be editing that. So we've got a TPM class in the works, which will sort of make TPM not a black magic voodoo DRM box. It's just another sort of interesting chip that you should really try to play around with. And we've got things like virtualization, reverse engineering, and so forth. So check that site out, and come visit us in the Q&A session. Thanks for your time.