1 00:00:00,000 --> 00:00:05,260 I'm Zeno Kova. This is Corey Kallenberg. And we're going to be talking about detecting code 2 00:00:05,260 --> 00:00:11,640 integrity attacks today. So we work at the MITRE Corporation, which is a nonprofit company that 3 00:00:11,640 --> 00:00:17,740 runs five federally funded research and development centers for the U.S. government. And the 4 00:00:17,740 --> 00:00:23,960 main place you would have probably heard of MITRE is from CVE. So we run CVE. So most of our 5 00:00:23,960 --> 00:00:27,900 stuff is not public facing type things. So we're happy to be able to talk about this publicly. 6 00:00:28,820 --> 00:00:34,280 And so like I said, the problem we're going to talk about today is code integrity attacks, 7 00:00:35,040 --> 00:00:42,520 knowing when someone is compromising your code and modifying it. So the way that the security 8 00:00:42,520 --> 00:00:47,720 game plays out today is that you've got malicious software and you've got security software. And 9 00:00:47,720 --> 00:00:51,540 the security software is supposed to just tell you of the presence of the malicious software and 10 00:00:51,540 --> 00:00:56,820 hopefully get rid of it. Well, so at such time as the security software is actually good 11 00:00:56,820 --> 00:00:57,600 enough to... 12 00:00:57,900 --> 00:01:02,980 to get rid of malicious software, which I don't think we're really there today, but in a 13 00:01:02,980 --> 00:01:08,140 future world where we have security software which actually impedes the attacker in some 14 00:01:08,140 --> 00:01:14,240 meaningful way, then the security software will start to become the target by the malicious 15 00:01:14,240 --> 00:01:19,420 software itself. So they need to keep doing their job. And so they can start instead of 16 00:01:19,420 --> 00:01:24,160 going after, you know, just generically bypassing signatures and going after the operating 17 00:01:24,160 --> 00:01:28,580 system to compromise, you know, the stuff below the security software, they can go after the 18 00:01:28,580 --> 00:01:33,220 security software directly. And they can use code integrity attacks. That means things where 19 00:01:33,220 --> 00:01:40,300 you're putting an inline jump in some code which jumps out to stuff and filters results as you see 20 00:01:40,300 --> 00:01:46,500 in root kits. It can be things like no upping out checks within code in order to force it always 21 00:01:46,500 --> 00:01:51,500 down some path like you see potentially with software cracks and things like that where you 22 00:01:51,500 --> 00:01:54,040 want to bypass a key. 23 00:01:56,080 --> 00:02:01,680 So the point is the security software will now lie. The security software when it's targeted 24 00:02:01,680 --> 00:02:07,300 specifically it's going to lie because they're not really built to handle an attacker at the same 25 00:02:07,300 --> 00:02:15,000 privileged level being able to modify them. So what we do is we, you know, we can add some 26 00:02:15,000 --> 00:02:20,420 additional software to try to deal with this problem. We can add more software which doesn't 27 00:02:20,420 --> 00:02:24,120 necessarily solve the problem, but we can check the security software. Well, that's not going to 28 00:02:24,120 --> 00:02:27,000 solve the problem. Well, if we do this, then the attacker is just going to play the same game. 29 00:02:27,200 --> 00:02:31,080 You know, adding more software that's not fundamentally different is not going to make any 30 00:02:31,080 --> 00:02:35,300 change. They're going to do the exact same thing against our security software as well. And so 31 00:02:35,300 --> 00:02:41,240 our program is called Checkmate. Checkmate has, it's checking the security software. But the 32 00:02:41,240 --> 00:02:47,940 important thing is that now we're adding a self-checking mechanism so that we tell you, our 33 00:02:47,940 --> 00:02:54,100 software may be forced to lie and it may say the security software is okay, but it's not going to 34 00:02:54,120 --> 00:02:57,800 check. But then when it checks itself, it's going to say, but don't believe me, I'm not actually 35 00:02:57,800 --> 00:03:04,200 okay. And so some security software does incorporate some element of self-checking into it. But we 36 00:03:04,200 --> 00:03:08,940 would argue that the current self-checking mechanisms are pretty naive. And they really, you 37 00:03:08,940 --> 00:03:12,800 know, when you're doing a self-checking mechanism and you're evaluating it on the system that's 38 00:03:12,800 --> 00:03:18,260 being checked, that's the expected compromise system, that just leads to problems where 39 00:03:18,260 --> 00:03:24,100 ultimately it's bypassable. So, I mean, if we add this sort of self-checking mechanism as a way to 40 00:03:24,120 --> 00:03:28,720 check, as I said, some security software does have a type of this, while the attacker can just 41 00:03:28,720 --> 00:03:33,220 again play the exact same game, go down to the self-check software and manipulate that. So the 42 00:03:33,220 --> 00:03:39,740 point is you can just keep playing this game at infinitum and it's not going to make a 43 00:03:39,740 --> 00:03:44,000 difference. So, but the key difference that we're going to talk about with Checkmate that 44 00:03:44,000 --> 00:03:49,080 differentiates this from other security software is that we build the self-checking mechanism in a 45 00:03:49,080 --> 00:03:54,040 very specific way where we're constructing the self-check explicitly to build an 46 00:03:54,120 --> 00:03:56,580 attack against the attacker. So we're using a timing side channel in its execution. So here 47 00:03:56,580 --> 00:04:02,060 we're using a timing side channel to help us in defense rather than you typically see it used in 48 00:04:02,060 --> 00:04:06,640 offense to extract keys and things like that. We're making it so that with our self-check, if 49 00:04:06,640 --> 00:04:12,600 you try a code integrity attack against it, it will lie just like the attacker wants. It will 50 00:04:12,600 --> 00:04:17,660 calculate that, you know, the check sum is good. But it will lie in such a way that the timing is 51 00:04:17,660 --> 00:04:23,280 manipulated. So this is analogous to the case if you ask someone if they're okay and they say, I am 52 00:04:26,340 --> 00:04:31,180 okay, you don't believe the content of that message, right? There's something wrong about the 53 00:04:31,180 --> 00:04:35,960 timing of that message that indicates that the person is not actually okay. So that's the key 54 00:04:35,960 --> 00:04:40,380 point. There's a lot of work that has to be done in order to get this software in this specific 55 00:04:40,380 --> 00:04:46,700 way and we'll sort of talk through the design parameters that are necessary. So as I said, 56 00:04:47,400 --> 00:04:51,960 Checkmate is two components, but we're only going to be talking about one today. There's the 57 00:04:51,960 --> 00:04:54,100 measuring other security software and we're going to talk a little bit more about that in a 58 00:04:54,100 --> 00:04:58,100 little bit. We're measuring the operating system itself. This is analogous to other memory 59 00:04:58,100 --> 00:05:02,900 integrity verification things. Patch guard in Windows does some Windows OS self-checking. 60 00:05:03,880 --> 00:05:08,360 Companies like Mandiant and HB Gary have things which do memory integrity verification because 61 00:05:08,880 --> 00:05:13,840 obviously they're concerned with that. Having done, you know, having good experience with root 62 00:05:13,840 --> 00:05:18,280 kits, they know that that's a necessary component. So we're focusing on the self-checking 63 00:05:18,280 --> 00:05:22,280 mechanism. This is what the other security software doesn't have. So you can take, you know, 64 00:05:24,100 --> 00:05:27,900 any kind of defense, any of those, if you're targeting them specifically, you can make them 65 00:05:27,900 --> 00:05:32,080 lie. And the point is they don't care about that because they said, well, in some future world 66 00:05:32,080 --> 00:05:36,900 where the attacker cares enough to target us, then we're winning. But until we see that, we 67 00:05:36,900 --> 00:05:42,060 don't care. But of course you're not going to see it because they're making you lie. So why 68 00:05:42,060 --> 00:05:47,800 would you see it? So we call this timing-based attestation. Attestation is just a fancy way of 69 00:05:47,800 --> 00:05:53,780 saying that you're providing some evidence about the state of something. You're attesting to the 70 00:05:54,100 --> 00:05:59,780 integrity of your code, for instance. And so this is based on academic work called Pioneer by 71 00:06:00,660 --> 00:06:06,640 Seshadri, et cetera. If there's any academics in the crowd, this is out of A.G. and Parag's group 72 00:06:06,640 --> 00:06:12,620 at CMU. And so the key point is we kind of consider our specialization area of research to 73 00:06:12,620 --> 00:06:18,160 take other people's research and make it more practical. So this was, Pioneer was good. It was 74 00:06:18,160 --> 00:06:23,960 for Linux. It was, it had some assumptions that we wanted to loosen so that we could get this 75 00:06:23,960 --> 00:06:30,700 to work in basically our corporate environment. And so we independently recreated this just to 76 00:06:30,700 --> 00:06:34,640 confirm that this academic work actually does what it says it does because you can't always 77 00:06:34,640 --> 00:06:40,040 believe that. And importantly, the source code is available. So, you know, as we're going 78 00:06:40,040 --> 00:06:44,220 through here and you're thinking to yourself, what if I do this, what if I do that, well, you 79 00:06:44,220 --> 00:06:48,840 can go actually do it and you can see if you can write the assembly more optimized than us and 80 00:06:49,340 --> 00:06:53,940 prove that you actually can compromise it. So with that, I want to cordially thank you for your 81 00:06:53,960 --> 00:07:00,020 time. It's great to start talking about the design. Okay. Thanks, everyone, for coming. Can 82 00:07:00,020 --> 00:07:05,860 you all hear me okay? Good? Okay. So you may be asking yourself why do we even want to do this? 83 00:07:06,000 --> 00:07:10,120 And just keep in mind the goal here is we want to build tamper-resistant software. If we're 84 00:07:10,120 --> 00:07:14,620 building some type of malware detection capability, like Zeno pointed out, the malware will 85 00:07:14,620 --> 00:07:21,220 eventually come and try to tamper with us. So we want to be able to detect that. So a very 86 00:07:21,220 --> 00:07:23,940 primitive case will be something like this. You might have seen this before. This is a very 87 00:07:23,960 --> 00:07:26,500 primitive case. You might see this in some current commercial software where they'll be doing a 88 00:07:26,500 --> 00:07:31,080 basic checksum of their own code. And then, you know, if the checksum is good, it will continue. 89 00:07:31,240 --> 00:07:34,580 And if it's bad, it will be some type of fail case. And often with malware, you'll also see 90 00:07:34,580 --> 00:07:39,820 like, you know, RDTSC command. And if it's not within expected time constraints between point A 91 00:07:39,820 --> 00:07:47,780 and point B in the code, it will go to a fail case where it's being debugged. So this is naive 92 00:07:47,780 --> 00:07:51,840 because obviously anyone that knows anything about X86 assembly can just come in and do something 93 00:07:51,840 --> 00:07:53,940 like this. You know about the call to this assembly. You know about the call to this 94 00:07:53,960 --> 00:07:58,840 self-check. And then you just hard code, you know, the expected correct self-check sum there, 95 00:07:58,940 --> 00:08:04,400 the correct hash. And then the code would have no idea it's been tampered with, right? So 96 00:08:04,400 --> 00:08:09,640 unfortunately at this point, most sort of commercial software out there kind of gives up. And 97 00:08:09,640 --> 00:08:15,300 they either just rely on, you know, something simple like this or they don't do it at all. And 98 00:08:15,300 --> 00:08:20,200 maybe to improve it, they'll just try to obfuscate the hell out of it. But they never really try to 99 00:08:20,200 --> 00:08:23,940 improve upon that method and make it more hard. And that's what we're trying to do here. So that's 100 00:08:23,960 --> 00:08:27,520 what we want to do. We want to make this style of self-attestation better and more resilient to 101 00:08:27,520 --> 00:08:33,820 attack. And so in order to do that, we have to fundamentally change our approach from what I just 102 00:08:33,820 --> 00:08:37,700 showed you. So first of all, we have to make our self-check, our hash that we're doing over our 103 00:08:37,700 --> 00:08:42,820 own code a function of a nonce, a random value sent from a verifier. That way the attacker can't 104 00:08:42,820 --> 00:08:46,380 just hard code the correct value, right? Because it's going to be different depending on the 105 00:08:46,380 --> 00:08:53,860 random value coming from the verifier. Another key point is with things like patch guard that are 106 00:08:53,960 --> 00:09:00,380 sort of trying to measure themselves and attest to their own integrity. The verifier also exists on 107 00:09:00,380 --> 00:09:04,120 that system. So with patch guard, you know, it's trying to verify itself and determine whether or 108 00:09:04,120 --> 00:09:08,960 not it's been compromised. And all that's happening on the compromised system. So the attacker, if 109 00:09:08,960 --> 00:09:12,480 they can compromise the system, they can just compromise the verification software and patch 110 00:09:12,480 --> 00:09:16,480 guard as well. And patch guard would have no idea that it's being tampered with. So we incorporate 111 00:09:16,480 --> 00:09:21,700 this trusted server that we assume is not compromised. And it's going to get the results of 112 00:09:23,960 --> 00:09:27,440 that self-check sum, send back to it from the client, and then, you know, in a secure environment, 113 00:09:27,580 --> 00:09:31,440 what we assume is not compromised, take the results of that self-check sum to try to make a 114 00:09:31,440 --> 00:09:36,160 determination about whether or not it thinks the software has been tampered with on the client 115 00:09:36,160 --> 00:09:43,620 side. So our framework, as opposed to what I showed you previously, looks a little bit more like 116 00:09:43,620 --> 00:09:49,140 this. Obviously it's not the real deal, but just a pseudo code here. And so we have our check 117 00:09:49,140 --> 00:09:53,900 sum and then it's going to be waiting for a request from the verifier, some type of server. It's 118 00:09:53,900 --> 00:09:58,360 going to get the nonce from that server, which point it knows, okay, the server wants me to 119 00:09:58,360 --> 00:10:03,940 attest to my integrity so it can know whether or not it should believe any measurements I sent it 120 00:10:03,940 --> 00:10:08,020 so it knows whether or not I've been tampered with. It's going to do a self-check sum based on 121 00:10:08,020 --> 00:10:16,920 that nonce and then obviously send the results of that back to the server. All right. So the 122 00:10:16,920 --> 00:10:20,420 first thing, like he said, the first thing the nonce gives us is just there's not a one-to-one 123 00:10:20,420 --> 00:10:23,880 mapping of, like, this is the correct self-check. So we're going to have to do a self-check 124 00:10:23,900 --> 00:10:28,480 sum. So now if we have a nonce that's 32 bits, we know that there has to be at least, you know, 125 00:10:28,520 --> 00:10:33,780 two to the 32 possible combinations. When we have a larger self-check sum that's not just, you know, 126 00:10:33,800 --> 00:10:38,620 a single 32-bit value when it's actually 60 words, that means you've got actually an attacker 127 00:10:38,620 --> 00:10:43,420 would have to pre-calculate 96 gigabytes worth of data and, like, keep that on the machine that 128 00:10:43,420 --> 00:10:47,300 he's compromising. If he does that, then he can, you know, definitely respond in the correct 129 00:10:47,300 --> 00:10:51,800 amount of time. He can just say, oh, let me look that up in my table. This input nonce equals 130 00:10:51,800 --> 00:10:53,800 that output check sum. Let me just send that along. 131 00:10:54,260 --> 00:10:59,300 But, you know, for our laptops and things like that, we don't have 96 gigs of memory on them. 132 00:10:59,420 --> 00:11:05,700 So we consider this a good enough initial thing for 32-bit systems. You know, maybe a big huge 133 00:11:05,700 --> 00:11:11,900 32-bit server wouldn't be. But then you go to more 64-bit systems. On the 64-bit systems, it's 134 00:11:11,900 --> 00:11:16,320 just completely infeasible that they're going to do a pre-calculation of all the possible inputs 135 00:11:16,320 --> 00:11:20,900 to outputs. So that's the first good thing you get by adding a nonce and making it so that every 136 00:11:20,900 --> 00:11:23,880 different self-check sum is there. So that's the first good thing you get by adding a nonce and 137 00:11:23,900 --> 00:11:29,340 making it so it's fresh and it's a function of a nonce. So now we want to talk about, you know, 138 00:11:29,340 --> 00:11:34,880 what is the actual data that we need to attest to in order to say that our code is untampered? 139 00:11:35,000 --> 00:11:40,800 Well, the first and most obvious thing is we have to read our code itself. We have to measure 140 00:11:40,800 --> 00:11:45,280 our code and somehow mix that into the self-check sum and then, you know, that will ‑‑ you 141 00:11:45,280 --> 00:11:49,600 can think of it like, you know, in the naive case, you do a CRC over your own code in order to 142 00:11:49,600 --> 00:11:53,880 say my code is good. Or you do a hash over it, et cetera. But, you know, it's not going to be 143 00:11:53,880 --> 00:11:58,060 good. We're doing, you know, a sort of special checksum that has some additional criteria that 144 00:11:58,060 --> 00:12:02,320 we'll talk about next. So the first thing is you need to read your own code. The second thing, 145 00:12:02,440 --> 00:12:06,540 sort of the second and third thing is that you want to say something about that the code 146 00:12:06,540 --> 00:12:10,900 that's reading your own code, the self‑checking code itself, you want to say something about 147 00:12:10,900 --> 00:12:15,620 it's in a range that you expect and everything sort of matches up. So first of all, you have 148 00:12:15,620 --> 00:12:20,000 the pointer that's pointing to yourself. You include that pointer because that says something 149 00:12:20,000 --> 00:12:23,500 about where in memory your code is actually reading itself. 150 00:12:23,880 --> 00:12:28,200 So where in memory is your code stored? And then you include the instruction pointer next 151 00:12:28,200 --> 00:12:32,140 because that says where in memory your code itself is executing. And those two things should 152 00:12:32,140 --> 00:12:36,340 kind of, you know, match up and be in the same memory range. Otherwise, you know, you 153 00:12:36,340 --> 00:12:41,820 could potentially have an attack. So now if we expand this a little more, we dive down into 154 00:12:41,820 --> 00:12:46,380 the self‑check and we say, okay, what do we need to incorporate? So now a self‑check, our 155 00:12:46,380 --> 00:12:49,880 pseudocode here would look like, you know, get the start of my code, get the end of my code, 156 00:12:49,920 --> 00:12:53,620 and now inside of a while loop, and this while loop is a very critical component of it, 157 00:12:53,880 --> 00:12:58,320 inside of my while loop, I'm going to loop through and I'm going to just somehow incorporate 158 00:12:58,980 --> 00:13:03,940 the nonce that I got in the start, the star DP, that's the dereference data pointer, that's my 159 00:13:03,940 --> 00:13:10,020 actual, you know, four bytes of code. The data pointer itself. I'm going to calculate the 160 00:13:10,020 --> 00:13:16,300 EIP using, you know, the typical assembly mechanism of just calling zero bytes ahead and 161 00:13:16,300 --> 00:13:21,040 then popping the return address off the stack which gives me, you know, my current EIP. And 162 00:13:21,040 --> 00:13:23,780 then going to mix that in as well. And then finally there's just this 163 00:13:23,880 --> 00:13:29,100 generic mix that we're talking about here and that is basically it's a rotate and that's 164 00:13:29,100 --> 00:13:32,600 because some of the previous academic work had found that, you know, if you don't ‑‑ it's 165 00:13:32,600 --> 00:13:36,660 some of the previous academic work said you can kind of think of this self‑check sum like a 166 00:13:36,660 --> 00:13:42,180 stream cipher and you want to add confusion and diffusion and so this mixing is the diffusion. 167 00:13:42,460 --> 00:13:47,160 You want to rotate the results so that if there's like just a change in one bit, it will 168 00:13:47,160 --> 00:13:52,800 eventually rotate through and affect all the bits. So there's some additional problems with 169 00:13:52,800 --> 00:13:53,860 even this. So ‑‑ 170 00:13:53,880 --> 00:13:59,420 Even this code right here, this pseudo‑code, there's a couple of problems that we have here. 171 00:14:00,000 --> 00:14:04,440 The first is that it's potentially parallelizable. We said, you know, think back to the very first 172 00:14:04,440 --> 00:14:08,500 thing we were talking about. We're trying to get code where when it lies to you, it lies to you in 173 00:14:08,500 --> 00:14:14,040 a suspicious way. The timing of it is different. And so the problem here is we want to get it to, 174 00:14:14,080 --> 00:14:17,780 you know, there's some fixed amount of time that this thing should take and you should never be 175 00:14:17,780 --> 00:14:22,160 able to go faster than that. Well, the problem is the code is potentially parallelizable. So 176 00:14:22,160 --> 00:14:23,860 that means an attacker could break the code. You know, it's not going to be able to go faster than that. 177 00:14:23,860 --> 00:14:28,680 If I'm just writing this code and running it on my CPU, an attacker who knows more than me can go, 178 00:14:28,800 --> 00:14:33,640 you know, parallelize it off on the GPU. Well, so you can actually get around that. That's one of 179 00:14:33,640 --> 00:14:38,140 the first things a lot of people think of is I'll go faster by parallelizing. You can get around 180 00:14:38,140 --> 00:14:42,960 that by computing the self‑check as what the original pioneer paper called a strongly ordered 181 00:14:42,960 --> 00:14:47,080 function. I haven't been able to find any reference to this in other works. I don't think this is 182 00:14:47,080 --> 00:14:53,360 the correct term. But strongly ordered function just means the order of operations matters for the 183 00:14:53,360 --> 00:14:58,460 output order. And that means you can't rearrange the order of operations. And so you can do the 184 00:14:58,460 --> 00:15:04,440 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 185 00:15:04,440 --> 00:15:08,480 with C and then you take that quantity and then you add it to D and so forth. If you're 186 00:15:09,180 --> 00:15:14,200 accumulating this building up this checksum, if you do it in that order as opposed to you take A 187 00:15:14,200 --> 00:15:18,760 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 188 00:15:18,760 --> 00:15:23,340 results together, with high probability the results are going to be different. And so by doing 189 00:15:23,360 --> 00:15:27,180 doing this, just making sure that when we incorporate things into the self checksum that 190 00:15:27,180 --> 00:15:31,180 it's this add XOR, add XOR, and you want to make sure you're always maintaining that, then 191 00:15:31,180 --> 00:15:37,100 we're successfully making it non-parallelizable. So that takes that off the table. Then the 192 00:15:37,100 --> 00:15:41,880 other problem is one of just optimization. So we said we want to make it so that our thing is 193 00:15:41,880 --> 00:15:47,380 the fastest possible implementation. We're running as quickly as possible so that if the 194 00:15:47,380 --> 00:15:52,840 attacker adds overhead, it makes it take longer and it's lying in a strange way. And so 195 00:15:52,840 --> 00:15:58,340 this is kind of a problem which you can't really get around. There's no formal way. The 196 00:15:58,340 --> 00:16:03,440 academic sort of got side tracked here with saying we're going to formally prove that this is 197 00:16:03,440 --> 00:16:09,580 the optimal Intel assembly and that's a very hard thing to model. So basically we did the same 198 00:16:09,580 --> 00:16:13,760 thing that the previous work did, which is you guess and test it and you say, all right, let 199 00:16:13,760 --> 00:16:18,100 me change this assembly instruction and let me reorder these two instructions. You just keep 200 00:16:18,100 --> 00:16:22,620 trying it until you think what you have is the fastest possible way to calculate this add 201 00:16:22,620 --> 00:16:22,820 XOR. So that's kind of the problem. So this is kind of a problem which you can't really get 202 00:16:22,820 --> 00:16:26,000 around. You're just going to have to add XOR, add XOR, sort of checksum over the data pointer, 203 00:16:26,200 --> 00:16:32,240 the data pointed to by the data pointer and the instruction pointer. So that would potentially 204 00:16:32,240 --> 00:16:40,060 this is what one attack would look like. Okay. With this new solve checksum in mind, an 205 00:16:40,060 --> 00:16:43,320 attack against it would look something like this. So we have the same sort of loop set up 206 00:16:43,320 --> 00:16:46,880 where we're iterating over our own code and incorporating these key components like the data 207 00:16:46,880 --> 00:16:52,780 pointer, star DP, the data to data pointer, the EIP and so forth. So if an attacker wanted to 208 00:16:52,820 --> 00:16:57,620 forged that checksum while still tampering with the code, you would basically have to 209 00:16:57,620 --> 00:17:02,880 keep track of where the data pointer is currently and if it's pointing to some of his code that's 210 00:17:03,460 --> 00:17:07,660 tampering like an inline hook or a software break point or something like that, instead 211 00:17:07,660 --> 00:17:13,180 of actually incorporating the data at star DP, he would want to incorporate the clean 212 00:17:13,180 --> 00:17:17,480 copy of those bytes. So instead of incorporating his inline hook, incorporate what was there 213 00:17:17,480 --> 00:17:23,720 previously before he had tampered with the code. And notice, while this isn't a lot, this 214 00:17:23,720 --> 00:17:31,260 sort of if branching in x86 would only amount to a few x86 assembly codes, if we were doing 215 00:17:31,260 --> 00:17:35,700 this loop over millions of times, like 2.5 millions of times, that would actually cause the 216 00:17:35,700 --> 00:17:42,240 attacker to have to execute 2.5, 5 million, 7.5 million extra instructions in his calculation 217 00:17:42,240 --> 00:17:47,160 of this checksum. And that would induce a noticeable time difference and that's actually 218 00:17:47,160 --> 00:17:47,460 the time difference between the two. And so that would actually cause the attacker to 219 00:17:48,100 --> 00:17:55,300 have to execute 2.5 million times. So under normal circumstances, this is what the self-checksum 220 00:17:55,300 --> 00:17:59,800 typically looks like. So on the left we have the server and what's going to happen is it's 221 00:17:59,800 --> 00:18:05,560 going to send a nonce to the client and the client is going to use that as the input, 222 00:18:05,720 --> 00:18:11,200 the seed to its self-check and then that self-check is going to go back to the server. And then 223 00:18:11,200 --> 00:18:17,100 notice the server is basically incorporating the total network round trip time that it took for the client to respond to 224 00:18:17,100 --> 00:18:22,820 that self-checksum. And so it's going to say, okay, your checksum is correct because I calculated this on 225 00:18:22,820 --> 00:18:28,340 my own side and I know this is what your code should look like when it's been hashed correctly. But 226 00:18:28,340 --> 00:18:34,760 also the time it took you to respond to my request was within our acceptable limits, so I actually 227 00:18:34,760 --> 00:18:42,520 believe you. And based on that determination, it would basically trust or not trust the results of 228 00:18:42,520 --> 00:18:46,720 this next measurement. The next measurement would be something like, you know, a measurement of N2S kernel, 229 00:18:47,100 --> 00:18:53,480 or your security software or something like that. So this is what the diagram would look like if 230 00:18:53,480 --> 00:18:57,540 we were actually attacking and tampering with the software. So it starts off the same where we send 231 00:18:57,540 --> 00:19:03,580 a nonce to the client and then the client uses the nonce as the input for its self-check and then 232 00:19:03,580 --> 00:19:08,180 the self-check goes back. In this case the self-check is correct because the attacker has, you 233 00:19:08,180 --> 00:19:12,760 know, forged the value. He's done that, you know, keeping track of where DP is and if it's pointing 234 00:19:12,760 --> 00:19:17,080 at bad, tampered with data, he's going to replace that with good data. And then we have the 235 00:19:17,100 --> 00:19:23,000 check sum. And so the check sum checks out. But then the server notices, okay, look, your network 236 00:19:23,000 --> 00:19:27,760 round trip time has increased somewhat. You can see that on the left side, the delta T is larger 237 00:19:27,760 --> 00:19:32,220 than expected. So, yeah, your check sum is correct, but I know that something is up because it took 238 00:19:32,220 --> 00:19:37,040 too long for you to respond to me. And so this measurement of your system that you also sent, the 239 00:19:37,040 --> 00:19:40,420 measurement of N2S kernel or whatever, I'm not going to believe it because I think you're being 240 00:19:40,420 --> 00:19:47,080 tampered with. Okay. In general, this is sort of an iterative process where we're going to be 241 00:19:47,100 --> 00:19:51,420 working on the check sum and then notice some problems with it and then we'd have to change the 242 00:19:51,420 --> 00:19:55,280 design based on what we discovered. And so another problem we noticed with this approach was 243 00:19:55,280 --> 00:20:00,080 that when we're incorporating the instruction pointer, it's the same at every iteration in the 244 00:20:00,080 --> 00:20:03,960 self-check sum. So instead of doing this goofy trick where you have to, you know, call ahead, 245 00:20:04,160 --> 00:20:09,000 then pop off the stack to get your current EIP and x86, the attacker could actually just hard 246 00:20:09,000 --> 00:20:15,340 code that instruction pointer. So notice in this case he's actually gained a few x86 247 00:20:15,340 --> 00:20:17,080 instructions that he does not have to execute. So, you know, we're going to be working on the 248 00:20:17,100 --> 00:20:23,180 execute. He's made the self-check sum smaller. And so he's gained some instructions by 249 00:20:23,860 --> 00:20:29,360 optimizing this instruction pointer being inserted into the check sum. So that would allow him to go 250 00:20:29,360 --> 00:20:33,780 over here and forge the data pointer and so he would be able to tamper with our code and have a 251 00:20:33,780 --> 00:20:40,000 net result of zero additional time into the calculation of the self-check sum. So with this in 252 00:20:40,000 --> 00:20:44,440 mind, we had to go and sort of redesign how we are going to actually calculate this check sum. 253 00:20:48,400 --> 00:20:52,720 So what we need to do is make it so that it's not a fixed instruction pointer which is 254 00:20:52,720 --> 00:20:57,980 always incorporated in the check sum. And so how this can be done and how it was actually done in 255 00:20:57,980 --> 00:21:03,600 some related work is you make it so that you break up your code into multiple blocks. Each 256 00:21:03,600 --> 00:21:07,020 independent block is still doing the same sort of thing that you just saw on the previous slide. 257 00:21:07,160 --> 00:21:11,840 It's incorporating the data pointer, start EIP, instruction pointer. But the key thing is that 258 00:21:11,840 --> 00:21:17,080 you pseudo randomly choose which location you're going to go to next. So basically what we're 259 00:21:17,100 --> 00:21:22,760 basically what this sort of diagram is trying to show, if you can see my mouse, is that when you 260 00:21:22,760 --> 00:21:28,560 start out at block one, you go down to the end and the first loop through, block one may choose to go 261 00:21:28,560 --> 00:21:33,500 to block two. Or sorry, go to block three. Then block three will get done and it will go 262 00:21:33,500 --> 00:21:37,460 somewhere else. But the second time you get through block one, it will pseudo randomly choose 263 00:21:37,460 --> 00:21:42,560 that it's going to go to block four. And so the key point here is the attacker can't hard code the 264 00:21:42,560 --> 00:21:47,080 location where you're going next because it's chosen differently each time. 265 00:21:47,100 --> 00:21:52,460 So to do that, we need to add a pseudo random number generator. We use the same one Pioneer did 266 00:21:52,860 --> 00:21:57,620 and it's basically you see it with your nonce. That's easy. You've already got some fresh seed 267 00:21:57,620 --> 00:22:02,220 for it for every single measurement. And then you just basically do it. This is nice and simple 268 00:22:02,220 --> 00:22:07,400 in assembly language. You basically take your current value times the current value squared 269 00:22:07,400 --> 00:22:12,580 or with five. And so this works as a pseudo random number where it will cycle through all the 270 00:22:12,580 --> 00:22:15,520 possible values before looping back to the one where it started. 271 00:22:16,240 --> 00:22:21,700 Then we can also do some things like making the data pointer a function of this pseudo random 272 00:22:22,220 --> 00:22:26,900 value that we now have available. So instead of doing a strict linear sweep over our entire 273 00:22:26,900 --> 00:22:31,300 memory, we can bounce around and we can go to different locations each time. And that 274 00:22:31,300 --> 00:22:35,260 potentially makes it so that the attacker can't say, well, I know that when you get to loop, 275 00:22:35,320 --> 00:22:40,240 you know, 4,086, you're going to hit my data that I compromised. You're going to start reading 276 00:22:40,240 --> 00:22:45,500 that. And so I'm just going to like, you know, pop in just in time at 4,086, maybe I'll 277 00:22:45,500 --> 00:22:50,340 use some other processor to like change this stuff just in time. He can no longer have an 278 00:22:50,340 --> 00:22:55,200 expectation that for any given nonce, he doesn't know when we're going to be reading any change 279 00:22:55,200 --> 00:23:00,860 that he potentially made to our own code. So this is the closest thing we're going to show to 280 00:23:00,860 --> 00:23:04,600 the real code. We'll show the real code next. But this is just again, this is still really just 281 00:23:04,600 --> 00:23:10,500 pseudo code. But this is almost real pseudo code. And so how it works is we've got eight 282 00:23:10,500 --> 00:23:15,480 macros, block zero, block one, block two, through block seven. Each of the macros that we're 283 00:23:15,500 --> 00:23:21,800 using does the same thing. They're basically going and now we're not having that while loop 284 00:23:21,800 --> 00:23:26,620 just as straight up regular C code like you're used to. We're saying, you know, there's going to 285 00:23:26,620 --> 00:23:31,280 be some loop counter that we're keeping track of as we go. As Corey already mentioned, we do 286 00:23:31,280 --> 00:23:35,640 two and a half million iterations through this loop. So we'll hit one of these blocks, you 287 00:23:35,640 --> 00:23:40,980 know, two and a half million times. And so if the attacker wants to compromise this, he has to, 288 00:23:41,040 --> 00:23:45,300 you know, modify things within this and make sure that he fixes up all the values and that 289 00:23:45,500 --> 00:23:49,480 adds instructions which when multiplied by two and a half million equals many instructions. 290 00:23:50,520 --> 00:23:55,220 So basically look at the loop counter. If we're done with looping, just jump to the end. Then, 291 00:23:55,340 --> 00:24:00,460 you know, in the real assembly language kind of thing, we already have like two forms of the 292 00:24:00,460 --> 00:24:04,800 instruction pointer. We have one of them just already sitting in the ECX register because that's 293 00:24:04,800 --> 00:24:08,620 what we use at the end of the block. And then we have one that got pushed onto the stack. So 294 00:24:08,620 --> 00:24:13,920 we've got like a target destination EIP, which is the start of a block, and we've got a source 295 00:24:13,920 --> 00:24:15,480 EIP, which is what gets pushed onto the stack. So we've got like a target destination EIP, which is 296 00:24:15,500 --> 00:24:20,040 what gets pushed onto the stack by a call instruction at the end of each block. And so we 297 00:24:20,040 --> 00:24:23,920 start mixing these things together and all we're doing is we're going to do an add XOR, add 298 00:24:23,920 --> 00:24:28,540 XOR with each of our values that we said we care about. Starting with the EIP and the next 299 00:24:28,540 --> 00:24:33,020 thing, add in the pseudorandom number, which we changed through each loop, add in the data 300 00:24:33,020 --> 00:24:37,240 pointer, the data pointed to by the data pointer, go ahead and update your pseudorandom number 301 00:24:37,240 --> 00:24:42,480 with that X equals X squared over five, and then update the data pointer so that we choose a 302 00:24:42,480 --> 00:24:45,480 new pseudorandom location with our own code. That's going to be the next step. So that's the 303 00:24:45,500 --> 00:24:50,720 next place that we're going to read ourselves. And then mix it all together with rotate. And 304 00:24:50,720 --> 00:24:54,960 then finally we're going to calculate the next location to jump to pseudorandomly. And so you 305 00:24:54,960 --> 00:25:01,980 can think of these blocks, they're all just code in an array in our own kernel module. And so 306 00:25:01,980 --> 00:25:06,720 you can think of it like an array of eight of the blocks of this assembly language. So we're 307 00:25:06,720 --> 00:25:10,700 going to start at the base of the array, block zero base, and then we need to pick the new 308 00:25:10,700 --> 00:25:15,480 index pseudorandomly. So we take the pseudorandom number, we OR, we EIP, and then we're going to 309 00:25:15,500 --> 00:25:21,500 end it with seven in order to get the bottom three bits, right? So that gives us potential eight 310 00:25:21,500 --> 00:25:26,440 possible values that we're going to index to in this array of code. And so that basically says 311 00:25:26,440 --> 00:25:31,660 take the size of each block plus this index, zero to seven, and then that's the next place we're 312 00:25:31,660 --> 00:25:36,500 going to go. Just calculate that all, put it in ECX, that's where we're going next. So you can 313 00:25:36,500 --> 00:25:43,600 read the real paper, you know, this has academic paper behind it, 16 pages of goodness and plenty 314 00:25:43,600 --> 00:25:45,480 of assembly. And then we're going to take the size of each block plus this index, zero to seven, and 315 00:25:45,500 --> 00:25:50,860 basically all of this stuff looks exactly like that sort of code I just showed. The only 316 00:25:50,860 --> 00:25:56,060 difference is we show the actual rotates here, and then there's some additional state that we 317 00:25:56,060 --> 00:25:59,900 want to keep about the system that we don't have time to go into. But there's additional stuff 318 00:25:59,900 --> 00:26:08,020 you want to do. Otherwise, there's additional attacks the attacker can do. Okay. So defense is 319 00:26:08,020 --> 00:26:13,240 boring. So let's talk about offense a little bit. So what would the attacker have to do if he 320 00:26:13,240 --> 00:26:15,480 actually wanted to try to break this system? Well, you know, we're going to try to break this system. 321 00:26:15,500 --> 00:26:21,040 Now, the original paper that we mentioned, the academic paper out of CMU, outlined four attacks, 322 00:26:21,260 --> 00:26:25,600 or I guess really three attacks that you can do against this style of a self-checksum. And so keep 323 00:26:25,600 --> 00:26:30,500 in mind that we're incorporating things like the data pointer, star DP, star DP, the program 324 00:26:30,500 --> 00:26:37,960 counter, into the self-checksum. So if the attacker wants to forge the checksum, he's going to 325 00:26:37,960 --> 00:26:42,680 have to, and be manipulating the code, he'll have to forge some subset of those components we're 326 00:26:42,680 --> 00:26:45,480 mixing in, star DP, DP, or the instruction pointer. So if the attacker wants to forge the checksum, he's 327 00:26:45,500 --> 00:26:48,960 going to have to do that. Notice if he wasn't forging any of those values, if DP was the same, if 328 00:26:48,960 --> 00:26:54,040 EIP was the same, if star DP was the same, he would just be running our untampered code and we would 329 00:26:54,040 --> 00:26:58,420 be winning already. So he's going to have to forge some of those values. So in the naive case, the 330 00:26:58,420 --> 00:27:04,060 worst case for the attacker is basically where he is forging most of those, the more components he 331 00:27:04,060 --> 00:27:08,500 has to forge, the worse for him. So in the worst case you can see on the bottom right is when he's 332 00:27:08,500 --> 00:27:15,400 forging the data pointer and the program counter. So how this attack typically works is the 333 00:27:15,500 --> 00:27:21,420 attacker would create a clean copy of our self checksum code, what we're measuring over, and then 334 00:27:21,420 --> 00:27:27,120 he would point DP at that code and he would have some custom, his own version of the self checksum 335 00:27:27,120 --> 00:27:32,000 that is going to point DP at that code. And then notice if DP is pointing at that clean copy, star 336 00:27:32,000 --> 00:27:38,100 DP will already be good, since it's good and untampered. But he'll have to be, you know, DP is 337 00:27:38,100 --> 00:27:44,500 having to be forged because it's not pointing at the real copy of our code. It's just a clean copy. 338 00:27:44,580 --> 00:27:45,480 It's not where our code actually is. So it's going to be a clean copy of our self checksum code. So 339 00:27:45,500 --> 00:27:49,740 that's the worst case for the attacker. And then you have to forge the program counter, the 340 00:27:49,740 --> 00:27:55,160 instruction pointer, because he's not executing the real authentic self checksum. He's executing 341 00:27:55,160 --> 00:28:00,440 his own custom version that is forging these values. So that's the worst case for the attacker 342 00:28:00,440 --> 00:28:05,160 is having to forge all of those components. The best attack we could come up with was in the 343 00:28:05,160 --> 00:28:10,940 bottom left where the attacker does not have to forge star DP because he's using a clean copy, 344 00:28:11,040 --> 00:28:15,480 like I outlined before. And also he does not have to forge DP. So he's using a clean copy. And 345 00:28:15,480 --> 00:28:21,580 the reason being we're running this on a Windows environment as a Windows kernel module. And 346 00:28:22,160 --> 00:28:25,840 even in Windows XP that doesn't have ASLR, we have something that we have to deal with called 347 00:28:25,840 --> 00:28:31,800 foe. We call it foe ASLR. And that's because the Windows kernel module loader doesn't respect 348 00:28:31,800 --> 00:28:37,320 the base address that you put into the kernel driver. So you could tell the kernel, hey, I want 349 00:28:37,320 --> 00:28:42,940 this driver loaded at address OX deadbeath. But the kernel is going to totally disregard that. So 350 00:28:43,480 --> 00:28:45,460 we actually rely on the, you know, the, you know, the, you know, the, you know, the, you know, the 351 00:28:45,460 --> 00:28:51,200 the self checksum code to report back where it's located in memory. And this introduces an attack 352 00:28:51,200 --> 00:28:56,020 into our system where the attacker can also lie and say, hey, guess what, you're actually located 353 00:28:56,020 --> 00:29:00,940 where your clean copy is. And this allows them to not have to forge DP. But they're still 354 00:29:00,940 --> 00:29:04,100 having to forge the program counter because they're running their own custom version of the 355 00:29:04,100 --> 00:29:07,840 self checksum code. Hopefully this will be a little more clear when I show you the diagram 356 00:29:07,840 --> 00:29:13,440 next. Okay. So once again, this is what the self checksum looks like. On the left we have the 357 00:29:13,440 --> 00:29:15,440 server, where the verifier and on the right is the client. And on the right is the server. And on the 358 00:29:15,440 --> 00:29:20,160 client. So the measurement request comes in to the client, including the nonce for the 359 00:29:20,160 --> 00:29:25,340 self-check sum. We have this main switch case that's receiving all these packets and it 360 00:29:25,340 --> 00:29:28,740 says, okay, I've got a self-check sum request. Let's go ahead and do that. Here's my nonce. 361 00:29:29,600 --> 00:29:33,820 The self-check sum occurs, goes back to the server. The server is like, okay, everything 362 00:29:33,820 --> 00:29:37,840 is all good. Your self-check sum is good and it took the expected amount of time, so I 363 00:29:37,840 --> 00:29:43,840 believe you. And then obviously the whole reason we want to do this is because we can 364 00:29:43,840 --> 00:29:47,300 measure other important parts of the system, like the kernel, and also believe those 365 00:29:47,300 --> 00:29:51,160 measurements. So the system is also going to do a measurement of NTOS kernel and send back 366 00:29:51,160 --> 00:29:55,360 to the server and the server says, okay, NTOS kernel looks good and I believe what you're 367 00:29:55,360 --> 00:29:59,440 telling me about it because your self-check sum was good as well. All right, now let's 368 00:29:59,440 --> 00:30:05,080 switch back to attacker mode. This is what would happen. Notice the main thing the attacker 369 00:30:05,080 --> 00:30:09,640 is concerned with, again, is corrupting this general system measurement. So he wants to 370 00:30:09,640 --> 00:30:13,340 install hooks into NTOS kernel, things like kernel loggers, and that's where keyboard 371 00:30:13,340 --> 00:30:13,820 loggers are. So he wants to install hooks into NTOS kernel, things like kernel loggers, and 372 00:30:13,820 --> 00:30:18,920 that sort of thing, and have them be undetected by our measurement system. So that is what 373 00:30:18,920 --> 00:30:25,460 he is interested in protecting and not have show up in the measurement values. Okay. And 374 00:30:25,460 --> 00:30:30,040 so to pull this off, first the attacker installs an inline hook at the beginning of our self-check 375 00:30:30,040 --> 00:30:36,440 sum. That way he can gain control of EIP. He has this custom version of the self-check 376 00:30:36,440 --> 00:30:40,520 sum that is going to forge the self-check sum value, even though the original code has 377 00:30:40,520 --> 00:30:43,800 been modified. He still wants to produce the correct self-check sum. So he's going to 378 00:30:43,800 --> 00:30:50,700 do that. The measurement request comes in from the server. We naturally call the self-check 379 00:30:50,700 --> 00:30:55,000 sum code, but look here, we have the inline hook, so the attacker gains control of EIP. He is 380 00:30:55,000 --> 00:31:01,180 now running his custom self-check sum code. Over on the right we have the clean copy of the 381 00:31:01,180 --> 00:31:07,420 kernel module, the unadulterated copy, not tampered with. The attacker points DP at this clean 382 00:31:07,420 --> 00:31:13,540 copy. And he also lies, notice on the response back to the server, he's saying, hey, guess what, my base 383 00:31:13,540 --> 00:31:19,800 address is actually this is allowing him to not have to forge the data pointer. Because we don't 384 00:31:19,800 --> 00:31:24,640 know on the server side where our code should actually be located in kernel memory because of 385 00:31:24,640 --> 00:31:33,160 that FOBASLR. So then the attacker wants to execute his corrupted system measurement call. 386 00:31:33,320 --> 00:31:38,260 That way he can lie about what NTOS kernel actually contains. That goes back to the server. 387 00:31:38,440 --> 00:31:43,480 The server says, okay, NTOS kernel looks good. The self-check sum matches up with what I calculated. 388 00:31:43,540 --> 00:31:48,020 on my own side but you took too long to do this so I don't really believe you so we would flag 389 00:31:48,020 --> 00:31:54,640 that as something that needs investigation. All right. So that was the design and 390 00:31:54,640 --> 00:31:59,400 justification kind of thing in a nutshell and now we want to say does it actually work. So we 391 00:31:59,400 --> 00:32:05,020 ran experiments on our actual corporate intranet and we're going to show you data for two types 392 00:32:05,020 --> 00:32:10,020 of experiments. The first one is we wanted to see like over the maximum hop count that we can 393 00:32:10,020 --> 00:32:16,660 find at our campus, you know, does this attack still detectable. You know, what about network 394 00:32:16,660 --> 00:32:21,260 jitter and things like that, is there too much noise in the network that we can really see this 395 00:32:21,260 --> 00:32:26,320 attack. And so that's the first thing, does it work over the maximum hop count? And the second 396 00:32:26,320 --> 00:32:31,840 thing is, does the same, you know, is there a single bound that we can set to say this is the 397 00:32:31,840 --> 00:32:38,160 good self-check time and can we use that same bounding at different locations on our network. 398 00:32:38,280 --> 00:32:40,000 So we're going to take two hosts, we're going to take the same network and we're going to 399 00:32:40,020 --> 00:32:45,040 put them at the ten links and physically move them to eight links away and physically move 400 00:32:45,040 --> 00:32:52,500 them to three links away and measure them again. So these were desktop systems. So here's 401 00:32:52,500 --> 00:32:59,500 some raw data. So we had 31 different hosts over in a lab that's used for our training. 402 00:32:59,940 --> 00:33:05,880 And so 31 hosts, you can see that basically the first thing here is that all 31 hosts 403 00:33:05,880 --> 00:33:13,540 basically behave the same way at the same time. So when we have the no attack present, all 31 404 00:33:13,540 --> 00:33:19,020 hosts basically take about 111 milliseconds to do this round trip time. So we send a request from 405 00:33:19,020 --> 00:33:24,180 our server, they're ten links away, they calculate the self check sum, they send it back in 406 00:33:24,180 --> 00:33:29,300 111 milliseconds. When the attacker is there, so we have the ability to turn on our reference 407 00:33:29,300 --> 00:33:34,280 attacker, just like toggle it on with a request. When the attacker is there, clearly the 408 00:33:34,280 --> 00:33:35,860 attack is a much different thing. So when the attacker is there, the attack is a much 409 00:33:45,680 --> 00:34:05,600 different thing. So when the attacker is there, the attack is a much different thing. So when 410 00:34:05,600 --> 00:34:05,860 the attacker is there 411 00:34:05,880 --> 00:34:12,240 hacker, it's always going to take him 1.7% longer in order to do this. So if instead of doing 412 00:34:12,240 --> 00:34:19,260 2.5 million iterations, we do 25 million iterations, then instead of taking an extra 2 413 00:34:19,260 --> 00:34:24,100 milliseconds, it's going to take an extra 20 milliseconds. So you can always increase that, 414 00:34:24,160 --> 00:34:30,060 but it's at the cost of this thing taking more time. But you see a graph like this and the 415 00:34:30,060 --> 00:34:34,680 first thing your eyes are drawn to are the outliers and you say, what is that? What does 416 00:34:34,680 --> 00:34:39,140 that say about your results? And so first of all, you say when there's no attack present, it 417 00:34:39,140 --> 00:34:45,020 actually sometimes goes faster than the quote baseline correct good thing. And so we think 418 00:34:45,020 --> 00:34:50,300 that's just initial evidence that we haven't sufficiently optimized this or that we're not 419 00:34:50,300 --> 00:34:54,980 potentially taking some caching effects and things like that into consideration. But the 420 00:34:54,980 --> 00:34:59,180 important thing is that first of all, the amount of magnitude that this pulls a good guy down in 421 00:34:59,180 --> 00:35:04,660 these best case runs is not enough to pull an attacker down into the good area. And so 422 00:35:04,680 --> 00:35:06,940 we're going to be looking at this as a way to see if an attacker could somehow take advantage of 423 00:35:06,940 --> 00:35:11,600 this. And the second thing is that, like I said, this is 31 hosts and this is actually just 424 00:35:11,600 --> 00:35:19,840 one off measurements here. It's basically, you know, this one host, this one time somehow got 425 00:35:19,840 --> 00:35:24,140 lower. And so we basically think this is just, like I said, we're not necessarily taking all 426 00:35:24,140 --> 00:35:29,360 potential caching effects and stuff like that into account. And so maybe in some cases it's just 427 00:35:29,360 --> 00:35:33,900 getting lucky and it's hitting, you know, the perfect, all the cache and everything is just lined 428 00:35:34,680 --> 00:35:38,440 up and everything runs a little bit faster. And I should say we validated these network 429 00:35:38,440 --> 00:35:44,540 round trip times against RDTSC self-reported self amount of time, which we don't, we wouldn't use 430 00:35:44,540 --> 00:35:48,900 in real system. But for experiments we confirmed that these are not like network abnormalities. 431 00:35:49,040 --> 00:35:55,200 These are actually on the host. It definitely took less time. And so the next thing you're going 432 00:35:55,200 --> 00:35:59,560 to ask is what about the things where in the attack case it's getting pulled up. So you see 433 00:35:59,560 --> 00:36:04,520 there's no attacker data where he gets, like, pulled down accidentally. There is attacker data 434 00:36:04,680 --> 00:36:08,360 where he gets pulled up. We think that's, again, the same thing. We optimized the thing as best 435 00:36:08,360 --> 00:36:12,960 we could through guess and test. And we know that when the attacker is adding in additional 436 00:36:12,960 --> 00:36:17,560 instructions, clearly it adds overhead. But then he's maybe having more opportunities to get 437 00:36:17,560 --> 00:36:25,160 unlucky on the caching and side effect type things as well. So the next thing was just to say 438 00:36:25,160 --> 00:36:29,580 something about, you know, is there a single value that we can say in baseline, like, this is 439 00:36:29,580 --> 00:36:34,660 the correct time that it should take for, you know, core two duo running at three gigabit per 440 00:36:34,660 --> 00:36:39,700 hertz, you know, this particular revision of the hardware. And so the answer is, yes, there is 441 00:36:39,700 --> 00:36:43,980 some upper and lower bound we can set. But, of course, as you would expect, the more network 442 00:36:43,980 --> 00:36:48,600 hardware you go through, the more potential there is to pull up the amount of time that is the 443 00:36:48,600 --> 00:36:53,020 quote good time. And so all this is showing basically is that when you're one link, when you're 444 00:36:53,020 --> 00:36:59,520 connected through a crossover cable, your measurements are down there in the, you know, 110.25 445 00:37:00,000 --> 00:37:04,640 range. And when you're over ten links, you're up closer to the, you know, you know, the 446 00:37:04,660 --> 00:37:12,480 110.75 range, things like that. So this is saying we can have ‑‑ we do have a wider range in 447 00:37:12,480 --> 00:37:18,100 this sort of case. But the key point is we can use a single baseline and it's still sufficiently 448 00:37:18,760 --> 00:37:23,880 distinguishable from the attack traffic as you can see at the top of the graph. And so that 449 00:37:23,880 --> 00:37:28,800 worked for us, network time within our intranet. But obviously when you have jitter and things 450 00:37:28,800 --> 00:37:32,120 like that, we don't expect this to work over the Internet. We don't expect this to work over 451 00:37:32,120 --> 00:37:34,640 wireless. So Corey is going to talk about what we can do. 452 00:37:34,660 --> 00:37:40,680 Okay. So like Zeno pointed out, this scheme obviously wouldn't work over like a 453 00:37:40,680 --> 00:37:45,160 VPN over the Internet because of the large amount of network jitter. Lucky for us, these 454 00:37:45,160 --> 00:37:50,160 academics proposed a similar protocol that used the trusted platform module as sort of a 455 00:37:50,160 --> 00:37:55,100 trusted stopwatch is the best way to think of it. And so that way you can push the timing to 456 00:37:55,100 --> 00:38:01,480 the client side. And you can actually trust that timing because the TPM is signing the times. 457 00:38:01,800 --> 00:38:04,480 Unless you're Chris Tarnowski and have a fib or something. 458 00:38:04,660 --> 00:38:10,100 Hopefully you can't forge your own time values. So the way the system works is it's very much 459 00:38:10,100 --> 00:38:17,260 the same. It comes in to the client. The client before calculates a self check sum, it does a tick 460 00:38:17,260 --> 00:38:22,720 stamp which is asking the TPM okay give me a signed current time value. Then it incorporates 461 00:38:23,420 --> 00:38:29,500 bits from that signature as its nonce just to avoid some possible attacks there. And then it 462 00:38:29,500 --> 00:38:34,060 calculates a self-check sum with that as a nonce and when it's done it does one more. Asks the TPM, 463 00:38:34,660 --> 00:38:38,600 sign me the time one more time and that way we have the signed time for the beginning 464 00:38:38,600 --> 00:38:42,920 of the checksum and the end and the server can obviously just verify the signatures on 465 00:38:42,920 --> 00:38:46,880 the server side to make sure the times haven't been tampered with and then take the delta 466 00:38:46,880 --> 00:38:50,760 the difference between the two times and say okay this is how long your checksum actually 467 00:38:50,760 --> 00:38:55,880 took. And so this is great in theory because it would all the timing is on the client side 468 00:38:55,880 --> 00:39:01,040 we don't have to worry about network jitter at all. Unfortunately things with the TPM 469 00:39:01,040 --> 00:39:06,660 if you've ever worked with TPM are kind of crazy and don't work very well. So let's talk 470 00:39:06,660 --> 00:39:11,000 about some of those results. Alright so here's that TPM implementation on the single host 471 00:39:11,000 --> 00:39:15,140 and you can see it's much like a diagram I showed you before. The attack is installed 472 00:39:15,140 --> 00:39:18,980 in the middle obviously and we have a very distinguishable attack is installed attack 473 00:39:18,980 --> 00:39:25,440 is not installed so they can detect that. Notice down here on the right the median goes 474 00:39:25,440 --> 00:39:29,480 down after the attack is installed and we really have no idea why that's happening 475 00:39:29,480 --> 00:39:30,820 because there's a lot of 476 00:39:30,820 --> 00:39:30,960 mistakes. 477 00:39:36,140 --> 00:39:44,600 Let's talk about let's look at this diagram. So this is a 32 host running a self checksum 478 00:39:44,600 --> 00:39:49,320 protocol with the TPM as well and notice they're all exhibiting this okay the time 479 00:39:49,320 --> 00:39:52,860 goes up when the attack is installed but also notice that all of their baselines are 480 00:39:52,860 --> 00:39:58,100 completely different, right? So these were all identical systems, identical CPUs, identical 481 00:39:58,740 --> 00:40:00,280 trusted platform modules and everything. 482 00:40:00,280 --> 00:40:06,740 But what we discovered was that each TPM exhibits different timing characteristics which is 483 00:40:06,740 --> 00:40:11,500 kind of bizarre. And even weirder for some of you people that do side channel attacks is 484 00:40:11,500 --> 00:40:16,700 that the TPM will actually each TPM key will exhibit different timing characteristics. 485 00:40:16,920 --> 00:40:20,760 So anyone that's into side channel attacks that's something you should investigate. And you 486 00:40:20,760 --> 00:40:25,700 can also see there's this one host up here, you know the crazy blue line towards the top and 487 00:40:25,700 --> 00:40:29,700 we really have no idea what the hell was going on with that TPM. It was just totally broken or 488 00:40:29,700 --> 00:40:29,920 something. 489 00:40:34,000 --> 00:40:38,800 We think we actually broke the TPM from overuse. We were using that specific system for 490 00:40:38,800 --> 00:40:43,680 previous experiments where we were just like hammering it with a bunch of TPM tests. So we 491 00:40:43,680 --> 00:40:50,620 somehow broke it. All right. So at this point this is where most academics would claim success 492 00:40:50,620 --> 00:40:56,200 and move on. You say I have proven that I can detect, you know, I can detect when you're 493 00:40:56,200 --> 00:40:59,900 tampering with my software. I can detect it over my intranet and I can detect when you're 494 00:40:59,900 --> 00:41:02,240 tampering with your computer. If I want to detect it, you know, using this TPM mechanism, yes, 495 00:41:02,240 --> 00:41:06,660 with the TPMs I have to baseline each system individually, but you already have to go around 496 00:41:06,660 --> 00:41:11,880 to every TPM anyways to install keys or to tell it to generate keys, so when you're 497 00:41:11,880 --> 00:41:18,280 generating the keys you can potentially, you know, do a timing baseline anyways. But when we 498 00:41:18,280 --> 00:41:21,520 were doing this, you know, we were concerned with, you know, how can we actually get around our 499 00:41:21,520 --> 00:41:28,760 own system? And so what we found is that the ‑‑ what we've been doing here is we've been 500 00:41:28,760 --> 00:41:32,820 trying to channel the attacker to this very narrow place. We want to force him, if you 501 00:41:32,820 --> 00:41:36,220 want to hook the kernel, you've got to hook the security software and then you've got to 502 00:41:36,220 --> 00:41:40,440 hook us and then you've got to hook our self-check, but aha, it's a trap, the self-check will 503 00:41:40,440 --> 00:41:44,620 actually behave differently once you hook it. Well, it turns out that the attacker doesn't 504 00:41:44,620 --> 00:41:49,220 have to hook any of that or he can change the way he's hooking in order to get around 505 00:41:49,220 --> 00:41:54,080 us. And you can do this with talk to attack, time of check, time of use. So when we're 506 00:41:54,080 --> 00:41:58,400 checking the system, it will look different from when the system is running normally. So 507 00:41:58,400 --> 00:42:02,560 there's three conditions that have to be met for a talk to attack. And if we can break any of 508 00:42:02,560 --> 00:42:07,480 them as defenders, we can break the whole talk to attack and, you know, different systems have 509 00:42:07,480 --> 00:42:11,880 different assumptions which break some of these. But in our case where we're assuming we're at 510 00:42:11,880 --> 00:42:15,920 the exact same level as the attacker and we're in the Windows kernel where there's a lot of 511 00:42:15,920 --> 00:42:20,520 flexibility, this can be pretty difficult. So the conditions are the attacker has to know 512 00:42:20,520 --> 00:42:24,460 when you're about to measure something. And so if you're at the same privilege level, that's 513 00:42:24,460 --> 00:42:27,820 pretty easy, right? They can always know when you're about to start a measurement by just 514 00:42:27,820 --> 00:42:28,380 putting a set of numbers on the screen. So if you're at the same privilege level, that's 515 00:42:28,380 --> 00:42:32,200 pretty easy. They can put a hook into your code, right? They're always going to bounce out to 516 00:42:32,780 --> 00:42:37,460 their code before you ever even have a chance to measure your own code, right? Way up in the 517 00:42:37,460 --> 00:42:41,740 prologue, way up in the code that listens for network packets. So the attacker has to know 518 00:42:41,740 --> 00:42:45,740 when you're about to start. They have to be able to move themselves to some unmeasured 519 00:42:45,740 --> 00:42:50,880 location or they have to remove their existing hooks for the duration of the measurement. So 520 00:42:50,880 --> 00:42:55,280 they basically have to clean things up so that at the time that you check it, it looks clean. 521 00:42:55,680 --> 00:42:57,520 And they have to be somewhere that's not measured. 522 00:42:58,040 --> 00:43:02,540 And then the third thing is that they need to reinstall as fast as possible after the check is 523 00:43:02,540 --> 00:43:06,700 done. Because if they don't reinstall right when you're done measuring, then the system is 524 00:43:06,700 --> 00:43:10,800 running for some period of time where they're not in control. And that's kind of a problem 525 00:43:10,800 --> 00:43:15,480 that, you know, leaves them vulnerable to things, to other just regular detection mechanisms. 526 00:43:16,560 --> 00:43:20,080 So, you know, this is what it would look like in our first sort of picture. We left off with, 527 00:43:20,200 --> 00:43:23,740 you know, the attacker has fallen into our trap. They've gone after the self-checking 528 00:43:23,740 --> 00:43:27,500 software. But, you know, if he's being clever about this, he actually doesn't have the ability to 529 00:43:27,500 --> 00:43:31,720 do that. What he's going to do is he's going to say, you're about to do a self-check. You're 530 00:43:31,720 --> 00:43:35,680 about to do, you know, a measurement of NQS kernel. Or you're about to do a measurement of, 531 00:43:35,720 --> 00:43:39,640 you know, McAfee. I see you're about to do a measurement. I'm just going to go ahead and 532 00:43:39,640 --> 00:43:44,920 erase all of the things that you're about to measure. Everywhere that you would detect me, I 533 00:43:44,920 --> 00:43:49,440 will erase that. And only that. He can still have hooks elsewhere in the system. He just has to 534 00:43:49,440 --> 00:43:54,320 target it to the specific measurements you're doing right now. And so in that case, you do a 535 00:43:54,320 --> 00:43:57,480 measurement and there's no changes detected. Once you're done with that, you can go back to the 536 00:43:57,500 --> 00:44:02,360 server. Once you're done, he reinstalls himself immediately at the end. All right. So we 537 00:44:02,360 --> 00:44:07,860 really found that there's actually a bunch of academic work that is talk-to attacks, but it 538 00:44:07,860 --> 00:44:11,520 doesn't, like, claim it explicitly. And so that's why we kind of thought it was important to 539 00:44:11,520 --> 00:44:16,580 pull out this because you look at things like academic and non-academic work as well. I mean, 540 00:44:16,600 --> 00:44:21,300 if you're thinking in a talk-to sort of sense of things, you can look at, like, where did 541 00:44:21,300 --> 00:44:25,280 Joanna Rakowska leave off the, you know, virtualization-based rootkits and things like 542 00:44:25,280 --> 00:44:27,480 that. She left it off with, okay, yeah, you can do this. You can do this. You can do this. You 543 00:44:27,500 --> 00:44:32,720 guys can go time me in order to detect that I've got a malicious hypervisor. But I'm going to 544 00:44:32,720 --> 00:44:37,120 watch for you timing me. And if you do that, I'm going to uninstall myself, let you do the 545 00:44:37,120 --> 00:44:41,200 timing check, and then once you're done, I'm going to reinstall myself. And so she called 546 00:44:41,200 --> 00:44:46,940 that blue chicken, but it's really a talk-to attack. And so this is sort of a problem for any 547 00:44:46,940 --> 00:44:50,800 sort of measurement system. There's the potential here, and you have to design with it 548 00:44:50,800 --> 00:44:54,900 explicitly in mind. And so we don't think that most things are doing that, and we certainly 549 00:44:54,900 --> 00:44:57,480 didn't do that. And so now we're going back and trying to figure out how to do that. And so 550 00:44:57,500 --> 00:45:00,600 we're going back and trying to figure out how we can deal with talk-to attacks to break 551 00:45:00,600 --> 00:45:06,400 things. And so most economic work will just say, like, you know, I'm in the kernel. You're in 552 00:45:06,400 --> 00:45:10,400 user space. You can't see when I'm about to do a measurement. I'm in a hypervisor. You're in 553 00:45:10,400 --> 00:45:14,560 kernel space. You can't see when I'm about to do a measurement. I'm in SMM. You're in a 554 00:45:14,560 --> 00:45:18,660 hypervisor. You can't see when I'm about to do measurement. You can break it by violating the 555 00:45:18,660 --> 00:45:22,740 assumption that they don't know, or you can break it by saying there's no unmeasured location. 556 00:45:23,060 --> 00:45:26,840 I'm just going to measure everything. And that will work on, you know, some limited systems, 557 00:45:26,840 --> 00:45:31,500 embedded systems, things like that. But for desktop systems, we're not going to measure all 558 00:45:31,500 --> 00:45:36,880 four gigs of memory or, you know, if it's a 64‑bit system, however much memory. We're not 559 00:45:36,880 --> 00:45:40,340 going to do that every single time, so that's not reasonable. So we're sort of focusing more 560 00:45:40,340 --> 00:45:44,100 on the, you know, preventing them from reinstalling themselves deterministically, having 561 00:45:44,100 --> 00:45:49,700 some window where they've let go of the system and taking advantage of that. The other just 562 00:45:49,700 --> 00:45:54,660 minor point is that we've said this talk is about code integrity, protection, detection. 563 00:45:55,880 --> 00:45:56,820 Control flow integrity is something that we've been talking about for a long time. We've been 564 00:45:56,840 --> 00:45:59,680 talking about code integrity, just meaning, you know, if there's other ways besides hacking the 565 00:45:59,680 --> 00:46:03,580 code that they can get ‑‑ they can start running their stuff, the most common one being 566 00:46:03,580 --> 00:46:07,540 changing function pointers and things like that. Those are kind of enablers for talk‑to‑attacks. 567 00:46:07,620 --> 00:46:12,760 That's why they can see that you're about to start doing things. All right. So in conclusion, 568 00:46:13,060 --> 00:46:17,260 what we've basically shown in this work is that, you know, we have a more practical system, 569 00:46:17,400 --> 00:46:24,180 runs on Windows XP, runs on Windows 7. We have a system where we can detect if you're 570 00:46:24,180 --> 00:46:26,820 modifying our self‑checking code. You can detect it on Windows 10, you can detect it on Windows 571 00:46:26,820 --> 00:46:30,360 11, you can detect it on the intranet based on the round trip time. And we can detect it, you 572 00:46:30,360 --> 00:46:35,540 know, sort of arbitrarily based on TPM, trusted stopwatch, if we baseline the time for your 573 00:46:35,540 --> 00:46:40,280 specific system. And we know that the attacker can get around it with talk‑to‑attacks, but the 574 00:46:40,280 --> 00:46:45,820 key point is, we ‑‑ he's doing a talk‑to‑attack, our code is unmodified. So in the 575 00:46:45,820 --> 00:46:50,780 academic sense, we've won, but, you know, we're still concerned about this. So we still want to 576 00:46:50,780 --> 00:46:56,800 find ways to mitigate talk‑to‑attacks. So thank you for coming. You can go check out the code, 577 00:46:56,800 --> 00:47:02,440 on Google code page. And we've actually got videos, rather than read‑me files, we've got 578 00:47:02,440 --> 00:47:07,200 videos that show you exactly what you should do in order to install our software and validate our 579 00:47:07,200 --> 00:47:11,560 results, run it on your own machines, tinker around with the assembly code, see if you can 580 00:47:11,560 --> 00:47:17,020 make it go faster than we can. And so speaking of videos, the last thing we're going to pimp here 581 00:47:17,020 --> 00:47:23,940 is open security training.info. That's a site that we contribute to on our free time, where we 582 00:47:23,940 --> 00:47:26,780 put up class material that we use for monitoring our software. So if you're interested in 583 00:47:26,780 --> 00:47:32,540 MITRE internal training, and then we put up the materials itself and videos. So I've got eight 584 00:47:32,540 --> 00:47:37,920 days' worth of material on things like X86 assembly, architecture, virtual memory type things, 585 00:47:38,260 --> 00:47:45,760 PE binary format, root kits. Corey's got two days currently up on exploits, intro exploits, 586 00:47:45,780 --> 00:47:50,360 but he's got three more days of videos that we're going to be editing after this. So we've got 587 00:47:50,360 --> 00:47:55,120 things on that. We've got a TPM class in the works, which will sort of make TPM not a black 588 00:47:55,120 --> 00:47:56,760 magic voodoo DRM box. So we're going to be editing that. So we're going to be editing that. So we've 589 00:47:56,760 --> 00:47:57,200 got a TPM class in the works, which will sort of make TPM not a black magic voodoo DRM box. It's 590 00:47:57,200 --> 00:48:02,120 just another sort of interesting chip that you should really try to play around with. And we've 591 00:48:02,120 --> 00:48:06,160 got things like virtualization, reverse engineering, and so forth. So check that site out, 592 00:48:06,240 --> 00:48:09,400 and come visit us in the Q&A session. Thanks for your time.