1 00:00:00,000 --> 00:00:02,220 Do we have a mic? You guys can hear me. Excellent. 2 00:00:02,660 --> 00:00:04,960 Well, I'm going to go ahead and get started, if that's okay with everybody. 3 00:00:05,100 --> 00:00:07,260 I imagine we'll have a few people trickling in in the meantime, 4 00:00:07,520 --> 00:00:10,080 but in the interest of time, I'll just dive into it. 5 00:00:10,260 --> 00:00:14,280 I imagine we'll have a few minutes left for questions at the end of the talk here, 6 00:00:14,420 --> 00:00:16,880 but then they also have, you guys probably all know already, 7 00:00:17,320 --> 00:00:18,960 question and answer room set up aside, 8 00:00:19,080 --> 00:00:22,400 so I'm going to hustle off when the time slot is over and go over there. 9 00:00:23,260 --> 00:00:26,280 I'm Jacob West. I run security research at Fortify Software. 10 00:00:26,280 --> 00:00:27,760 We're a software security company. 11 00:00:27,860 --> 00:00:30,180 We make tools for helping people build more secure software, 12 00:00:31,040 --> 00:00:35,660 and I'm really happy to be here today to talk to you guys a little bit about static analysis and fuzzing 13 00:00:35,660 --> 00:00:41,040 and what the right distribution of time from a software security practitioner standpoint 14 00:00:41,660 --> 00:00:43,500 one might make between the two technologies. 15 00:00:45,420 --> 00:00:47,940 So I'm going to start off with a little introduction about fuzzing. 16 00:00:48,140 --> 00:00:51,180 Some of this will be a review for a lot of you, I imagine, 17 00:00:51,300 --> 00:00:55,440 as well as some challenges that I see with fuzzing in terms of what you want to get out of it, 18 00:00:55,500 --> 00:00:56,160 and how you're going to reach those. 19 00:00:56,280 --> 00:00:58,660 Then I'll talk a little bit about static analysis, 20 00:00:58,960 --> 00:01:00,960 some of the benefits and challenges with that, 21 00:01:01,040 --> 00:01:04,880 and how energy can best be put into static analysis to get the most out of it. 22 00:01:05,260 --> 00:01:08,840 And then I'll conclude with some experimental results running on a small program 23 00:01:08,840 --> 00:01:10,260 comparing the two technologies. 24 00:01:12,620 --> 00:01:13,780 So what is fuzzing? 25 00:01:14,780 --> 00:01:19,020 Really, it's anything that encompasses run-time testing of the application 26 00:01:19,020 --> 00:01:21,760 with random or semi-random input. 27 00:01:22,040 --> 00:01:25,880 So it was originally documented by Barton Miller around 1990, 28 00:01:26,280 --> 00:01:27,160 from University of Wisconsin. 29 00:01:27,540 --> 00:01:29,620 He's got a series of papers from that point on 30 00:01:29,620 --> 00:01:31,960 where they've taken fairly basic fuzzing tools 31 00:01:31,960 --> 00:01:33,940 and applied them to a variety of software, 32 00:01:34,200 --> 00:01:38,800 ranging from Unix distributions to Windows applications, 33 00:01:39,060 --> 00:01:40,820 and most recently, I think, OSX. 34 00:01:43,200 --> 00:01:46,920 So just to clarify what I'm talking about when I say fuzzing, 35 00:01:46,940 --> 00:01:48,980 because I think it can be a little bit vague these days. 36 00:01:49,080 --> 00:01:51,080 It's not necessarily a well-defined field. 37 00:01:51,340 --> 00:01:56,260 I'm talking about tools that are really much more on the random side of input rather than the, 38 00:01:56,280 --> 00:01:58,180 uh, known attack side of input. 39 00:01:58,400 --> 00:02:00,780 So I'm talking about tools like Spike, Peach, Protos, 40 00:02:00,880 --> 00:02:05,580 not necessarily black box testing tools like Senzic, Spy, Dynamics, and Watchfire. 41 00:02:08,520 --> 00:02:11,360 So a couple of thoughts from Barton Miller, 42 00:02:11,460 --> 00:02:13,520 just to set the stage for what I'm gonna say today. 43 00:02:14,460 --> 00:02:18,000 In many of the papers he's published on fuzzing since the first one, 44 00:02:18,120 --> 00:02:20,220 he's reiterated the point that he does not intend, 45 00:02:20,440 --> 00:02:23,380 never intended fuzzing to be a replacement for more formal methods. 46 00:02:23,600 --> 00:02:25,780 So program verification, or, 47 00:02:25,780 --> 00:02:27,100 or more formal testing mechanisms. 48 00:02:27,320 --> 00:02:30,380 Rather, it's a useful way to find low-hanging fruit, 49 00:02:30,540 --> 00:02:33,660 so put a little bit of effort in and get easy bugs back out. 50 00:02:36,580 --> 00:02:39,600 Unfortunately these days, we hear a lot of people making, uh, 51 00:02:39,800 --> 00:02:42,120 woulda, coulda, shoulda comments about fuzzing. 52 00:02:42,240 --> 00:02:45,400 So, after you find a bug through whatever mechanism, 53 00:02:45,580 --> 00:02:49,120 either manual testing from somebody in the field that you didn't want to find it, 54 00:02:49,320 --> 00:02:51,180 static analysis, however else you go about it, 55 00:02:51,260 --> 00:02:53,080 it's often easy to come back and say, 56 00:02:53,600 --> 00:02:55,760 oh, well we could have found that. 57 00:02:55,780 --> 00:03:01,180 now that we know what the bug looks like I think this is a dangerous dangerous 58 00:03:02,100 --> 00:03:05,940 approach because leads you into a false sense of confidence that you're going to 59 00:03:05,940 --> 00:03:08,660 be able to find bugs more and more easily just because you found bugs in 60 00:03:08,660 --> 00:03:13,460 the past this is referring to you know I don't actually remember what program 61 00:03:13,460 --> 00:03:17,740 this is in but it's in the secure coding list and Ken van wick came out saying 62 00:03:18,620 --> 00:03:21,920 this buffer overflow would have been really difficult to find using fuzzing 63 00:03:21,920 --> 00:03:25,060 or manual testing because it involved a lot of program context and fuzzing a 64 00:03:25,060 --> 00:03:29,180 very specific type of data Steve Christie came back and said well now 65 00:03:29,180 --> 00:03:33,020 that we know what the type of data was and what the bug that that data tweaked 66 00:03:33,020 --> 00:03:36,620 was it'd be very easy to generate a fuzzing test that would find that which 67 00:03:36,620 --> 00:03:40,760 is a great idea but don't let that lead you into believing that the next time 68 00:03:40,760 --> 00:03:45,180 there's such a bug you'll find it too if it's the same scenario you will but you 69 00:03:45,180 --> 00:03:48,000 need all that context order to decide what the bug was that you're looking 70 00:03:48,000 --> 00:03:53,560 for same thing goes with the animated cursor bug in Microsoft earlier Mike 71 00:03:53,560 --> 00:03:55,040 Howard came back and basically said 72 00:03:55,040 --> 00:03:59,480 yeah that was a test case that was missing from our fuzzing scripts now we 73 00:03:59,480 --> 00:04:02,340 can add it we'll be able to find them in the future but that doesn't mean that 74 00:04:02,340 --> 00:04:05,400 there isn't another very similar parallel bug that's not quite the same 75 00:04:05,400 --> 00:04:12,560 that they're gonna miss so at a high level fuzzing works in a couple of 76 00:04:12,560 --> 00:04:16,820 steps so it's about identifying what the sources of input you want to fuzz in the 77 00:04:16,820 --> 00:04:23,140 application are permuting existing files or input or generating new input 78 00:04:23,140 --> 00:04:23,900 entirely randomly 79 00:04:25,040 --> 00:04:28,640 and then trying to monitor the application to identify when an error 80 00:04:28,640 --> 00:04:33,060 has occurred and that could be as simple as the program crashing or an error 81 00:04:33,060 --> 00:04:37,900 message being displayed or a change in behavior that's unanticipated so when 82 00:04:37,900 --> 00:04:41,800 you find one of these with an Oracle you record the state that led to that error 83 00:04:41,800 --> 00:04:46,000 and now you've got a reproducible test case to come back in and document what 84 00:04:46,000 --> 00:04:49,140 the problem was and figure out what what what the real issue was so you can fix 85 00:04:49,140 --> 00:04:54,840 it so fuzzing really is tied to specific 86 00:04:55,040 --> 00:04:59,360 types of input so we've got file fuzzers we've got network protocol fuzzers we've 87 00:04:59,360 --> 00:05:03,260 got all kinds of things on the file side just to give a couple examples of these 88 00:05:03,260 --> 00:05:06,500 you might fuzz jpg files TIFF files PDFs and so on 89 00:05:07,500 --> 00:05:10,660 you collect a library of those valid files because you need to know what the 90 00:05:10,660 --> 00:05:12,880 structure is going to look like you could set up a program that would 91 00:05:12,880 --> 00:05:16,040 generate them from scratch as well but you really want some existing structure 92 00:05:16,560 --> 00:05:21,260 and then you start modifying in various ways and we'll talk about kind of smart 93 00:05:21,260 --> 00:05:24,400 fuzzing and dumb fuzzing but the simplest is you just start changing 94 00:05:24,400 --> 00:05:27,400 changing bytes around in the file and see how the program consumes it. 95 00:05:27,640 --> 00:05:31,300 More advanced techniques are going to look for specific areas of the file so that the 96 00:05:31,300 --> 00:05:36,320 file isn't instantly malformed in terms of the structure, but also maybe tweaks problems 97 00:05:36,320 --> 00:05:38,180 with individual fields within the file. 98 00:05:38,760 --> 00:05:42,500 Then you run the program, have it consume the file, see what happens, look for problems. 99 00:05:44,500 --> 00:05:46,420 Network protocols, it's very much the same way. 100 00:05:46,560 --> 00:05:49,960 You can either try to generate network traffic arbitrarily or you can record some existing 101 00:05:49,960 --> 00:05:53,160 network traffic and then start tweaking fields within it. 102 00:05:56,320 --> 00:05:58,780 I mentioned before dumb fuzzing and smart fuzzing. 103 00:05:59,900 --> 00:06:06,260 Dumb fuzzing really is the idea that you're going to start with some rough idea of, okay, 104 00:06:06,360 --> 00:06:09,660 I'm going to send a network packet or I'm going to create a file, but you don't worry 105 00:06:09,660 --> 00:06:10,700 about the structure of that file. 106 00:06:10,880 --> 00:06:12,560 You just start arbitrarily changing bits around. 107 00:06:12,780 --> 00:06:13,700 Some of those will be valid. 108 00:06:13,940 --> 00:06:17,240 Some of them will get, most of them, in fact, will get thrown out right away because the 109 00:06:17,240 --> 00:06:19,940 file just won't parse to begin with or the network packet won't. 110 00:06:19,940 --> 00:06:21,020 It will just be rejected right away. 111 00:06:22,760 --> 00:06:29,620 This works pretty well for basic test cases because handling those malformed files, you 112 00:06:29,620 --> 00:06:33,800 may have failures there as well, but you're not going to get to deeper level bugs that 113 00:06:33,800 --> 00:06:37,640 involve specific fields being malformed and how the program handles that data. 114 00:06:39,000 --> 00:06:42,520 It can take a long time to enumerate all the test cases because you have a large file. 115 00:06:42,620 --> 00:06:43,820 You're changing one byte at a time. 116 00:06:43,880 --> 00:06:45,900 You can imagine there are now a lot of permutations of these. 117 00:06:47,080 --> 00:06:49,760 Very few of those are going to get passed. 118 00:06:49,940 --> 00:06:51,120 That's kind of the first level of validation. 119 00:06:54,540 --> 00:06:59,120 Smart fuzzing, the idea is you start altering content, so you're aware of the data structures 120 00:06:59,120 --> 00:07:03,720 that are involved in the network protocol, the file, whatever you're working with, and 121 00:07:03,720 --> 00:07:05,240 you start changing individual fields. 122 00:07:05,400 --> 00:07:08,580 You might change a null terminated string to remove the null character. 123 00:07:08,940 --> 00:07:10,720 You might alter numeric values. 124 00:07:10,940 --> 00:07:11,660 You might flip signs. 125 00:07:11,940 --> 00:07:13,760 You might try a large integer, smallest integer. 126 00:07:13,940 --> 00:07:17,540 You can be a little more intelligent here with the kind of input the program expects 127 00:07:17,540 --> 00:07:19,360 in a given field and the kind you're going to give it. 128 00:07:19,360 --> 00:07:23,140 Not necessarily that you want to give it exactly what it expects, but enumerate the 129 00:07:23,140 --> 00:07:23,880 cases at least. 130 00:07:24,820 --> 00:07:31,720 This also can involve changing the, within the data structure, changing the structure. 131 00:07:33,220 --> 00:07:36,080 Adding additional headers, duplicating specific fields. 132 00:07:36,160 --> 00:07:39,420 What happens if there are two of a field the program only expects one of? 133 00:07:39,540 --> 00:07:41,080 Is it going to use the first one, the second one? 134 00:07:41,340 --> 00:07:42,420 Is it deterministic? 135 00:07:45,480 --> 00:07:49,220 The real challenge that I see with fuzzing is related. 136 00:07:49,360 --> 00:07:53,940 It's related to assurance, and that's kind of an overloaded word in security, so I don't 137 00:07:53,940 --> 00:07:55,540 use it in any of the overloaded ways. 138 00:07:55,780 --> 00:08:00,000 But how do you tell how many of the input sources you tested? 139 00:08:00,200 --> 00:08:03,500 How do you tell how much of the program underneath those input sources you reached? 140 00:08:03,960 --> 00:08:06,720 How do you tell when an error occurs? 141 00:08:07,020 --> 00:08:08,660 So this is all about quality of the oracle. 142 00:08:08,960 --> 00:08:13,120 And then as you increase all of these things, you're going to have the side effect that 143 00:08:13,120 --> 00:08:17,480 the runtime of your test is actually going to increase as well, because in order to exercise 144 00:08:17,960 --> 00:08:18,640 more of the code. 145 00:08:19,360 --> 00:08:22,360 You're running the program more times or subjecting it to more input. 146 00:08:23,400 --> 00:08:27,620 So the Microsoft SDL has a pretty concrete policy about this. 147 00:08:27,720 --> 00:08:31,060 It says you need to run it 100,000 times per file format per parser. 148 00:08:31,440 --> 00:08:35,320 When you find a bug, you have to start at zero, start with a new seed, and run up to 149 00:08:35,320 --> 00:08:36,120 another 100,000. 150 00:08:37,620 --> 00:08:38,440 Why is that? 151 00:08:38,600 --> 00:08:41,780 I'm sure they have empirical evidence that says they find a lot of bugs that way, which 152 00:08:41,780 --> 00:08:42,120 is great. 153 00:08:42,240 --> 00:08:44,860 But what does that really mean in terms of the quality of your testing? 154 00:08:45,500 --> 00:08:48,000 So these are some of the points we're going to try to talk about today. 155 00:08:51,180 --> 00:08:56,500 So next, I want to talk about some challenges tied to those questions I had on the last slide. 156 00:08:56,700 --> 00:09:00,540 So how do you identify the input sources in your program? 157 00:09:01,020 --> 00:09:02,260 Sometimes this is really easy. 158 00:09:02,380 --> 00:09:06,240 So a standard web application and AJAX and JavaScript and dynamic stuff on the client 159 00:09:06,240 --> 00:09:07,740 is starting to change this a little bit. 160 00:09:07,900 --> 00:09:09,860 But think of a traditional web application. 161 00:09:10,240 --> 00:09:13,180 You've got HTTP requests and responses going back and forth. 162 00:09:13,280 --> 00:09:14,100 You can record those. 163 00:09:14,220 --> 00:09:15,560 They've got a very concrete structure. 164 00:09:15,860 --> 00:09:17,480 You can start fuzzing fields in them. 165 00:09:17,520 --> 00:09:18,460 This is pretty straightforward. 166 00:09:19,360 --> 00:09:20,420 And fairly generalizable. 167 00:09:20,720 --> 00:09:25,700 So I'm starting with the assumption that most of us are not in the business of creating 168 00:09:25,700 --> 00:09:28,280 our own fuzzing tools for every application we want to work on. 169 00:09:28,380 --> 00:09:29,220 That could be a lot of work. 170 00:09:29,540 --> 00:09:34,980 So it's desirable to have some generalization between programs, between protocols, and so 171 00:09:34,980 --> 00:09:35,180 on. 172 00:09:35,820 --> 00:09:40,280 So when you've got a standard protocol like HTTP web traffic, it's fairly easy to generalize. 173 00:09:40,320 --> 00:09:45,320 When you have proprietary web service APIs or a specific network server that accepts 174 00:09:45,740 --> 00:09:47,220 packets with some structure in them. 175 00:09:48,040 --> 00:09:49,340 Or if the client's software. 176 00:09:49,340 --> 00:09:51,100 With proprietary communication protocol. 177 00:09:51,380 --> 00:09:55,180 You start to lose some of that generalizability and you've got to start doing things much 178 00:09:55,180 --> 00:09:56,640 more specifically to your software. 179 00:09:59,360 --> 00:10:04,040 It's very difficult to, when you're dealing with new protocols, determine what would constitute 180 00:10:04,040 --> 00:10:06,080 valid input versus invalid input. 181 00:10:06,260 --> 00:10:07,260 So you see a couple of examples. 182 00:10:08,080 --> 00:10:13,860 You may very well get stuck in that no man's land of producing input that isn't valid and 183 00:10:13,860 --> 00:10:16,540 isn't going to make it past the very first level of validation. 184 00:10:18,040 --> 00:10:18,500 Really. 185 00:10:18,500 --> 00:10:23,400 What this is all saying is to get past these in more complex types of software, more proprietary 186 00:10:23,400 --> 00:10:27,400 types of software, you're going to require customization to tune it to these protocols 187 00:10:27,400 --> 00:10:28,880 and you're going to lose that generalization. 188 00:10:32,060 --> 00:10:37,280 So tied to this is once you've exercised that attack surface, those inputs, how do 189 00:10:37,280 --> 00:10:40,660 you tell how much of the program you've exercised or how do you increase the amount of the program 190 00:10:40,660 --> 00:10:41,500 that you've exercised? 191 00:10:41,820 --> 00:10:48,260 This is kind of a simple example with a couple of string manipulation calls in C. You do 192 00:10:48,260 --> 00:10:53,260 do a stir compare on input one, and then you do a copy operation on input two. And we're 193 00:10:53,260 --> 00:10:56,820 going to assume both of those are coming from the outside. Now, in order to ever exercise 194 00:10:56,820 --> 00:11:00,260 this buffer overflow, which depending on how big input two is, it's very likely a buffer 195 00:11:00,260 --> 00:11:04,800 overflow, the stir copy call, the fuzzer would need to know that input one needs to match 196 00:11:04,800 --> 00:11:09,940 this static string value. Now, obviously, you could tune a tool to provide that input, 197 00:11:10,100 --> 00:11:13,520 but now you're in the business of manually determining what all the bugs in your program 198 00:11:13,520 --> 00:11:19,340 might be. So the tool finding that randomly can be quite hard, and you end up with permutations 199 00:11:19,340 --> 00:11:24,100 of input to reach all the given states. So you need, in this case, static string to have 200 00:11:24,100 --> 00:11:30,040 a particular value, input one to match static string, and a large value in input two. So 201 00:11:30,040 --> 00:11:32,860 now you're dependent on what the values you're providing for both of these inputs is. 202 00:11:37,140 --> 00:11:40,420 To go into that a little bit more, here's another example with a couple of conditionals. 203 00:11:40,440 --> 00:11:43,120 So if x equals three, then we have one buffer overflow. 204 00:11:43,520 --> 00:11:47,440 If y equals five, we're nested in that same if block. We have another buffer overflow. 205 00:11:47,720 --> 00:11:51,860 And finally, if z equals seven, and those previous conditions are matched, then we have 206 00:11:51,860 --> 00:11:55,300 another buffer overflow. Now, what's the likelihood that a fuzzing tool is going to 207 00:11:55,300 --> 00:11:59,660 find each one of these? So the likelihood that if it's fuzzing each of these values 208 00:11:59,660 --> 00:12:03,860 independently, it's going to get x equals three is one over two to the 32nd, all the 209 00:12:03,860 --> 00:12:08,960 values in an integer, let's say. Now, for each of those subsequent permutations, you 210 00:12:08,960 --> 00:12:11,920 have to get every combination between each of the values in the conditional, right? Because 211 00:12:11,920 --> 00:12:13,040 now you need x equals three. 212 00:12:13,720 --> 00:12:15,480 So you have to get every combination between each of the values in the conditional, right? 213 00:12:15,480 --> 00:12:15,560 So you have to get every combination between each of the values in the conditional, right? 214 00:12:15,800 --> 00:12:19,000 So you can see the run time and the number of inputs you have to provide to the program 215 00:12:19,000 --> 00:12:25,300 really can explode here. In fact, in the worst case, it explodes exponentially. And 216 00:12:25,960 --> 00:12:30,660 that is painful for you as the person running or developing the fuzzing tool because you 217 00:12:30,660 --> 00:12:33,900 have to come up with all those inputs and maybe try to do some optimizations to narrow 218 00:12:33,900 --> 00:12:39,760 the field a little bit. But most of all, it's painful from a run time perspective. So how 219 00:12:39,760 --> 00:12:42,940 long is it going to take you to run these tests if you really want to get very solid 220 00:12:42,940 --> 00:12:43,500 code coverage? So that's a good question. So I'm going to go ahead and show you how to 221 00:12:43,500 --> 00:12:49,320 get very solid code coverage. Just to give you an example, we were looking at a conditional 222 00:12:49,320 --> 00:12:54,280 depth of three in that made up example with the get s calls before. I picked a couple 223 00:12:54,280 --> 00:12:58,720 of bugs that I've been thinking about lately. So there's a buffer overflow and a format 224 00:12:58,720 --> 00:13:03,240 string bug from WFTPD that have been around forever. Those are nested below three and 225 00:13:03,240 --> 00:13:08,180 four conditionals each. And one in offbiz from Apache across its scripting bug that's 226 00:13:08,180 --> 00:13:12,720 got four conditionals in front of it. So the idea of two, three, four, five levels of conditionals 227 00:13:12,720 --> 00:13:24,000 in front of a bug, not unlikely. So the second piece of this, those were really, if you've 228 00:13:24,000 --> 00:13:27,640 got a solid understanding of the conditional, then it's fairly easy to reach those. And 229 00:13:27,640 --> 00:13:31,380 through purely random input, you could reach all of them given a sufficient amount of time. 230 00:13:32,000 --> 00:13:37,980 A second class of hard to reach states has to do with program semantics and program context. 231 00:13:38,320 --> 00:13:41,920 So imagine an airline booking system that accepts reservations for flights. 232 00:13:41,920 --> 00:13:47,080 And there's a bug on a page that's only displayed when a flight is full. So the fuzzing tool 233 00:13:47,080 --> 00:13:52,420 now needs to know that it needs to reserve 297 seats, which will all behave in no interesting 234 00:13:52,420 --> 00:13:56,520 way, one after another exactly the same. And then the 298th time, it's going to behave 235 00:13:56,520 --> 00:14:01,440 entirely differently. So these are cases where, again, you're customizing the tool if you 236 00:14:01,440 --> 00:14:06,140 want to reach that with a fuzzing tool to handle the program logic. And you're really 237 00:14:06,140 --> 00:14:09,980 losing that ability to generalize across multiple programs because you're tuning it to your 238 00:14:09,980 --> 00:14:11,480 very, very specific environment. 239 00:14:11,480 --> 00:14:19,120 So that can be fairly costly. And the benefits are hard to judge, because they're going to find 240 00:14:19,120 --> 00:14:22,560 very specific bugs that you almost had to understand, for example, in this case, before 241 00:14:22,560 --> 00:14:25,120 you did the customization to reach them. 242 00:14:28,580 --> 00:14:33,540 The final challenge I want to talk about is identifying errors. So this has to do with 243 00:14:33,540 --> 00:14:38,260 the oracle that the fuzzing tool uses to tell when some input that it's provided has actually 244 00:14:38,260 --> 00:14:40,340 identified an error, produced an error in the application. 245 00:14:41,480 --> 00:14:47,520 So this is great for traditional system programs where any kind of bad input and it's going 246 00:14:47,520 --> 00:14:51,560 to crash or return with a bad error code. Great. You can tell when that happens. 247 00:14:52,280 --> 00:14:56,500 Modern applications, for the most part, are being architected to hide errors in a lot 248 00:14:56,500 --> 00:15:00,960 of ways, or at least not reveal a lot of details, but what the error was. So web applications 249 00:15:00,960 --> 00:15:05,900 often will take you to a single kind of discrete error page that doesn't give you any details 250 00:15:05,900 --> 00:15:08,620 about what happened, because they don't want you to know about what's going on behind the 251 00:15:08,620 --> 00:15:11,460 scenes. So when you're using fuzzing, you're basically 252 00:15:11,480 --> 00:15:15,240 dropping yourself back to more or less the level of an attacker, because you're coming 253 00:15:15,240 --> 00:15:19,400 at it from a black box perspective. You may put some knowledge into the tool, but when 254 00:15:19,400 --> 00:15:22,380 the tool is actually running, it doesn't have any visibility beyond whatever the interface 255 00:15:22,380 --> 00:15:23,400 that it's communicating with. 256 00:15:24,000 --> 00:15:29,100 So how do you tell when an error has occurred? You need better oracles. You can gain some 257 00:15:29,560 --> 00:15:34,060 ground here by looking inside the code, so instrumenting it with checkpoints to see 258 00:15:34,060 --> 00:15:39,320 when the fuzzing tool is exercising in this way, here's the behavior, here's what signifies 259 00:15:39,320 --> 00:15:40,580 an error in a given case. 260 00:15:41,480 --> 00:15:44,900 But again, you're talking about putting a lot more energy beyond that kind of simple 261 00:15:44,900 --> 00:15:49,340 run it to find low-hanging fruit bugs that Barton Miller described when he came up with 262 00:15:49,340 --> 00:15:49,840 this technique. 263 00:15:52,200 --> 00:15:58,280 So really what I'm saying with some of those examples and in general today is that fuzzing 264 00:15:59,440 --> 00:16:05,000 bugs that you might find with fuzzing really fall across the spectrum. So at the very easy 265 00:16:05,000 --> 00:16:09,360 end are things in web applications like a shallow cross-descripting bug. So the shallowest 266 00:16:09,360 --> 00:16:10,980 case being it never even leaves the client. 267 00:16:11,480 --> 00:16:14,940 Or a little worse, it goes up to the server and comes straight back. That's pretty easy 268 00:16:14,940 --> 00:16:17,660 to identify, fuzzing is a great way to go about doing this. 269 00:16:18,220 --> 00:16:22,860 And just to clarify for everyone, I'm in no way advocating, when I say stop fuzzing, 270 00:16:23,440 --> 00:16:28,060 I don't mean never start fuzzing. I just mean know how much energy it's worth putting 271 00:16:28,060 --> 00:16:31,260 into the process and what you're going to get back out of it and where that sweet spot 272 00:16:31,260 --> 00:16:33,480 in terms of ROI for your time is. 273 00:16:34,720 --> 00:16:39,400 At the hard end, you have these things where you need to run millions or billions of inputs 274 00:16:39,400 --> 00:16:40,520 in order to reach the bug. 275 00:16:41,480 --> 00:16:46,040 You've put so much understanding of the application's logic into the fuzzing tool that you've put 276 00:16:46,040 --> 00:16:49,880 more effort than it's really worth getting back out to find because you need to really 277 00:16:49,880 --> 00:16:53,640 customize it to not even an application but the case of a specific bug almost. 278 00:16:55,960 --> 00:17:01,020 So to summarize, advantages of fuzzing, it's really one of the easiest testing techniques 279 00:17:01,020 --> 00:17:05,460 you can go about. If you've got an application that runs, there's probably a fuzzing tool 280 00:17:05,460 --> 00:17:09,560 you can let loose on it in one way or another and very likely find some bugs. I mean, looking 281 00:17:09,560 --> 00:17:11,120 at Miller's research. 282 00:17:11,120 --> 00:17:15,480 The papers, paper after paper, in every case, he found bugs in a large percentage of the 283 00:17:15,480 --> 00:17:21,820 programs he was testing with very unintelligent tools. So he wasn't tuning them very carefully 284 00:17:21,820 --> 00:17:22,560 to the environment. 285 00:17:24,180 --> 00:17:28,460 The other advantage of any sort of runtime testing is you have a reproducible test case 286 00:17:28,460 --> 00:17:32,760 at the end. So you're fairly certain what you found actually is a bug depending on how 287 00:17:32,760 --> 00:17:36,280 good your Oracle is because you had some input and you know what the output that came back 288 00:17:36,280 --> 00:17:40,380 out was and that tells you that there was a bug. There can be false positives there but 289 00:17:41,120 --> 00:17:44,480 in contrast with static analysis, it's much closer to being a proven bug at that point. 290 00:17:45,340 --> 00:17:49,700 And finally, there is the potential to generalize and to scale across programs where you have 291 00:17:49,700 --> 00:17:54,820 standardization on protocols and input sources. So the web is a great example. Doing fuzzing 292 00:17:54,820 --> 00:17:58,360 for certain kinds of vulnerabilities in web applications absolutely makes sense and you 293 00:17:58,360 --> 00:18:00,680 will find them more easily than probably with any other technique. 294 00:18:02,660 --> 00:18:07,340 Disadvantages of fuzzing. It can be very costly to achieve completeness. So reaching 295 00:18:07,340 --> 00:18:10,160 all of those conditionals, reaching those hard to reach states. 296 00:18:11,120 --> 00:18:14,300 Can be quite hard and can involve a lot of effort on the tool developer's standpoint 297 00:18:14,300 --> 00:18:15,820 to make it work in their environment. 298 00:18:17,880 --> 00:18:22,840 If you succeed in that, which is hard enough on its own, then the runtime costs of the 299 00:18:22,840 --> 00:18:26,440 tool are going to grow with your success. So the more of the application you're testing, 300 00:18:26,640 --> 00:18:30,080 the more inputs you're going to provide and the longer it's going to take to run your 301 00:18:30,080 --> 00:18:31,320 tests, almost invariably. 302 00:18:33,340 --> 00:18:40,700 And finally, you may have a great test and a bad Oracle. So an example of this is we 303 00:18:40,700 --> 00:18:46,520 were running a fuzz test on an application in our office looking for path manipulation 304 00:18:46,520 --> 00:18:52,880 bugs. So you provide some nasty input and it ends up in a file system call. We ran this 305 00:18:52,880 --> 00:18:57,280 test and the fuzzing tool we were using came back and said, nope, didn't find anything. 306 00:18:57,520 --> 00:19:01,260 The web application was still running just fine. Everything appeared to have no problems 307 00:19:01,260 --> 00:19:05,740 whatsoever. Till we rebooted the machine, because it had overwritten one of the critical 308 00:19:05,740 --> 00:19:09,520 operating system files. One of the attacks had succeeded. It wasn't evidenced back through 309 00:19:10,700 --> 00:19:15,940 it, but our machine was hosed and we had to recover it. So having a good Oracle really 310 00:19:15,940 --> 00:19:20,200 matters here. If that file wasn't a critical system file, we never would have known about 311 00:19:20,200 --> 00:19:23,280 the vulnerability. It would have overwritten something sitting in temp somewhere, who knows. 312 00:19:23,680 --> 00:19:27,960 And the tool never would have told us that there was a problem, even though it had in 313 00:19:27,960 --> 00:19:30,580 fact succeeded in attacking the application just as it intended to. 314 00:19:33,160 --> 00:19:38,860 So I want to switch over to talking about static analysis a little bit. And prehistoric 315 00:19:38,860 --> 00:19:39,560 may be a stretch. 316 00:19:40,700 --> 00:19:44,760 I don't know how many years between these tools and where we are today, but depending 317 00:19:44,760 --> 00:19:49,360 on where your familiarity with static analysis comes in, you may have heard about tools like 318 00:19:49,360 --> 00:19:53,820 RATS, ITS4, FlawFinder, some of the early open source solutions in the space. And these 319 00:19:53,820 --> 00:19:58,900 really are dinosaurs compared to what we're dealing with today. They were useful in a 320 00:19:58,900 --> 00:20:03,760 lot of ways. So for a security professional, these tools were great. They gave them the 321 00:20:03,760 --> 00:20:08,920 ability to really focus their manual audit techniques or process, and they gave them 322 00:20:08,920 --> 00:20:10,500 a repository of information. 323 00:20:10,500 --> 00:20:10,680 So I'm going to turn it over to you. 324 00:20:10,700 --> 00:20:13,520 So let's talk about security. So they gave them a list of functions that you shouldn't 325 00:20:13,520 --> 00:20:17,620 use, and they can go through and verify whether there were bugs there or not. The downside 326 00:20:17,620 --> 00:20:22,240 is they're not bug finders. So the output of these tools was close to a glorified graph. 327 00:20:22,340 --> 00:20:26,080 It gave you a list of things that you should go inspect, not a list of bugs to file to 328 00:20:26,080 --> 00:20:32,060 your QA department. You really need to have security expertise to use them. And the difference 329 00:20:32,060 --> 00:20:35,300 between those and tools today is that we're trying to make tools that are a little more 330 00:20:35,300 --> 00:20:39,660 useful for developers, people who are not security professionals, but security professionals 331 00:20:39,660 --> 00:20:40,100 too. 332 00:20:40,980 --> 00:20:46,360 So the biggest piece of that change from the prehistoric tools to where we are today 333 00:20:46,360 --> 00:20:51,380 is about prioritization. So a tool today should still warn you about every call to stir copy 334 00:20:51,380 --> 00:20:54,740 in your code, because you just shouldn't be calling stir copy. But it should also be 335 00:20:54,740 --> 00:20:57,660 able to give you some prioritization between those two and tell you which ones are important. 336 00:20:58,080 --> 00:21:01,280 Because if you've got 10,000 calls to stir copy in your code, you need the ability to 337 00:21:01,280 --> 00:21:05,660 prioritize which ones you should look at. Unfortunately, this misconception about the 338 00:21:05,660 --> 00:21:10,060 prehistoric tools lives on to today. I was really excited about the new fuzzing book, 339 00:21:10,060 --> 00:21:14,620 and I still am in a lot of ways. But on page four, they've got these examples where they're 340 00:21:14,620 --> 00:21:19,540 trying to refute the applicability of static analysis in finding security bugs. And they 341 00:21:19,540 --> 00:21:24,640 give two main methods, functions, each with a car buffer, each with a stir copy. The only 342 00:21:24,640 --> 00:21:28,580 difference is what you're copying into that stack buffer. In one case, you're copying 343 00:21:28,580 --> 00:21:33,420 a short static string that will fit just fine. In the other case, you're copying a command 344 00:21:33,420 --> 00:21:37,140 line argument. So this could be exploitable, depending on the environment the program is 345 00:21:37,140 --> 00:21:37,820 running in, right? 346 00:21:39,300 --> 00:21:40,040 Rats, it's fine. It's fine. It's fine. It's fine. It's fine. It's fine. It's fine. It's fine. 347 00:21:40,040 --> 00:21:43,480 In page four, no difference, right? They're going to say, there's a call to stir copy 348 00:21:43,480 --> 00:21:48,440 on line X. You should really look at it. Modern tools are going to tell you, one case, there's 349 00:21:48,440 --> 00:21:52,560 a stir copy, low priority. The other case, here's a command line argument being accepted 350 00:21:52,560 --> 00:21:56,660 into main and eventually being used in a stir copy. This is accessible from outside 351 00:21:56,660 --> 00:21:59,640 the program, potentially exploitable. This is near the top of your list then. 352 00:22:02,600 --> 00:22:08,180 So why is static analysis good for security? It's fast compared to manual review and testing. 353 00:22:09,140 --> 00:22:13,020 It's complete and consistent in its coverage, so you get to consider all the possible states, 354 00:22:13,100 --> 00:22:18,300 all the possible inputs, basically for free. It makes the security review process easier 355 00:22:18,300 --> 00:22:23,100 for non-experts. So some of that knowledge about what are interesting, even from the 356 00:22:23,100 --> 00:22:26,700 early tools RATS and its four, what methods, what functions are interesting, what we need 357 00:22:26,700 --> 00:22:31,100 to look for, can be encompassed in the tool and provided to the user who might not be 358 00:22:31,100 --> 00:22:37,260 a security expert. And they're useful on all kinds of code. So although the rule sets, 359 00:22:37,340 --> 00:22:38,160 we'll talk more about rule sets in a little bit, but they're useful on all kinds of code. 360 00:22:38,160 --> 00:22:40,720 So although the rule sets, we'll talk more about rule sets in a little bit, but they're useful on all kinds of code. 361 00:22:40,720 --> 00:22:44,820 The technique and the tool, the engine, are typically applicable across entire languages 362 00:22:44,820 --> 00:22:48,260 and multiple languages, in fact. So you don't get this kind of specialization that you need 363 00:22:48,260 --> 00:22:51,500 to have with fuzzing tools to a particular environment, a particular protocol. 364 00:22:54,220 --> 00:22:58,960 Not a silver bullet, though. So despite how much I would love for static analysis to be 365 00:22:58,960 --> 00:23:03,380 the solution to everyone's problems, absolutely not. It's harder to get started with static 366 00:23:03,380 --> 00:23:07,260 analysis than it is with fuzzing. So again, if you have an application that runs, you 367 00:23:08,160 --> 00:23:12,440 pointed at the program, let her rip and probably find some bugs in a lot of cases. Static analysis 368 00:23:12,440 --> 00:23:16,200 is more involved. You need to have access to the source code. You need to, in a lot 369 00:23:16,200 --> 00:23:19,760 of cases, be able to build the source code, understand how to build the source code, understand 370 00:23:19,760 --> 00:23:23,500 what the source code is doing. These are not skills that everyone who wants to find 371 00:23:23,500 --> 00:23:28,100 bugs in software has, necessarily. And they do require a good bit more investment before 372 00:23:28,100 --> 00:23:33,280 you start getting bugs back out the other end. On the technical side, static analysis 373 00:23:33,280 --> 00:23:37,240 tools have some limitations, too. They don't understand the program's architecture. They 374 00:23:37,240 --> 00:23:42,420 don't understand the semantics of the code. So this string, is it a credit card or is 375 00:23:42,420 --> 00:23:46,800 it a random temporary variable? These two things could be quite different. Statically, 376 00:23:46,940 --> 00:23:50,380 we're not going to have any idea, whereas with runtime testing, you might actually 377 00:23:50,380 --> 00:23:54,460 know because the data's there at that point, so you get a lot more context about it. And 378 00:23:54,460 --> 00:23:57,580 finally, they don't understand the social context of where these applications run and what the 379 00:23:57,580 --> 00:24:00,740 implications on those semantic values that are being passed around have. 380 00:24:03,400 --> 00:24:07,160 So I'm going to talk a little bit more about static analysis, what some custom 381 00:24:07,240 --> 00:24:11,860 ization potentials are, different types of analysis algorithms, and so on. Just to 382 00:24:11,860 --> 00:24:15,520 give you an overview of what I'm talking about, most static analysis tools work roughly like 383 00:24:15,520 --> 00:24:20,400 this. Take some source code in, include some modeling rules to describe things that maybe 384 00:24:20,400 --> 00:24:24,880 it doesn't have source code for, and build the model of the program. Then it's going 385 00:24:24,880 --> 00:24:29,320 to run one or more types of analysis against that model and use rules to describe what 386 00:24:29,320 --> 00:24:33,220 the problems it's looking for are in that case. And eventually, it's going to have some 387 00:24:33,220 --> 00:24:36,760 sort of viewer to render results. This might be as simple as the command line for those 388 00:24:37,240 --> 00:24:39,900 tools or a graphical interface or something built into an IDE. 389 00:24:42,420 --> 00:24:46,720 So what's critical on the front end of that? You need to be able to support whatever languages 390 00:24:46,720 --> 00:24:49,920 you're interested in looking at. That's pretty important. This is actually something that 391 00:24:49,920 --> 00:24:53,880 fuzzing tools have an advantage over static analysis on, right? So fuzzing tool doesn't 392 00:24:53,880 --> 00:24:58,120 care whether your web application is written in PHP or Java or .NET. It's still talking 393 00:24:58,120 --> 00:25:02,780 HTTP, which is all it cares about. So having the context of the code is both helpful and 394 00:25:02,780 --> 00:25:06,860 hurtful in this case. You can get around some of the limitations 395 00:25:06,860 --> 00:25:09,940 of actually having to have the source code by looking at the binary. So this might help 396 00:25:09,940 --> 00:25:13,400 people who are in a traditional testing environment and aren't used to thinking about source code, 397 00:25:13,500 --> 00:25:17,540 test and application. The downside is you start to lose a lot of that context that 398 00:25:17,540 --> 00:25:23,520 source code analysis actually benefits, typically, because it's written out of the bytecode version 399 00:25:23,520 --> 00:25:28,340 of it in some cases. And also, decompilation can be difficult. So getting back to something 400 00:25:28,340 --> 00:25:32,500 close to that original model. If you've got a Java jar file in debug mode, this is pretty 401 00:25:32,500 --> 00:25:35,900 easy. If you're trying to decompile C and analyze that, a little more difficult. 402 00:25:39,600 --> 00:25:43,500 So static analysis tools are driven off of rules. So what they know about the program 403 00:25:43,500 --> 00:25:48,000 outside of the immediate source code, so libraries that are linked in from the outside, as well 404 00:25:48,000 --> 00:25:53,000 as the kinds of security properties that they're looking for, are all provided by input 405 00:25:53,000 --> 00:25:57,780 from outside the analysis engine, basically. Rules in this case. And this is where a lot 406 00:25:57,780 --> 00:26:02,400 of the…you know, one of the premises I started with. So everybody ought to use fuzzing. Everyone 407 00:26:02,400 --> 00:26:06,360 ought to use static analysis. Now, from that baseline, how much energy do you put into 408 00:26:06,360 --> 00:26:06,840 each one? And what does that mean? You start with an idea and you think, well, what is 409 00:26:06,860 --> 00:26:07,640 and where is it best spent. 410 00:26:07,940 --> 00:26:10,940 And customization on the static analysis side, I argue, 411 00:26:11,120 --> 00:26:13,700 can potentially buy you more than on the fuzzing side 412 00:26:13,700 --> 00:26:15,120 because things can be more generalizable. 413 00:26:15,280 --> 00:26:16,720 So I'm gonna talk about some different kinds 414 00:26:16,720 --> 00:26:18,300 of analysis engines or different types 415 00:26:18,300 --> 00:26:21,000 of analysis techniques as well as different types of rules 416 00:26:21,480 --> 00:26:23,500 and give you an idea of how you could go 417 00:26:23,500 --> 00:26:24,820 about customizing some of these tools. 418 00:26:26,020 --> 00:26:28,940 So on the very easiest side of static analysis techniques 419 00:26:28,940 --> 00:26:30,640 is something called structural analysis. 420 00:26:30,820 --> 00:26:32,660 So you're not interested in control flow 421 00:26:32,660 --> 00:26:33,800 through the program, you're not interested 422 00:26:33,800 --> 00:26:35,540 in data flowing through the program, 423 00:26:35,540 --> 00:26:37,080 you're just interested in the structure 424 00:26:37,080 --> 00:26:38,160 as the program is declared. 425 00:26:39,220 --> 00:26:40,980 Simplest case, those get s calls. 426 00:26:41,220 --> 00:26:42,660 You shouldn't ever have get s in your program, 427 00:26:42,720 --> 00:26:43,700 how do you flag one of those? 428 00:26:43,880 --> 00:26:45,740 You need a function call, you need to match 429 00:26:45,740 --> 00:26:47,700 against every function call to a function named get s. 430 00:26:48,100 --> 00:26:49,640 About the easiest rule you can write. 431 00:26:51,500 --> 00:26:53,200 Going a little more complex, you can talk 432 00:26:53,200 --> 00:26:54,880 about structures of the program, 433 00:26:55,040 --> 00:26:57,300 but beyond a single function call. 434 00:26:57,360 --> 00:26:58,660 You can start to talk about a little broader scope. 435 00:26:59,040 --> 00:27:01,820 So the line under the example there 436 00:27:01,820 --> 00:27:05,140 is a potential memory leak in the case where Realloc fails. 437 00:27:05,540 --> 00:27:07,300 So if Realloc fails, it's gonna return null. 438 00:27:07,500 --> 00:27:09,140 If you overwrite the reference to that pointer, 439 00:27:09,300 --> 00:27:10,940 that hasn't been freed, now you've lost 440 00:27:10,940 --> 00:27:12,180 the ability to free that memory. 441 00:27:13,000 --> 00:27:14,460 Doesn't matter how this is executed, 442 00:27:14,600 --> 00:27:15,840 what the flow leading into it is, 443 00:27:15,940 --> 00:27:17,160 that's a potential memory leak. 444 00:27:18,420 --> 00:27:20,260 Structural rule for that is fairly simple again. 445 00:27:20,360 --> 00:27:22,360 So you're interested in a function call to Realloc, 446 00:27:22,780 --> 00:27:24,100 and then you're interested in whether 447 00:27:24,100 --> 00:27:25,380 the first parameter passed to Realloc 448 00:27:25,380 --> 00:27:26,660 is the same thing the return value 449 00:27:26,660 --> 00:27:27,980 from Realloc is assigned to. 450 00:27:32,860 --> 00:27:34,700 Data flow is what a lot of people think about 451 00:27:34,700 --> 00:27:35,520 when they think about it. 452 00:27:35,520 --> 00:27:36,860 It's a modern static analysis tool. 453 00:27:36,980 --> 00:27:38,320 So this is often what gives us the ability 454 00:27:38,320 --> 00:27:40,160 to prioritize and put things that we think 455 00:27:40,160 --> 00:27:42,280 might be exploitable at the top of the list, 456 00:27:42,360 --> 00:27:43,860 as opposed to the traditional mechanism 457 00:27:43,860 --> 00:27:45,860 of looking just at the structure of the program. 458 00:27:46,620 --> 00:27:49,140 This is a fairly simple command injection problem. 459 00:27:49,420 --> 00:27:51,140 So we get some input from outside, 460 00:27:51,360 --> 00:27:53,680 fictitious function names in these cases. 461 00:27:53,820 --> 00:27:55,340 We copy it from one buffer to another, 462 00:27:55,480 --> 00:27:56,800 and then we execute whatever that was. 463 00:27:58,720 --> 00:28:00,620 So assuming we don't have source code 464 00:28:00,620 --> 00:28:02,620 for get input from network, copy buffer, 465 00:28:03,360 --> 00:28:05,440 we need rules to describe what this 466 00:28:05,440 --> 00:28:07,560 and the significance of those functions is to the program. 467 00:28:07,780 --> 00:28:08,980 So the static analysis tool on its own 468 00:28:08,980 --> 00:28:10,460 isn't going to know that get input from network 469 00:28:10,460 --> 00:28:12,640 is a source of input, for example. 470 00:28:13,600 --> 00:28:17,100 So we're going to use a, you know, 471 00:28:17,160 --> 00:28:18,200 I've got a little problem on my slide, 472 00:28:18,300 --> 00:28:19,400 the sync rule bit at the bottom. 473 00:28:19,460 --> 00:28:20,500 Save that for the end. 474 00:28:20,660 --> 00:28:22,340 We're going to talk about up until then first. 475 00:28:22,480 --> 00:28:23,120 Sorry about that. 476 00:28:23,360 --> 00:28:25,600 So we need a source rule, which is the piece 477 00:28:25,600 --> 00:28:26,500 that's missing from the bottom, 478 00:28:26,600 --> 00:28:28,060 to say that get input from network 479 00:28:28,060 --> 00:28:29,720 actually introduces input to the program. 480 00:28:30,220 --> 00:28:31,860 So that's going to tell the analysis engine now 481 00:28:31,860 --> 00:28:33,040 that buff is something interesting. 482 00:28:33,300 --> 00:28:34,600 So it's going to start following buff, 483 00:28:35,440 --> 00:28:35,960 but we don't know what the significance 484 00:28:35,960 --> 00:28:36,960 of that's going to be yet. 485 00:28:38,880 --> 00:28:40,540 So it follows on its own that, okay, 486 00:28:40,560 --> 00:28:42,100 now buff is used in another function call. 487 00:28:42,860 --> 00:28:44,920 But what's the significance of copy buffer? 488 00:28:45,120 --> 00:28:47,300 So to a human reviewer, this makes a lot of sense. 489 00:28:47,420 --> 00:28:49,340 Probably it's like stir copy, right? 490 00:28:49,940 --> 00:28:51,460 Static analysis tool doesn't have any idea 491 00:28:51,460 --> 00:28:53,160 unless it's got a rule for this function. 492 00:28:53,340 --> 00:28:55,320 So it needs to know that buff starting 493 00:28:55,320 --> 00:28:57,460 in the second parameter is going to the first parameter, 494 00:28:57,500 --> 00:28:59,200 and now if the second parameter is interesting, 495 00:28:59,400 --> 00:29:01,560 the first one is two after the function is called. 496 00:29:02,860 --> 00:29:05,080 And finally, we see new buff used 497 00:29:05,080 --> 00:29:08,200 in a call to exec, and the tool needs a rule 498 00:29:08,200 --> 00:29:10,020 to describe to it that that's a potential vulnerability, 499 00:29:10,320 --> 00:29:11,420 command injection in this case. 500 00:29:12,300 --> 00:29:13,580 That's the one at the bottom there. 501 00:29:16,860 --> 00:29:18,560 So we talked about following data 502 00:29:18,560 --> 00:29:21,500 flowing through the program, but order of operations 503 00:29:21,500 --> 00:29:23,460 and control flow through the program can be interesting, 504 00:29:23,640 --> 00:29:24,780 particularly you can imagine in cases 505 00:29:24,780 --> 00:29:26,420 like dealing with resources. 506 00:29:27,140 --> 00:29:29,060 So here's an example of a double free vulnerability, 507 00:29:29,300 --> 00:29:32,200 potentially, in this code on the side of the slide. 508 00:29:32,500 --> 00:29:34,160 We've got a while loop and an if block. 509 00:29:34,160 --> 00:29:36,460 There are various control flow paths 510 00:29:36,460 --> 00:29:37,920 that one could follow through this code. 511 00:29:38,180 --> 00:29:40,380 So one is, we don't enter the while loop, 512 00:29:40,440 --> 00:29:42,980 we don't enter the if block, no memory is freed at all. 513 00:29:43,040 --> 00:29:44,220 It's certainly not a double free vulnerability. 514 00:29:45,220 --> 00:29:46,760 The way you typically represent rules 515 00:29:46,760 --> 00:29:49,300 for control flow analysis is by modeling them 516 00:29:49,300 --> 00:29:49,780 as state machines. 517 00:29:50,160 --> 00:29:51,660 So you have various states that represent 518 00:29:51,660 --> 00:29:53,420 potential states the program can be in, 519 00:29:53,480 --> 00:29:55,700 or small components of the program can be in. 520 00:29:56,220 --> 00:29:58,140 And then you have transitions between those states 521 00:29:58,140 --> 00:30:00,640 that describe how you move from one state to another. 522 00:30:01,320 --> 00:30:04,020 So the rule on the other side of the slide has three states, 523 00:30:04,160 --> 00:30:06,080 two transitions that are relevant, 524 00:30:06,260 --> 00:30:07,640 which are on calls to free, 525 00:30:08,060 --> 00:30:10,420 and then self loops from the state back to itself 526 00:30:10,420 --> 00:30:11,360 on any other operation. 527 00:30:11,580 --> 00:30:13,800 So we only care about cases where we see a call to free. 528 00:30:14,840 --> 00:30:16,300 On this first path through the code, 529 00:30:16,420 --> 00:30:17,740 we stay in that initial state. 530 00:30:17,840 --> 00:30:19,540 We're just self looping on everything we see 531 00:30:19,540 --> 00:30:20,740 because there's never a call to free. 532 00:30:22,160 --> 00:30:24,300 Another path through the code is we enter the while loop 533 00:30:24,300 --> 00:30:26,340 and we don't enter either of the if blocks. 534 00:30:26,560 --> 00:30:28,060 So now we've seen a single call to free 535 00:30:28,060 --> 00:30:30,760 and we've transitioned from one state to another in our rule 536 00:30:30,760 --> 00:30:32,280 and then we've looped a couple times there 537 00:30:32,280 --> 00:30:33,280 on the other instructions 538 00:30:33,280 --> 00:30:34,380 that we weren't interested in. 539 00:30:35,520 --> 00:30:37,160 And finally, you can see where this is going. 540 00:30:37,300 --> 00:30:38,880 There's a third path through the code 541 00:30:38,880 --> 00:30:40,460 that involves going into the while loop, 542 00:30:40,540 --> 00:30:42,720 into the if block, hitting two calls to free, 543 00:30:43,300 --> 00:30:44,440 and we end up in an error state 544 00:30:44,440 --> 00:30:46,160 and that's when the tool's gonna report a bug to you. 545 00:30:48,580 --> 00:30:50,880 Customization of rules like this can be really useful 546 00:30:50,880 --> 00:30:53,040 for managing proprietary resources. 547 00:30:53,320 --> 00:30:54,800 So you've got a particular kind of resource 548 00:30:54,800 --> 00:30:56,320 that needs to be cleared up in a particular way. 549 00:30:56,420 --> 00:30:57,560 The tool may not know about that. 550 00:30:57,720 --> 00:30:59,700 You can model all that to the tool in advance. 551 00:31:03,280 --> 00:31:05,520 So where do static analysis tools typically go wrong? 552 00:31:05,760 --> 00:31:08,220 I mean, we talked about some of the upfront cost 553 00:31:08,220 --> 00:31:11,520 and some of the limitations in terms of what they can derive 554 00:31:11,520 --> 00:31:13,340 from the source code as opposed to the architecture, 555 00:31:13,340 --> 00:31:14,940 the context the program's gonna run in. 556 00:31:15,420 --> 00:31:16,900 But when it really comes down to it, 557 00:31:16,960 --> 00:31:19,500 what most people are concerned about are false positives 558 00:31:19,500 --> 00:31:22,180 in a lot of cases and false negatives in some other cases. 559 00:31:22,280 --> 00:31:24,200 So is the tool reporting things 560 00:31:24,200 --> 00:31:25,280 that aren't really vulnerabilities 561 00:31:25,860 --> 00:31:28,100 or is the tool missing things that really are? 562 00:31:28,460 --> 00:31:30,200 And these come down to a couple of factors 563 00:31:30,200 --> 00:31:32,360 that contribute to the likelihood of false positives 564 00:31:32,360 --> 00:31:33,060 and false negatives. 565 00:31:33,900 --> 00:31:36,400 One is an incomplete or inaccurate model of the program. 566 00:31:36,640 --> 00:31:38,080 So you link in an external library, 567 00:31:38,660 --> 00:31:40,260 get web input in the case earlier. 568 00:31:40,620 --> 00:31:42,580 The tool may or may not know what that is 569 00:31:42,580 --> 00:31:43,980 unless it has a rule to describe it. 570 00:31:44,040 --> 00:31:45,200 So it doesn't have source code for it. 571 00:31:45,240 --> 00:31:46,600 It doesn't know what something does. 572 00:31:46,820 --> 00:31:48,740 You can imagine that leading to both false positives 573 00:31:48,740 --> 00:31:49,560 and false negatives. 574 00:31:49,620 --> 00:31:50,820 You see it on both lists here. 575 00:31:52,520 --> 00:31:55,660 Another is how conservative or forgiving is the analysis? 576 00:31:56,040 --> 00:31:58,160 So how much, what's the burden of proof 577 00:31:58,160 --> 00:32:00,020 before the tool will report a vulnerability 578 00:32:00,020 --> 00:32:01,040 in a given context? 579 00:32:01,420 --> 00:32:02,660 Do I have to be able to 580 00:32:03,540 --> 00:32:05,040 prove that I think it's exploitable 581 00:32:05,500 --> 00:32:07,580 or did maybe I follow a function pointer 582 00:32:07,580 --> 00:32:09,220 which statically I couldn't quite tell 583 00:32:09,220 --> 00:32:11,720 but it's possible in a certain scenario at runtime 584 00:32:11,720 --> 00:32:12,900 that this might be a vulnerability. 585 00:32:13,780 --> 00:32:15,580 Depending on what the purpose of the tool is, 586 00:32:15,700 --> 00:32:17,680 tools optimize in one direction or another. 587 00:32:17,840 --> 00:32:18,980 So there are tools that are really targeted 588 00:32:18,980 --> 00:32:19,900 being bug finders. 589 00:32:19,940 --> 00:32:20,860 So they want to report things 590 00:32:20,860 --> 00:32:22,100 that are as accurate as possible. 591 00:32:22,300 --> 00:32:24,100 They tend to have pretty conservative analysis. 592 00:32:24,280 --> 00:32:27,480 So they're not going to report something 593 00:32:27,480 --> 00:32:28,600 unless they really think it's a bug. 594 00:32:29,000 --> 00:32:30,980 And then there are tools that are much more forgiving 595 00:32:30,980 --> 00:32:31,940 in terms of their analysis, 596 00:32:31,940 --> 00:32:32,840 because a false negative 597 00:32:32,840 --> 00:32:34,520 is really the most important thing for them. 598 00:32:35,400 --> 00:32:36,560 And the last one is the one 599 00:32:36,560 --> 00:32:37,680 I really want to call attention to today, 600 00:32:37,820 --> 00:32:39,120 which is missing rules. 601 00:32:39,560 --> 00:32:42,020 So that can affect the incomplete and inaccurate model 602 00:32:42,020 --> 00:32:42,520 of the program. 603 00:32:42,620 --> 00:32:43,680 These are kind of tied together. 604 00:32:44,040 --> 00:32:46,200 How much does the tool know about your environment 605 00:32:46,200 --> 00:32:47,460 beyond the source code? 606 00:32:47,780 --> 00:32:49,940 You can also use rules to convey some of the context 607 00:32:49,940 --> 00:32:51,400 and semantics of the program. 608 00:32:51,580 --> 00:32:52,560 So you can write a rule that says 609 00:32:52,560 --> 00:32:54,320 this function always returns a credit card number. 610 00:32:54,720 --> 00:32:56,780 In the code, it might just always be a string, 611 00:32:57,220 --> 00:32:59,120 but you can give it a little more information about it 612 00:32:59,120 --> 00:33:00,700 and then derive more value from it as well. 613 00:33:03,760 --> 00:33:04,760 So untapped potential. 614 00:33:05,160 --> 00:33:07,540 It's really about customization for static analysis. 615 00:33:07,820 --> 00:33:09,840 Too many people today are using static analysis tools 616 00:33:10,380 --> 00:33:11,040 out of the box. 617 00:33:11,160 --> 00:33:12,860 And we see a lot of people now putting energy 618 00:33:12,860 --> 00:33:15,340 into customizing fuzzing tools to their environment 619 00:33:15,340 --> 00:33:17,360 because it's clear that once you move beyond 620 00:33:17,360 --> 00:33:19,920 kind of a lot of the simple cases, old system software, 621 00:33:19,980 --> 00:33:21,780 you really need to put that customization in. 622 00:33:22,240 --> 00:33:24,700 Static analysis tools will give you some value out of the box. 623 00:33:24,940 --> 00:33:26,980 It's not as obvious that you need to take that next step 624 00:33:26,980 --> 00:33:28,380 and put energy into customizing them, 625 00:33:28,460 --> 00:33:29,640 but there's actually the potential 626 00:33:29,640 --> 00:33:31,160 to get quite a bit of value back out. 627 00:33:32,260 --> 00:33:34,740 So you can use customization to, as I said before, 628 00:33:34,980 --> 00:33:37,420 model the behavior of third party libraries that you're using 629 00:33:37,420 --> 00:33:39,800 or internal libraries that you precompile and then link in. 630 00:33:40,660 --> 00:33:42,520 You can also use it to describe semantics. 631 00:33:42,900 --> 00:33:45,540 You can use it to identify program specific vulnerabilities. 632 00:33:45,980 --> 00:33:47,780 And this is certainly getting back into the realm 633 00:33:47,780 --> 00:33:49,920 of the thing I was critiquing fuzzing on, 634 00:33:50,040 --> 00:33:52,600 which is doing too much customization in a given, 635 00:33:53,820 --> 00:33:58,320 specific to a given program, but the effort involved 636 00:33:58,320 --> 00:34:01,500 in one individual rule, a handful of individual rules, 637 00:34:01,940 --> 00:34:04,000 may very well be worthwhile in terms of the classes of bugs 638 00:34:04,000 --> 00:34:05,520 you can find, because if they're very applicable 639 00:34:05,520 --> 00:34:07,140 to a large code base that you work on, 640 00:34:07,300 --> 00:34:08,520 this could be worthwhile still. 641 00:34:11,620 --> 00:34:14,960 So I talked before about the implications of performance 642 00:34:14,960 --> 00:34:17,920 on runtime testing, which is the more complete your tests are, 643 00:34:18,060 --> 00:34:20,080 the likely, the longer your runtime is going to be. 644 00:34:20,600 --> 00:34:22,740 Static analysis doesn't necessarily have the same problem. 645 00:34:22,920 --> 00:34:24,420 So if you add a couple of those custom rules 646 00:34:24,420 --> 00:34:26,600 I talked about earlier, the runtime is basically going 647 00:34:26,600 --> 00:34:28,180 to be the same because it's primarily bounded 648 00:34:28,180 --> 00:34:30,300 by what the scope of the analysis is. 649 00:34:30,380 --> 00:34:31,280 So how much of the program 650 00:34:31,940 --> 00:34:34,140 is the analysis engine considering at any given time? 651 00:34:34,420 --> 00:34:36,280 And you've got early tools like RATS 652 00:34:36,280 --> 00:34:38,560 that basically consider a line of code at a time, 653 00:34:38,680 --> 00:34:40,240 and then you go all the way up through tools 654 00:34:40,240 --> 00:34:42,820 that consider modules, entire programs, 655 00:34:43,040 --> 00:34:44,680 or across process boundaries even. 656 00:34:45,180 --> 00:34:47,300 So you can make the right choice in your environment 657 00:34:47,300 --> 00:34:48,680 as to which of these is right, 658 00:34:49,300 --> 00:34:51,880 but no matter how much customization energy you put into it, 659 00:34:51,900 --> 00:34:53,320 you're not going to change that significantly. 660 00:34:53,580 --> 00:34:55,440 So the more energy you put into customizing the tool, 661 00:34:55,780 --> 00:34:57,500 your runtime is going to stay roughly static. 662 00:34:57,740 --> 00:35:00,520 So you don't get dinged for the effort you're putting into it. 663 00:35:02,900 --> 00:35:05,640 So to talk a little bit about the experiment we conducted, 664 00:35:06,840 --> 00:35:08,640 scale was obviously a problem here. 665 00:35:08,720 --> 00:35:11,440 We couldn't test five zillion input cases 666 00:35:11,440 --> 00:35:12,840 like the example I gave earlier. 667 00:35:13,140 --> 00:35:14,780 We needed something that was fairly scalable. 668 00:35:15,160 --> 00:35:18,560 So we chose a quick SMTPD. 669 00:35:18,740 --> 00:35:20,560 I can never say that, particularly in public, 670 00:35:21,020 --> 00:35:22,880 which is a couple-year-old male daemon. 671 00:35:23,000 --> 00:35:24,620 It's got some known vulnerabilities in it, 672 00:35:24,680 --> 00:35:25,900 not particularly large, written in C. 673 00:35:27,020 --> 00:35:28,380 And we picked a couple of tools. 674 00:35:28,620 --> 00:35:31,920 So I have to say, I work at Fortify, so that's the static analysis. 675 00:35:31,940 --> 00:35:34,040 This tool I chose because I have it sitting on my desk already. 676 00:35:34,240 --> 00:35:35,300 Could use a different one, too. 677 00:35:35,440 --> 00:35:37,700 I don't think it would have a significant impact in this study. 678 00:35:38,280 --> 00:35:41,380 And we chose the at-stake SMTP fuzzing tool 679 00:35:41,880 --> 00:35:43,720 because it was really customized to this environment. 680 00:35:43,980 --> 00:35:46,340 A lot of energy has been put into it, 681 00:35:46,740 --> 00:35:48,600 customizing it to this particular protocol, 682 00:35:48,780 --> 00:35:49,860 this particular type of application, 683 00:35:50,640 --> 00:35:53,760 as opposed to kind of a general file format fuzzer, let's say, 684 00:35:53,760 --> 00:35:54,360 or something like that. 685 00:35:55,280 --> 00:35:57,220 And we ran the tools, collected data, 686 00:35:57,400 --> 00:35:59,220 and tried to draw some conclusions from them. 687 00:36:00,740 --> 00:36:01,800 So what did we find? 688 00:36:02,680 --> 00:36:04,380 Four remotely exploitable vulnerabilities. 689 00:36:04,700 --> 00:36:06,460 Two buffer reflows, two format strings. 690 00:36:07,440 --> 00:36:09,180 These are known for several years, 691 00:36:09,260 --> 00:36:11,160 so I'm not letting anything out of the bag today. 692 00:36:11,780 --> 00:36:14,060 And then a bunch of other stuff having to do 693 00:36:14,060 --> 00:36:17,720 with local file system attacks, environment variable attacks, 694 00:36:18,020 --> 00:36:20,560 and so on, which, since this is installed, 695 00:36:20,740 --> 00:36:22,860 set UID root on most systems actually could be interesting. 696 00:36:23,060 --> 00:36:24,960 But for the purpose of today, we're going to put most 697 00:36:24,960 --> 00:36:27,100 of the significance on the remotely exploitable things 698 00:36:27,100 --> 00:36:28,600 since that's what the fuzzing tools are really going 699 00:36:28,600 --> 00:36:30,140 to be capable of finding in this case. 700 00:36:30,720 --> 00:36:31,880 Although it's a good example 701 00:36:31,940 --> 00:36:33,080 that you could actually pick three 702 00:36:33,080 --> 00:36:35,260 or four different fuzzing tools and fuzz those different sources 703 00:36:35,260 --> 00:36:37,200 of input and maybe get a little more out of them. 704 00:36:37,340 --> 00:36:38,200 I didn't do that. 705 00:36:39,520 --> 00:36:40,500 So what were the results? 706 00:36:40,640 --> 00:36:42,200 We've got these four remotely exploitable bugs. 707 00:36:42,920 --> 00:36:44,700 Static analysis tool found all four of them. 708 00:36:44,940 --> 00:36:45,340 Hooray. 709 00:36:45,740 --> 00:36:47,760 Fuzzing tool found two very easily. 710 00:36:47,960 --> 00:36:49,160 So the first couple of test cases, 711 00:36:49,240 --> 00:36:50,500 they found these format string vulnerabilities 712 00:36:50,500 --> 00:36:52,080 because it's one of the things it looks for. 713 00:36:52,180 --> 00:36:54,800 It's going to fuzz every field in the SMTP traffic 714 00:36:55,640 --> 00:36:57,400 and insert format strings into them 715 00:36:57,400 --> 00:36:58,940 because that's something interesting we've seen in a lot 716 00:36:58,940 --> 00:37:00,120 of mail clients over the years. 717 00:37:00,500 --> 00:37:01,920 The buffer reflows, it didn't. 718 00:37:01,940 --> 00:37:05,880 The reason being that where the stack variables were located, 719 00:37:06,120 --> 00:37:07,520 there was too much padding around them. 720 00:37:07,620 --> 00:37:08,540 So there were a lot of other buffers. 721 00:37:08,700 --> 00:37:09,780 So although they actually, it's kind 722 00:37:09,780 --> 00:37:11,680 of like the path manipulation example I gave before. 723 00:37:12,420 --> 00:37:15,320 The tool did exercise the vulnerability in many cases 724 00:37:15,320 --> 00:37:16,800 and overrode variables on the stack. 725 00:37:17,140 --> 00:37:19,320 But changing those variables wasn't sufficient 726 00:37:19,320 --> 00:37:21,360 to cause the program to crash or to cause it 727 00:37:21,360 --> 00:37:22,120 to return differently. 728 00:37:23,740 --> 00:37:25,820 Therefore, the oracle was really insufficient. 729 00:37:26,140 --> 00:37:28,120 So the tool couldn't tell that the vulnerability was there 730 00:37:28,120 --> 00:37:30,240 and therefore the user, if they weren't already aware 731 00:37:30,240 --> 00:37:31,700 of the vulnerability, wouldn't be made aware 732 00:37:31,940 --> 00:37:32,860 of it by writing this test. 733 00:37:35,780 --> 00:37:38,120 So what are our conclusions about that experiment? 734 00:37:39,080 --> 00:37:41,120 It found exploitable vulnerabilities in, 735 00:37:41,820 --> 00:37:43,700 one qualification to the whole thing is, 736 00:37:43,840 --> 00:37:45,300 the scale of the program is such 737 00:37:45,300 --> 00:37:47,220 that measuring performance really wasn't useful. 738 00:37:47,520 --> 00:37:50,080 It's not large enough to say it took an hour to run the test 739 00:37:50,080 --> 00:37:51,460 or five hours to run the static analysis. 740 00:37:51,660 --> 00:37:52,880 So everything was very quick. 741 00:37:53,080 --> 00:37:56,540 But in its defense, it found exploitable format string 742 00:37:56,540 --> 00:37:58,480 vulnerabilities in the program in a matter of seconds. 743 00:37:58,580 --> 00:38:00,400 Fast as you can hit enter on the command line. 744 00:38:01,940 --> 00:38:04,480 It also missed critical remotely exploitable vulnerabilities 745 00:38:04,480 --> 00:38:05,540 that were within its reach. 746 00:38:05,860 --> 00:38:08,140 So I'm going to ding it a little bit for having missed things 747 00:38:08,140 --> 00:38:11,320 like file format bugs or environment variable bugs. 748 00:38:11,500 --> 00:38:12,540 But it's not really its fault. 749 00:38:12,740 --> 00:38:14,260 It only was talking network traffic. 750 00:38:14,580 --> 00:38:16,640 But it missed these buffer overflows which are tweaked 751 00:38:16,640 --> 00:38:19,160 by fields in the network traffic that's passed to the server. 752 00:38:19,300 --> 00:38:20,080 It should have found these. 753 00:38:20,260 --> 00:38:22,380 These are something that the user would have expected it 754 00:38:22,380 --> 00:38:22,760 to find. 755 00:38:24,640 --> 00:38:27,380 And although it didn't affect any bugs in this program 756 00:38:27,380 --> 00:38:28,820 because there weren't any masked 757 00:38:28,820 --> 00:38:31,920 by significantly complex conditionals, you can easily, 758 00:38:31,920 --> 00:38:35,740 easily imagine a case where a particular bug requires two 759 00:38:35,740 --> 00:38:38,440 different header fields to be put in a mail request, 760 00:38:38,720 --> 00:38:42,280 a value X and value Y, and then have certain behavior. 761 00:38:43,180 --> 00:38:45,700 This tool was fuzzing one input field at a time 762 00:38:45,700 --> 00:38:48,500 with a long list of variable inputs and would never get 763 00:38:48,500 --> 00:38:50,800 to that complex case of what if this had this value 764 00:38:50,800 --> 00:38:51,680 and that had that value. 765 00:38:55,300 --> 00:38:57,140 So there are definitely some advantages. 766 00:38:57,760 --> 00:38:59,780 Fuzzing is a lot less involved in static analysis. 767 00:39:00,220 --> 00:39:01,640 I am not an expert. 768 00:39:01,920 --> 00:39:03,720 I'm just a user of fuzzing tools, got this up and running. 769 00:39:03,820 --> 00:39:05,080 Once I got the mail server running, 770 00:39:05,180 --> 00:39:08,580 which took me a couple of days, very, very quickly, compiled it, 771 00:39:08,600 --> 00:39:11,700 ran it, found bugs in half an hour, easily start to finish. 772 00:39:12,340 --> 00:39:15,260 Not a hard thing to ask someone testing software to do. 773 00:39:15,400 --> 00:39:17,540 An easy way to find low-hanging fruit, good idea. 774 00:39:19,120 --> 00:39:20,920 You get a lot of context for free. 775 00:39:21,120 --> 00:39:23,400 So the tool, depending on how specialized it is 776 00:39:23,400 --> 00:39:25,420 into the environment that the program is going to be used in, 777 00:39:26,020 --> 00:39:27,960 is going to have a lot of context baked into it. 778 00:39:28,060 --> 00:39:31,780 So the fuzzing tool I was using is a mail fuzzing tool. 779 00:39:31,920 --> 00:39:33,240 So it's sending things related to mail, 780 00:39:33,420 --> 00:39:34,640 headers that you would expect to see. 781 00:39:34,860 --> 00:39:36,640 You get a lot of the context that you would expect 782 00:39:36,640 --> 00:39:39,600 from an actual use case for the software in a real environment. 783 00:39:39,840 --> 00:39:41,680 Whereas static analysis isn't going to have any 784 00:39:41,680 --> 00:39:42,360 of that understanding. 785 00:39:43,800 --> 00:39:46,200 And finally, it's great because what I ended 786 00:39:46,200 --> 00:39:48,940 up with was this string caused the program to crash. 787 00:39:49,240 --> 00:39:51,480 Now I can send that to whoever wants to fix the bug 788 00:39:51,480 --> 00:39:53,160 and say very easily, there's clearly a bug, 789 00:39:53,300 --> 00:39:54,140 just run it this way. 790 00:39:57,040 --> 00:39:59,740 On the static analysis side, we get the benefit of thoroughness. 791 00:39:59,920 --> 00:40:01,900 So we were able 792 00:40:01,920 --> 00:40:04,200 to identify those buffer flows in the case that we looked at. 793 00:40:04,260 --> 00:40:06,180 Because we're considering every path through the code. 794 00:40:06,260 --> 00:40:07,980 We're considering every potential problem, 795 00:40:08,140 --> 00:40:10,660 whether it evidences itself from the outside or not, 796 00:40:10,780 --> 00:40:12,620 regardless of what the Oracle might be 797 00:40:12,620 --> 00:40:13,480 from a fuzzing standpoint. 798 00:40:14,820 --> 00:40:18,020 You get to handle nested conditionals and hard 799 00:40:18,020 --> 00:40:19,360 to reach states for free. 800 00:40:19,600 --> 00:40:21,220 Because the static analysis tool is going 801 00:40:21,220 --> 00:40:23,300 to assume any possible input. 802 00:40:23,540 --> 00:40:26,080 And that can certainly result in false positives in some cases. 803 00:40:26,100 --> 00:40:27,940 Because some of those inputs may not actually be plausible. 804 00:40:28,800 --> 00:40:31,740 But much better in some cases to come at it from the completeness 805 00:40:31,920 --> 00:40:33,120 and if you're really going for assurance, 806 00:40:33,260 --> 00:40:36,960 you want to find all the bugs, then slowly inching towards that 807 00:40:36,960 --> 00:40:38,860 and at the same time increasing the length of your tests. 808 00:40:41,120 --> 00:40:42,500 Doesn't require running the code 809 00:40:42,500 --> 00:40:45,260 and it only requires however much time it requires 810 00:40:45,260 --> 00:40:47,280 for the analysis to consider all of these paths. 811 00:40:47,560 --> 00:40:49,760 So you get all of them at the same time for the same cost 812 00:40:49,760 --> 00:40:50,820 from a run time standpoint. 813 00:40:51,680 --> 00:40:54,700 And as you put more energy into tuning it to your environment 814 00:40:54,700 --> 00:40:56,580 or your types of software, you're not going 815 00:40:56,580 --> 00:40:57,640 to increase that run time. 816 00:41:00,540 --> 00:41:01,820 Finally, it doesn't depend 817 00:41:01,920 --> 00:41:02,520 on an oracle. 818 00:41:02,700 --> 00:41:05,240 So the example I gave with the buffer overflow before is, 819 00:41:06,240 --> 00:41:07,980 it's going to look for what it thinks are problems 820 00:41:07,980 --> 00:41:09,180 at the source code level regardless 821 00:41:09,180 --> 00:41:11,060 of how they're actually going to be evidenced from the outside. 822 00:41:11,260 --> 00:41:13,900 So it's not dependent on what interfaces it has access to. 823 00:41:14,000 --> 00:41:15,920 Is it coming at it from the web or from the file system? 824 00:41:16,640 --> 00:41:18,780 Did it overwrite one of my system files and so on? 825 00:41:19,100 --> 00:41:21,140 It's going to look at what is the code actually doing 826 00:41:21,140 --> 00:41:22,900 and do I think that's a problem? 827 00:41:26,000 --> 00:41:28,660 So to summarize, when we're talking about finding bugs, 828 00:41:29,320 --> 00:41:31,340 it's not clear which technique you'd want to use. 829 00:41:31,340 --> 00:41:32,800 When you're talking about finding security problems, 830 00:41:33,120 --> 00:41:35,920 I think static analysis is spot on because it's really going 831 00:41:35,920 --> 00:41:38,400 for I want to have a complete view of the application. 832 00:41:38,760 --> 00:41:41,680 I want to guarantee that rather than inching towards it. 833 00:41:41,880 --> 00:41:44,100 And I want to report as many problems as I can. 834 00:41:46,260 --> 00:41:48,460 Important attributes when choosing a static analysis tool. 835 00:41:48,540 --> 00:41:49,880 You need to make sure it supports your languages. 836 00:41:50,100 --> 00:41:52,460 That's back to the example of a fuzzing tool doesn't need 837 00:41:52,460 --> 00:41:53,040 to worry about that. 838 00:41:53,100 --> 00:41:54,760 This is a new challenge when you're dealing 839 00:41:54,760 --> 00:41:55,440 with static analysis. 840 00:41:56,260 --> 00:41:58,320 You want to make sure you have the right analysis techniques 841 00:41:58,320 --> 00:42:00,840 so you can do prioritization as opposed to those early tools. 842 00:42:01,340 --> 00:42:03,000 You definitely want to have the right rule set. 843 00:42:03,200 --> 00:42:05,180 And this is somewhere that last bullet comes in. 844 00:42:05,320 --> 00:42:06,460 You should be building on that. 845 00:42:06,520 --> 00:42:08,020 Don't just use what the tool comes with. 846 00:42:09,000 --> 00:42:09,860 Performance is important. 847 00:42:10,160 --> 00:42:12,640 So if it takes two weeks to begin with 848 00:42:12,640 --> 00:42:14,860 and it always takes two weeks and never takes any longer, 849 00:42:15,020 --> 00:42:16,100 that's probably not acceptable. 850 00:42:16,340 --> 00:42:18,020 You need to find one that will work for your process 851 00:42:18,020 --> 00:42:19,260 in terms of running reviews. 852 00:42:20,600 --> 00:42:22,760 And something we didn't get to talk about today 853 00:42:22,760 --> 00:42:24,560 but that's really critical is results management. 854 00:42:24,940 --> 00:42:26,660 So the tool might report 100 issues. 855 00:42:26,960 --> 00:42:29,180 It might prioritize those some coming out of the engine. 856 00:42:29,400 --> 00:42:31,060 How is it going to present those to the user? 857 00:42:31,340 --> 00:42:32,940 How is it going to let the user review those issues 858 00:42:32,940 --> 00:42:34,380 and give them as much information to understand 859 00:42:34,380 --> 00:42:36,100 what the code is doing as possible? 860 00:42:36,360 --> 00:42:39,680 This is really critical in terms of you guys actually looking 861 00:42:39,680 --> 00:42:40,920 at the code and figuring out what bugs are. 862 00:42:41,960 --> 00:42:44,520 And the point I hope I've been harping on enough today 863 00:42:44,520 --> 00:42:46,000 is customize, customize, customize. 864 00:42:46,460 --> 00:42:48,220 It's worth putting energy into it 865 00:42:48,220 --> 00:42:50,220 because you're not shooting yourself in the foot 866 00:42:50,220 --> 00:42:51,960 by increasing the running time and you're really likely 867 00:42:51,960 --> 00:42:54,740 to find more bugs, more bugs that are relevant to you 868 00:42:54,740 --> 00:42:57,580 and more bugs that depend or that fill in for some 869 00:42:57,580 --> 00:42:59,140 of the weaknesses of the technology originally 870 00:42:59,680 --> 00:43:00,460 such as context 871 00:43:00,460 --> 00:43:01,600 and program semantics. 872 00:43:03,720 --> 00:43:05,080 I'll put a PDF of this up. 873 00:43:05,400 --> 00:43:07,280 There are slides with your CD 874 00:43:07,280 --> 00:43:08,720 but I've changed them around a little bit. 875 00:43:08,920 --> 00:43:11,120 So if you want to get the new things, here they are. 876 00:43:11,260 --> 00:43:12,980 If you don't care so much about the small changes, 877 00:43:13,060 --> 00:43:14,040 not a big deal. 878 00:43:14,620 --> 00:43:16,500 Feel free to send me an email if you want to disagree 879 00:43:16,500 --> 00:43:18,900 with anything I said today, talk about any of this stuff. 880 00:43:19,080 --> 00:43:19,680 I'm really eager. 881 00:43:19,820 --> 00:43:21,460 I enjoy talking to interesting people. 882 00:43:21,700 --> 00:43:23,320 So if you're not interesting, maybe don't talk to me. 883 00:43:24,100 --> 00:43:26,340 And I have to give a pitch for, I was really excited. 884 00:43:26,420 --> 00:43:28,300 This gentleman in the front row has a copy of my book. 885 00:43:28,460 --> 00:43:30,100 It's one of the only ones I've seen here 886 00:43:30,100 --> 00:43:32,020 because unfortunately it's a white hat book. 887 00:43:32,120 --> 00:43:34,080 So it's about how to write secure software, 888 00:43:34,220 --> 00:43:35,900 not how to break into software. 889 00:43:36,060 --> 00:43:38,320 So Black Hat and DEF CON, not the prime audiences 890 00:43:38,320 --> 00:43:40,780 but hopefully some of you will find some interest in it 891 00:43:40,780 --> 00:43:42,840 or at least want to know what the guys on the other side 892 00:43:42,840 --> 00:43:43,500 of the fence are doing. 893 00:43:44,060 --> 00:43:44,780 Thanks very much. 894 00:43:44,860 --> 00:43:45,760 I appreciate your time today.