1 00:00:03,090 --> 00:00:06,799 [Music] 2 00:00:06,799 --> 00:00:09,019 thank you 3 00:00:09,019 --> 00:00:12,960 hi I hope you had hope you are not very 4 00:00:12,960 --> 00:00:14,940 much hungover after this is the third 5 00:00:14,940 --> 00:00:16,920 day of the conference so I guess 6 00:00:16,920 --> 00:00:19,800 people can be a little bit tired 7 00:00:19,800 --> 00:00:21,539 can you hear me well 8 00:00:21,539 --> 00:00:24,060 ah thank you 9 00:00:24,060 --> 00:00:27,720 okay a few words about myself 10 00:00:27,720 --> 00:00:30,180 this is like a living proof that I can 11 00:00:30,180 --> 00:00:34,320 also wear a shirt if forced to do so 12 00:00:34,320 --> 00:00:36,000 so you can find me on LinkedIn when I 13 00:00:36,000 --> 00:00:37,920 have lots of connections you can also 14 00:00:37,920 --> 00:00:39,600 find me on Twitter when I don't have 15 00:00:39,600 --> 00:00:41,879 that many but if you would take a look 16 00:00:41,879 --> 00:00:43,739 at who those people are you will see 17 00:00:43,739 --> 00:00:45,600 that this is fairly elite club so I 18 00:00:45,600 --> 00:00:48,180 encourage you all to join this elite 19 00:00:48,180 --> 00:00:49,680 club 20 00:00:49,680 --> 00:00:52,920 and a little bit of self-promotion I 21 00:00:52,920 --> 00:00:55,620 started small projects when I try to 22 00:00:55,620 --> 00:00:57,059 like teach people about application 23 00:00:57,059 --> 00:00:58,860 security if you would like to take a 24 00:00:58,860 --> 00:01:00,840 look I would be very happy 25 00:01:00,840 --> 00:01:03,180 but okay you came here for something 26 00:01:03,180 --> 00:01:05,880 else and this something else is a story 27 00:01:05,880 --> 00:01:07,680 that I have to use so let me tell you a 28 00:01:07,680 --> 00:01:08,880 story 29 00:01:08,880 --> 00:01:10,760 this is gonna be a story 30 00:01:10,760 --> 00:01:14,220 about going down the rabbit hole to find 31 00:01:14,220 --> 00:01:16,260 new attack surfaces 32 00:01:16,260 --> 00:01:18,840 and I would like to today encourage you 33 00:01:18,840 --> 00:01:23,220 to take a similar uh Journey with 34 00:01:23,220 --> 00:01:24,900 software that you are responsible for 35 00:01:24,900 --> 00:01:28,140 because I believe that there is a 36 00:01:28,140 --> 00:01:29,640 likelihood that you're gonna find 37 00:01:29,640 --> 00:01:31,619 similar things that I have found when I 38 00:01:31,619 --> 00:01:33,960 I did this 39 00:01:33,960 --> 00:01:36,500 so first uh 40 00:01:36,500 --> 00:01:39,420 will be yeah our industry has the thing 41 00:01:39,420 --> 00:01:41,880 for skulls does it so I try to indulge 42 00:01:41,880 --> 00:01:43,619 you here 43 00:01:43,619 --> 00:01:44,340 um 44 00:01:44,340 --> 00:01:46,020 so we'll be looking for a pattern of 45 00:01:46,020 --> 00:01:48,840 death in in our application so what what 46 00:01:48,840 --> 00:01:51,000 it's gonna be so first 47 00:01:51,000 --> 00:01:53,700 ingredient of the pattern of death is 48 00:01:53,700 --> 00:01:55,799 going to be untrusted input no big 49 00:01:55,799 --> 00:01:57,600 surprises there right 50 00:01:57,600 --> 00:01:59,820 secondly we'll be looking for an input 51 00:01:59,820 --> 00:02:01,799 that will be accepting complex data 52 00:02:01,799 --> 00:02:03,840 structures so by complex data structures 53 00:02:03,840 --> 00:02:05,579 I mean exactly what a like computer 54 00:02:05,579 --> 00:02:08,038 science 101 would Define it right so 55 00:02:08,038 --> 00:02:10,679 files and any anything that is not 56 00:02:10,679 --> 00:02:14,400 simple so if you your application allows 57 00:02:14,400 --> 00:02:18,000 to for instance import data from XML 58 00:02:18,000 --> 00:02:22,560 file or allows to to upload an image or 59 00:02:22,560 --> 00:02:24,300 any kind of a file attachment this is 60 00:02:24,300 --> 00:02:27,060 going to be complex data structure 61 00:02:27,060 --> 00:02:28,700 so the Third 62 00:02:28,700 --> 00:02:33,060 uh necessary ingredient here is that 63 00:02:33,060 --> 00:02:35,099 this component who's gonna touch this 64 00:02:35,099 --> 00:02:36,599 complex data structure is going to be 65 00:02:36,599 --> 00:02:38,640 written in memorand save language so I'm 66 00:02:38,640 --> 00:02:41,099 thinking about C or C plus plus because 67 00:02:41,099 --> 00:02:42,480 I don't think there are people around 68 00:02:42,480 --> 00:02:45,780 who developing assembly anymore 69 00:02:45,780 --> 00:02:49,500 and finally the set component probably 70 00:02:49,500 --> 00:02:53,580 was not a security assessed by by a 71 00:02:53,580 --> 00:02:55,800 security professional before 72 00:02:55,800 --> 00:02:59,400 and you might think that this is not 73 00:02:59,400 --> 00:03:02,220 happening very often but I want to 74 00:03:02,220 --> 00:03:05,280 convince you now that it is super likely 75 00:03:05,280 --> 00:03:07,620 that this kind of patterns are present 76 00:03:07,620 --> 00:03:10,019 in the software that you are responsible 77 00:03:10,019 --> 00:03:12,959 for let's take a quick look at other 78 00:03:12,959 --> 00:03:15,659 dose so untrusted input if you are 79 00:03:15,659 --> 00:03:17,819 dealing with web applications basically 80 00:03:17,819 --> 00:03:19,200 most of your inputs are going to be 81 00:03:19,200 --> 00:03:20,940 untrusted inputs 82 00:03:20,940 --> 00:03:23,340 accepting complex data structures again 83 00:03:23,340 --> 00:03:25,620 it's just enough that you allow for 84 00:03:25,620 --> 00:03:29,099 instance for users to upload a avatar or 85 00:03:29,099 --> 00:03:31,440 a picture and and that's it or any kind 86 00:03:31,440 --> 00:03:32,640 of order 87 00:03:32,640 --> 00:03:33,630 file 88 00:03:33,630 --> 00:03:35,120 [Music] 89 00:03:35,120 --> 00:03:38,159 I will spend a little bit more on on the 90 00:03:38,159 --> 00:03:39,860 third and the fourth 91 00:03:39,860 --> 00:03:42,920 points here because 92 00:03:42,920 --> 00:03:46,620 let's first of all I'm older than I look 93 00:03:46,620 --> 00:03:49,260 and like in my generation it was normal 94 00:03:49,260 --> 00:03:51,000 for people when they started to learn 95 00:03:51,000 --> 00:03:52,980 development to start with low-level 96 00:03:52,980 --> 00:03:55,739 languages CC plus plus assembly my first 97 00:03:55,739 --> 00:03:58,019 computer was Commodore 64 by the way so 98 00:03:58,019 --> 00:03:59,580 if you didn't know assembly you couldn't 99 00:03:59,580 --> 00:04:01,440 write anything that that was 100 00:04:01,440 --> 00:04:05,400 sufficiently fast but I found that like 101 00:04:05,400 --> 00:04:06,900 the new wave of developers they 102 00:04:06,900 --> 00:04:09,120 basically start with python and and they 103 00:04:09,120 --> 00:04:12,299 never learn C C plus plus and therefore 104 00:04:12,299 --> 00:04:14,340 they are not familiar with the kind of 105 00:04:14,340 --> 00:04:16,738 challenges that you have in in those 106 00:04:16,738 --> 00:04:18,120 languages 107 00:04:18,120 --> 00:04:19,858 but on the other hand 108 00:04:19,858 --> 00:04:22,800 this is the hard reality that we have 109 00:04:22,800 --> 00:04:25,100 you know 110 00:04:26,580 --> 00:04:28,740 and it's not just python it's basically 111 00:04:28,740 --> 00:04:31,560 every high level language uh it's 112 00:04:31,560 --> 00:04:34,380 fantastic it's generally memory safe by 113 00:04:34,380 --> 00:04:37,740 Design which is fantastic but it's based 114 00:04:37,740 --> 00:04:39,960 on memory unsafe languages and you can 115 00:04:39,960 --> 00:04:42,199 find them everywhere 116 00:04:42,199 --> 00:04:45,300 so let's 117 00:04:45,300 --> 00:04:47,400 take a look at this for instance so I 118 00:04:47,400 --> 00:04:49,199 started with python as an example but 119 00:04:49,199 --> 00:04:50,820 let's keep in mind that it's gonna be 120 00:04:50,820 --> 00:04:52,759 true for probably every other 121 00:04:52,759 --> 00:04:55,800 high level language out there 122 00:04:55,800 --> 00:04:59,820 so see it's uh python itself the 123 00:04:59,820 --> 00:05:01,500 reference implementation of python is 124 00:05:01,500 --> 00:05:03,900 called C Python and it's called this way 125 00:05:03,900 --> 00:05:06,120 because it's written in C 126 00:05:06,120 --> 00:05:08,880 and as you can see in the repository of 127 00:05:08,880 --> 00:05:11,340 python around one third of the codes 128 00:05:11,340 --> 00:05:13,919 there is written in C and many popular 129 00:05:13,919 --> 00:05:16,139 libraries have substantial amount of 130 00:05:16,139 --> 00:05:18,479 code written in C or C plus plus I gave 131 00:05:18,479 --> 00:05:21,540 you several examples here but you you 132 00:05:21,540 --> 00:05:25,560 can look at the components that you are 133 00:05:25,560 --> 00:05:26,820 using in your 134 00:05:26,820 --> 00:05:30,780 companies or or in the software that you 135 00:05:30,780 --> 00:05:32,699 are particularly interested in and you 136 00:05:32,699 --> 00:05:34,199 will you will find something very 137 00:05:34,199 --> 00:05:35,820 similar you will find that a lot of code 138 00:05:35,820 --> 00:05:39,840 is in fact written in CRC plus plus and 139 00:05:39,840 --> 00:05:42,240 the python is only used as a glue 140 00:05:42,240 --> 00:05:44,400 language for them 141 00:05:44,400 --> 00:05:46,380 and the security consequences of that 142 00:05:46,380 --> 00:05:49,199 are interesting right because we have on 143 00:05:49,199 --> 00:05:51,060 one hand developers who have never been 144 00:05:51,060 --> 00:05:53,160 taught to deal with memory safety issues 145 00:05:53,160 --> 00:05:56,639 because on the first lesson of python or 146 00:05:56,639 --> 00:05:58,560 if they ever had any kind of like python 147 00:05:58,560 --> 00:06:01,020 security introduction it would be said 148 00:06:01,020 --> 00:06:03,300 that you you don't have to take take 149 00:06:03,300 --> 00:06:06,240 care about memory not just safety but 150 00:06:06,240 --> 00:06:07,979 basically all kinds of memory issues 151 00:06:07,979 --> 00:06:10,919 because python deals that it deals with 152 00:06:10,919 --> 00:06:13,199 that for you right 153 00:06:13,199 --> 00:06:15,539 uh yeah but in reality it could be 154 00:06:15,539 --> 00:06:19,380 slightly worse so uh so that's like the 155 00:06:19,380 --> 00:06:21,419 first part of my talk I I want to 156 00:06:21,419 --> 00:06:24,120 convince you that even though you might 157 00:06:24,120 --> 00:06:26,039 be using or your developers might be 158 00:06:26,039 --> 00:06:27,900 using the so-called memory safe 159 00:06:27,900 --> 00:06:30,720 languages you can still have memory safe 160 00:06:30,720 --> 00:06:33,539 issues uh in in your Stacks so what I 161 00:06:33,539 --> 00:06:35,819 would encourage you to do is to take a 162 00:06:35,819 --> 00:06:39,060 look at the inputs that you have 163 00:06:39,060 --> 00:06:42,360 and try to look for the pattern of that 164 00:06:42,360 --> 00:06:46,139 as I uh call it so attack you analyze 165 00:06:46,139 --> 00:06:49,560 your attack surface and look at the what 166 00:06:49,560 --> 00:06:51,840 kind of inputs do you have and what 167 00:06:51,840 --> 00:06:55,319 happens with that data as they are going 168 00:06:55,319 --> 00:06:58,020 through the stack which exactly 169 00:06:58,020 --> 00:07:00,840 components are touching it 170 00:07:00,840 --> 00:07:03,840 and what kind of components are that 171 00:07:03,840 --> 00:07:07,199 have you written it are there old have 172 00:07:07,199 --> 00:07:09,840 you taken it from GitHub what is their 173 00:07:09,840 --> 00:07:11,400 dependencies because it could be a 174 00:07:11,400 --> 00:07:13,560 dependency of the dependency that could 175 00:07:13,560 --> 00:07:17,520 have some interesting vulnerabilities 176 00:07:17,520 --> 00:07:20,340 and of course check how old are they 177 00:07:20,340 --> 00:07:22,919 because I don't know how your developers 178 00:07:22,919 --> 00:07:25,080 are good with updating the dependencies 179 00:07:25,080 --> 00:07:28,259 the developers I am working with uh are 180 00:07:28,259 --> 00:07:30,660 not very good with that sorry to say and 181 00:07:30,660 --> 00:07:32,759 sometimes they need to be you know 182 00:07:32,759 --> 00:07:34,800 reminded that this is super important 183 00:07:34,800 --> 00:07:39,539 and if you are working on the red side 184 00:07:39,539 --> 00:07:41,520 of things then you can you can basically 185 00:07:41,520 --> 00:07:43,199 have vulnerabilities for free because 186 00:07:43,199 --> 00:07:45,599 all you have to do there is check what 187 00:07:45,599 --> 00:07:48,319 kind of reports were 188 00:07:48,319 --> 00:07:51,000 submitted to the 189 00:07:51,000 --> 00:07:53,639 to the libraries in question and you you 190 00:07:53,639 --> 00:07:55,680 basically can just write an exploit for 191 00:07:55,680 --> 00:07:57,180 that and you get to be the hero right 192 00:07:57,180 --> 00:07:59,940 who hacked the application 193 00:07:59,940 --> 00:08:03,660 but if let's say you are dealing with 194 00:08:03,660 --> 00:08:05,880 maybe less known cold there is there is 195 00:08:05,880 --> 00:08:08,280 no CV associated with it it still 196 00:08:08,280 --> 00:08:09,720 doesn't mean that it's secure right it 197 00:08:09,720 --> 00:08:12,060 just means that no one has tried to hack 198 00:08:12,060 --> 00:08:12,900 it 199 00:08:12,900 --> 00:08:15,000 and this is where we are going to the 200 00:08:15,000 --> 00:08:17,580 second part of this talk when I will 201 00:08:17,580 --> 00:08:19,919 tell you how to deal with this exact 202 00:08:19,919 --> 00:08:22,919 situation so let's say that you have 203 00:08:22,919 --> 00:08:25,620 analyzed your attack surface of your web 204 00:08:25,620 --> 00:08:27,419 applications that are written in 205 00:08:27,419 --> 00:08:30,300 something like python or Ruby or 206 00:08:30,300 --> 00:08:32,479 something like that and you have found 207 00:08:32,479 --> 00:08:35,640 libraries that are using memory and safe 208 00:08:35,640 --> 00:08:37,799 languages because this is exactly what I 209 00:08:37,799 --> 00:08:39,179 had 210 00:08:39,179 --> 00:08:41,399 what can you do then 211 00:08:41,399 --> 00:08:43,919 well you know that there is this thing 212 00:08:43,919 --> 00:08:46,920 called fuzzing which is uh like number 213 00:08:46,920 --> 00:08:48,060 one technique for finding 214 00:08:48,060 --> 00:08:49,980 vulnerabilities this is like a 215 00:08:49,980 --> 00:08:52,160 superpower to have and very important 216 00:08:52,160 --> 00:08:53,880 competence of every security 217 00:08:53,880 --> 00:08:55,860 professional I would say so I really 218 00:08:55,860 --> 00:08:58,980 encourage you guys to to learn it if you 219 00:08:58,980 --> 00:09:01,680 don't already or if you if you like have 220 00:09:01,680 --> 00:09:04,860 some basic uh let's say understanding of 221 00:09:04,860 --> 00:09:07,860 what it is then like work on this skill 222 00:09:07,860 --> 00:09:09,300 because this this is gonna work magic 223 00:09:09,300 --> 00:09:12,600 for you it's absolutely fantastic 224 00:09:12,600 --> 00:09:15,620 okay so uh I I 225 00:09:15,620 --> 00:09:17,580 have a special relationship with 226 00:09:17,580 --> 00:09:19,560 mathematics a kind of similar to my 227 00:09:19,560 --> 00:09:22,140 relationship with women I don't 228 00:09:22,140 --> 00:09:23,940 understand much but I appreciate the 229 00:09:23,940 --> 00:09:26,120 beauty 230 00:09:26,820 --> 00:09:32,540 so I try to I try to like 231 00:09:32,540 --> 00:09:35,279 show you successful fuzzing as a form of 232 00:09:35,279 --> 00:09:37,200 mathematical equation so successful 233 00:09:37,200 --> 00:09:39,240 fuzzing consists of 234 00:09:39,240 --> 00:09:41,880 and you'll have like two tactical goals 235 00:09:41,880 --> 00:09:44,519 to achieve and one strategic goal so the 236 00:09:44,519 --> 00:09:46,980 first tactical goal is to achieve good 237 00:09:46,980 --> 00:09:48,420 coverage 238 00:09:48,420 --> 00:09:50,820 second tactical goal is to achieve 239 00:09:50,820 --> 00:09:52,620 sufficient speed 240 00:09:52,620 --> 00:09:56,100 and finally we have a strategic goal is 241 00:09:56,100 --> 00:09:58,800 to find actual bugs right so we need 242 00:09:58,800 --> 00:10:02,580 detection criteria for this and those 243 00:10:02,580 --> 00:10:06,779 are very measurable goals and I will 244 00:10:06,779 --> 00:10:08,640 give you three numbers that matter for a 245 00:10:08,640 --> 00:10:11,580 fuzzing campaign and those those numbers 246 00:10:11,580 --> 00:10:15,000 are going to be measuring how close how 247 00:10:15,000 --> 00:10:17,279 close you are to reaching those goals 248 00:10:17,279 --> 00:10:19,140 so the coverage typically will be 249 00:10:19,140 --> 00:10:22,500 counted in percentage of code covered I 250 00:10:22,500 --> 00:10:23,880 will speak a little bit more about that 251 00:10:23,880 --> 00:10:26,279 in future it could be also basic blocks 252 00:10:26,279 --> 00:10:27,720 if you are dealing with if you don't 253 00:10:27,720 --> 00:10:29,100 have access to source code you are 254 00:10:29,100 --> 00:10:30,540 dealing with 255 00:10:30,540 --> 00:10:34,080 assembly speed is going to be number of 256 00:10:34,080 --> 00:10:36,240 tests per second 257 00:10:36,240 --> 00:10:39,000 and detection criteria like the eventual 258 00:10:39,000 --> 00:10:41,160 kpi that you are going for is the number 259 00:10:41,160 --> 00:10:43,800 of unique bugs that you have found right 260 00:10:43,800 --> 00:10:46,019 so this is the 261 00:10:46,019 --> 00:10:48,360 formula for successful fuzzing and 262 00:10:48,360 --> 00:10:51,899 respective numbers that matter here 263 00:10:51,899 --> 00:10:53,940 okay so first let's take a look at 264 00:10:53,940 --> 00:10:56,420 coverage 265 00:10:56,940 --> 00:11:01,260 this is a short from a campaign that I 266 00:11:01,260 --> 00:11:04,440 did so there's a software that you can 267 00:11:04,440 --> 00:11:08,779 use to measure how much code have you 268 00:11:08,779 --> 00:11:11,720 covered with your 269 00:11:11,720 --> 00:11:14,820 fuzzing attack now I have a question for 270 00:11:14,820 --> 00:11:16,260 you guys do you think that those numbers 271 00:11:16,260 --> 00:11:19,459 here's are good or bad 272 00:11:22,920 --> 00:11:25,620 any 273 00:11:25,620 --> 00:11:30,180 but okay I have the saying that in in 274 00:11:30,180 --> 00:11:33,000 infosec for every general question the 275 00:11:33,000 --> 00:11:34,980 the answer is going to begin with it 276 00:11:34,980 --> 00:11:36,660 depends 277 00:11:36,660 --> 00:11:39,060 because it depends it could be horrible 278 00:11:39,060 --> 00:11:41,040 result in fact it could be a very good 279 00:11:41,040 --> 00:11:44,100 one it depends I I was dealing with very 280 00:11:44,100 --> 00:11:47,160 like sophisticated software that had a 281 00:11:47,160 --> 00:11:49,920 lot of inputs and it was basically 282 00:11:49,920 --> 00:11:51,720 impossible to cover it with a single 283 00:11:51,720 --> 00:11:55,260 fuzzing test so if you will be if you 284 00:11:55,260 --> 00:11:56,640 will ever try to fast something 285 00:11:56,640 --> 00:11:58,320 sophisticated like for instance a 286 00:11:58,320 --> 00:12:00,720 JavaScript engine it is completely 287 00:12:00,720 --> 00:12:04,200 impossible to to cover uh everything 288 00:12:04,200 --> 00:12:06,480 with one fuzzing campaign campaign 289 00:12:06,480 --> 00:12:08,519 because the software is simply to it has 290 00:12:08,519 --> 00:12:12,720 too many like Parts through it so if you 291 00:12:12,720 --> 00:12:15,000 even if the software is much simpler but 292 00:12:15,000 --> 00:12:16,920 has multiple inputs that each input is 293 00:12:16,920 --> 00:12:19,079 accepting different kind of data like 294 00:12:19,079 --> 00:12:21,480 one accepts let's say something that has 295 00:12:21,480 --> 00:12:23,700 to be grammatically sound then it's 296 00:12:23,700 --> 00:12:25,380 gonna it's gonna need a completely 297 00:12:25,380 --> 00:12:27,360 different approach that an input that 298 00:12:27,360 --> 00:12:29,940 accepts let's say integers and that's it 299 00:12:29,940 --> 00:12:31,100 right 300 00:12:31,100 --> 00:12:34,200 so what I want to say is that it's not 301 00:12:34,200 --> 00:12:36,120 that easy to say if your coverage is 302 00:12:36,120 --> 00:12:39,079 good or bad it depends on your let's say 303 00:12:39,079 --> 00:12:41,940 current priorities and what's what your 304 00:12:41,940 --> 00:12:43,980 like current approaches if you want to 305 00:12:43,980 --> 00:12:46,079 cover a specific module then of course 306 00:12:46,079 --> 00:12:47,639 the coverage of this module is going to 307 00:12:47,639 --> 00:12:50,459 be important for you achieving like 100 308 00:12:50,459 --> 00:12:53,700 percent coverage for a huge application 309 00:12:53,700 --> 00:12:56,040 is very difficult by the way guys who 310 00:12:56,040 --> 00:12:58,980 who all of you would tell me what is the 311 00:12:58,980 --> 00:13:01,139 code coverage of a fuzzing of Google 312 00:13:01,139 --> 00:13:02,820 Chrome 313 00:13:02,820 --> 00:13:05,519 do you know it 314 00:13:05,519 --> 00:13:10,740 25 okay who will give you more 315 00:13:10,740 --> 00:13:13,860 40 yeah it's around 40 overall yeah 40 316 00:13:13,860 --> 00:13:15,240 something I don't remember the exact 317 00:13:15,240 --> 00:13:16,860 number but just to give you an example 318 00:13:16,860 --> 00:13:19,260 that it's it's even when you have like 319 00:13:19,260 --> 00:13:21,839 much bigger security team that for 320 00:13:21,839 --> 00:13:22,880 instance 321 00:13:22,880 --> 00:13:26,399 I have you you it's super difficult to 322 00:13:26,399 --> 00:13:29,700 to get to like large numbers 323 00:13:29,700 --> 00:13:32,700 okay so uh at the end of the day what 324 00:13:32,700 --> 00:13:35,579 you have to do is manually review this 325 00:13:35,579 --> 00:13:37,560 kind of report and see if you are 326 00:13:37,560 --> 00:13:39,180 hitting the kind of code that you are 327 00:13:39,180 --> 00:13:42,600 that you want to hit and make make some 328 00:13:42,600 --> 00:13:44,820 adjustments because there are ways when 329 00:13:44,820 --> 00:13:47,279 in which you can like improve your 330 00:13:47,279 --> 00:13:49,740 coverage like for instance you can add 331 00:13:49,740 --> 00:13:52,260 specific test cases to Corpus of your 332 00:13:52,260 --> 00:13:55,320 fuzzing attack or maybe you you need to 333 00:13:55,320 --> 00:13:57,480 figure out a different mutation strategy 334 00:13:57,480 --> 00:14:01,019 or a different test phase generation 335 00:14:01,019 --> 00:14:04,260 strategy in fact and that's another 336 00:14:04,260 --> 00:14:06,180 slide that that's that that will show 337 00:14:06,180 --> 00:14:09,060 you how difficult it is to to get like 338 00:14:09,060 --> 00:14:12,060 100 coverage because for instance you're 339 00:14:12,060 --> 00:14:14,339 gonna have a code that handles some very 340 00:14:14,339 --> 00:14:16,980 very rare very Niche situations like 341 00:14:16,980 --> 00:14:19,339 some error messages 342 00:14:19,339 --> 00:14:23,459 error cases when like reaching them from 343 00:14:23,459 --> 00:14:25,560 like regular input could be very 344 00:14:25,560 --> 00:14:27,779 difficult because you don't cover 345 00:14:27,779 --> 00:14:29,339 everything like if you have like out of 346 00:14:29,339 --> 00:14:31,260 memory condition and it's there is a 347 00:14:31,260 --> 00:14:33,420 code that's covering that then you would 348 00:14:33,420 --> 00:14:36,420 need to take some special steps to to 349 00:14:36,420 --> 00:14:38,639 cover this code it's not like easily 350 00:14:38,639 --> 00:14:41,040 accessible 351 00:14:41,040 --> 00:14:44,940 okay so basically the the roads to good 352 00:14:44,940 --> 00:14:46,680 coverage is that you need to have a good 353 00:14:46,680 --> 00:14:49,500 test test case generation strategy and 354 00:14:49,500 --> 00:14:53,220 there are like at least two ways of uh 355 00:14:53,220 --> 00:14:55,740 going about that one is basically like 356 00:14:55,740 --> 00:14:57,899 the standard way which uh for instance 357 00:14:57,899 --> 00:15:00,720 my friend hardik Shah was delivering a 358 00:15:00,720 --> 00:15:03,480 fuzzing workshop on this very Defcon on 359 00:15:03,480 --> 00:15:06,360 the first two days uh is there anyone on 360 00:15:06,360 --> 00:15:09,000 the in the room who was on this Workshop 361 00:15:09,000 --> 00:15:11,279 maybe oh hello 362 00:15:11,279 --> 00:15:13,260 hello sir 363 00:15:13,260 --> 00:15:15,899 okay so I I'm sure he well he had two 364 00:15:15,899 --> 00:15:19,139 days right so so he got much more into 365 00:15:19,139 --> 00:15:20,820 the details of how to do that but 366 00:15:20,820 --> 00:15:23,459 basically uh in like broad Strokes the 367 00:15:23,459 --> 00:15:26,279 the idea of like the most typical way of 368 00:15:26,279 --> 00:15:27,839 going about fuzzing is to prepare 369 00:15:27,839 --> 00:15:31,620 so-called Corpus so Corpus is a like a 370 00:15:31,620 --> 00:15:34,260 collection of test cases that should be 371 00:15:34,260 --> 00:15:36,180 somewhat representative right so they 372 00:15:36,180 --> 00:15:38,399 should be hitting the main functionality 373 00:15:38,399 --> 00:15:41,000 of of the application and then you have 374 00:15:41,000 --> 00:15:43,740 mutators so-called right so mutation 375 00:15:43,740 --> 00:15:46,339 essentially is like taking one of the 376 00:15:46,339 --> 00:15:50,220 inputs from the Corpus and try and 377 00:15:50,220 --> 00:15:51,899 changing it somehow it could be like 378 00:15:51,899 --> 00:15:54,260 changing one byte flipping one bit 379 00:15:54,260 --> 00:15:57,660 adding something from the dictionary or 380 00:15:57,660 --> 00:15:59,820 there are all kinds of like random 381 00:15:59,820 --> 00:16:03,000 changes that could be applied to it 382 00:16:03,000 --> 00:16:07,139 uh and so if you want to improve your 383 00:16:07,139 --> 00:16:09,899 coverage then you can do it manually by 384 00:16:09,899 --> 00:16:11,820 simply adding test cases to the Corpus 385 00:16:11,820 --> 00:16:13,500 that will be hitting those particular 386 00:16:13,500 --> 00:16:17,399 lines of code that you are interested in 387 00:16:17,399 --> 00:16:19,860 but if you are into if your application 388 00:16:19,860 --> 00:16:22,980 is not is for instance taking something 389 00:16:22,980 --> 00:16:25,040 that has to be like grammatically sound 390 00:16:25,040 --> 00:16:28,139 like if you are attacking for instance 391 00:16:28,139 --> 00:16:30,120 SQL engine or JavaScript engine or 392 00:16:30,120 --> 00:16:31,320 something like that then you need 393 00:16:31,320 --> 00:16:33,240 something else because the approach with 394 00:16:33,240 --> 00:16:34,920 Corpus and mutation is not going to work 395 00:16:34,920 --> 00:16:36,720 and there is software like for instance 396 00:16:36,720 --> 00:16:39,959 Dharma done by Mozilla and and couple 397 00:16:39,959 --> 00:16:42,060 others which allows you to create a 398 00:16:42,060 --> 00:16:44,279 grammar and then this software will 399 00:16:44,279 --> 00:16:46,920 create test cases from this grammar that 400 00:16:46,920 --> 00:16:49,620 will be somewhat grammatically correct 401 00:16:49,620 --> 00:16:52,380 and this way you can because otherwise 402 00:16:52,380 --> 00:16:54,660 you know if the first line of the code 403 00:16:54,660 --> 00:16:57,839 is checking if the provided data is an 404 00:16:57,839 --> 00:17:01,500 exposed it's XML and there is a check if 405 00:17:01,500 --> 00:17:04,559 this XML is you know it has some like 406 00:17:04,559 --> 00:17:07,980 basic uh it passes some basic validity 407 00:17:07,980 --> 00:17:10,199 tests then you will be like testing 408 00:17:10,199 --> 00:17:12,839 those first couple of ifs very hard but 409 00:17:12,839 --> 00:17:14,459 nothing else right and this is not what 410 00:17:14,459 --> 00:17:16,939 you want to do 411 00:17:16,980 --> 00:17:18,299 okay 412 00:17:18,299 --> 00:17:21,900 let's move to speed we have a Need for 413 00:17:21,900 --> 00:17:24,059 Speed with fuzzing and we have it 414 00:17:24,059 --> 00:17:25,980 because fuzzing is essentially a Brute 415 00:17:25,980 --> 00:17:27,959 Force technique right so with brute 416 00:17:27,959 --> 00:17:29,640 forcing anything speed is super 417 00:17:29,640 --> 00:17:31,559 important 418 00:17:31,559 --> 00:17:34,559 and if you look at because another way 419 00:17:34,559 --> 00:17:36,179 of thinking about fuzzing and basically 420 00:17:36,179 --> 00:17:37,980 any kind of automated testing is that 421 00:17:37,980 --> 00:17:39,840 you want to explore this input space of 422 00:17:39,840 --> 00:17:42,120 a program right and this inputs it input 423 00:17:42,120 --> 00:17:44,419 space is going to be super large 424 00:17:44,419 --> 00:17:47,880 uh so it's uh like the the faster you 425 00:17:47,880 --> 00:17:51,059 can make your your uh faster the more 426 00:17:51,059 --> 00:17:52,740 likely is that you were gonna hit those 427 00:17:52,740 --> 00:17:58,080 cases that produce you uh bugs 428 00:17:58,080 --> 00:18:01,440 okay uh there's gonna be a quiz question 429 00:18:01,440 --> 00:18:03,600 I I showed those slides to one of my 430 00:18:03,600 --> 00:18:05,940 friends and he told me that this must be 431 00:18:05,940 --> 00:18:08,460 a picture of me when I still had her you 432 00:18:08,460 --> 00:18:10,980 know I never leave it friendship is such 433 00:18:10,980 --> 00:18:12,419 a beautiful thing 434 00:18:12,419 --> 00:18:15,900 and anyways so I'm referring here to a 435 00:18:15,900 --> 00:18:17,580 piece of mathematics 436 00:18:17,580 --> 00:18:20,280 and the question is if any of you can 437 00:18:20,280 --> 00:18:22,500 guess what kind of piece of mathematics 438 00:18:22,500 --> 00:18:24,360 that is 439 00:18:24,360 --> 00:18:26,940 there's a theorem mathematical theorem 440 00:18:26,940 --> 00:18:29,179 foreign 441 00:18:33,919 --> 00:18:38,000 the guy in the first row also 442 00:18:38,280 --> 00:18:40,020 yeah 443 00:18:40,020 --> 00:18:42,620 AC is 444 00:18:42,620 --> 00:18:45,179 these guys need socks 445 00:18:45,179 --> 00:18:47,160 okay 446 00:18:47,160 --> 00:18:49,559 so that is this thing called infinite 447 00:18:49,559 --> 00:18:51,780 monkey theorem so for those of you who 448 00:18:51,780 --> 00:18:53,460 don't know it the the idea is 449 00:18:53,460 --> 00:18:55,020 essentially if you take a monkey and you 450 00:18:55,020 --> 00:18:57,600 give it a typewriter it will eventually 451 00:18:57,600 --> 00:18:59,700 if of course if you give it enough time 452 00:18:59,700 --> 00:19:02,220 it will eventually type every single 453 00:19:02,220 --> 00:19:04,740 book in the world 454 00:19:04,740 --> 00:19:07,080 this is mathematics so you well there's 455 00:19:07,080 --> 00:19:09,539 this concept on Infinity that kind of 456 00:19:09,539 --> 00:19:11,640 plays a large role here and so we assume 457 00:19:11,640 --> 00:19:13,140 that the monkey of course will have like 458 00:19:13,140 --> 00:19:15,120 infinite lifetime 459 00:19:15,120 --> 00:19:18,000 anyways how does it apply to fuzzing uh 460 00:19:18,000 --> 00:19:19,200 because this is essentially the same 461 00:19:19,200 --> 00:19:21,539 thing the father is this monkey and it's 462 00:19:21,539 --> 00:19:24,419 gonna be figuring out new test cases so 463 00:19:24,419 --> 00:19:27,360 according to this uh theorem it will 464 00:19:27,360 --> 00:19:29,580 eventually figure out of course with 465 00:19:29,580 --> 00:19:31,020 some assumptions right so the first 466 00:19:31,020 --> 00:19:33,299 assumptions uh first assumption here is 467 00:19:33,299 --> 00:19:35,880 that we have figured out this coverage 468 00:19:35,880 --> 00:19:38,580 well right this is very important and 469 00:19:38,580 --> 00:19:40,620 second very important assumption is that 470 00:19:40,620 --> 00:19:42,559 we will we also figured that the 471 00:19:42,559 --> 00:19:45,000 detectability problem which I will speak 472 00:19:45,000 --> 00:19:47,280 about in a moment detectability is also 473 00:19:47,280 --> 00:19:49,140 very hard problem to fix but if those 474 00:19:49,140 --> 00:19:52,860 two problems are fixed then this fine 475 00:19:52,860 --> 00:19:55,980 gentleman kind of represents the truth 476 00:19:55,980 --> 00:19:57,960 that eventually you will find it but 477 00:19:57,960 --> 00:19:59,820 we're talking about speed here do we 478 00:19:59,820 --> 00:20:01,500 really have infinite time on our hands 479 00:20:01,500 --> 00:20:03,059 well I don't 480 00:20:03,059 --> 00:20:05,520 this is why we need something something 481 00:20:05,520 --> 00:20:07,620 better so this is a screenshot from from 482 00:20:07,620 --> 00:20:10,260 my campaign and in the beginning as you 483 00:20:10,260 --> 00:20:12,419 can see I was not very successful at 484 00:20:12,419 --> 00:20:15,380 making it fast unfortunately 485 00:20:15,380 --> 00:20:18,660 so I tried every trick in the book I I 486 00:20:18,660 --> 00:20:22,799 Googled all of the suggestions from Miho 487 00:20:22,799 --> 00:20:25,140 zalevsky also known as the original 488 00:20:25,140 --> 00:20:28,740 author of uh American fuzzy Loop which I 489 00:20:28,740 --> 00:20:31,020 use here a fantastic piece of software 490 00:20:31,020 --> 00:20:32,880 by the way I would recommend it 491 00:20:32,880 --> 00:20:35,700 so he had a number of ideas on how to 492 00:20:35,700 --> 00:20:37,679 make the software faster and 493 00:20:37,679 --> 00:20:40,320 unfortunately in my case like most of 494 00:20:40,320 --> 00:20:42,539 them didn't work very well I mean it was 495 00:20:42,539 --> 00:20:45,120 slightly faster but not the kind of like 496 00:20:45,120 --> 00:20:48,660 not like order of magnitude faster right 497 00:20:48,660 --> 00:20:53,760 so uh I one thing I I did try uh for a 498 00:20:53,760 --> 00:20:55,740 while until I understood that this is 499 00:20:55,740 --> 00:20:58,320 not gonna work with me uh is I try to 500 00:20:58,320 --> 00:20:59,940 decompose the software into smaller 501 00:20:59,940 --> 00:21:02,220 parts and fast them independently 502 00:21:02,220 --> 00:21:04,080 because that was also suggested as 503 00:21:04,080 --> 00:21:06,059 something very smart a smart thing to do 504 00:21:06,059 --> 00:21:07,919 but in this case unfortunately the 505 00:21:07,919 --> 00:21:10,559 software was very monolithic and it 506 00:21:10,559 --> 00:21:13,580 maintained a lot of like shared State 507 00:21:13,580 --> 00:21:16,260 and that state was like super difficult 508 00:21:16,260 --> 00:21:19,200 to Mock and I figured that okay if I 509 00:21:19,200 --> 00:21:21,000 tried really hard of course I could make 510 00:21:21,000 --> 00:21:23,580 I could decompose it eventually but the 511 00:21:23,580 --> 00:21:25,679 question is how many other bugs I would 512 00:21:25,679 --> 00:21:28,260 create and because then I would I would 513 00:21:28,260 --> 00:21:30,299 fight them of course but they wouldn't 514 00:21:30,299 --> 00:21:32,039 work in the original software so what's 515 00:21:32,039 --> 00:21:32,960 the point 516 00:21:32,960 --> 00:21:36,659 uh so this is why even though this 517 00:21:36,659 --> 00:21:38,520 approach is generally I really recommend 518 00:21:38,520 --> 00:21:40,500 it it only works with software that is 519 00:21:40,500 --> 00:21:42,840 kind of let's say modular and not not 520 00:21:42,840 --> 00:21:45,480 very monolithic so again if you want to 521 00:21:45,480 --> 00:21:47,940 try to fast JavaScript engines this 522 00:21:47,940 --> 00:21:50,340 software is not very 523 00:21:50,340 --> 00:21:52,879 question 524 00:21:53,659 --> 00:21:56,520 American father 525 00:21:56,520 --> 00:21:59,940 yes in the yellow letters 526 00:21:59,940 --> 00:22:01,860 yeah 527 00:22:01,860 --> 00:22:04,860 okay so what eventually worked in my 528 00:22:04,860 --> 00:22:09,179 case is uh so-called persistent mode 529 00:22:09,179 --> 00:22:10,159 again 530 00:22:10,159 --> 00:22:12,840 I cannot recommend it enough it's 531 00:22:12,840 --> 00:22:14,700 absolutely fantastic approach to fuzzing 532 00:22:14,700 --> 00:22:17,039 but in this case it was very difficult 533 00:22:17,039 --> 00:22:20,520 to to set up I I I I was not smart 534 00:22:20,520 --> 00:22:22,500 enough to do it but luckily there was a 535 00:22:22,500 --> 00:22:24,659 guy who was smart enough and he he did 536 00:22:24,659 --> 00:22:25,740 it 537 00:22:25,740 --> 00:22:28,980 hmm uh yeah so basically there is a way 538 00:22:28,980 --> 00:22:31,559 right if you cannot there are multiple 539 00:22:31,559 --> 00:22:33,179 approaches to this and you need to 540 00:22:33,179 --> 00:22:34,559 figure out which of them is going to 541 00:22:34,559 --> 00:22:37,260 work in your case 542 00:22:37,260 --> 00:22:39,539 so those are like the most important 543 00:22:39,539 --> 00:22:41,460 game changers when it comes to speed 544 00:22:41,460 --> 00:22:43,860 first of all access the source code you 545 00:22:43,860 --> 00:22:45,600 can fast anything you can fast software 546 00:22:45,600 --> 00:22:48,299 that that you do not have a source code 547 00:22:48,299 --> 00:22:50,400 for but this is going to be first of all 548 00:22:50,400 --> 00:22:53,220 much more difficult to set up and it's 549 00:22:53,220 --> 00:22:55,460 going to be very slow and also on the 550 00:22:55,460 --> 00:22:57,480 detectability side it's going to be 551 00:22:57,480 --> 00:23:00,360 difficult to uh way more you're gonna 552 00:23:00,360 --> 00:23:02,880 have fewer options to choose from 553 00:23:02,880 --> 00:23:06,000 a modular architecture helps a lot this 554 00:23:06,000 --> 00:23:07,159 is 555 00:23:07,159 --> 00:23:10,740 basically like when I look at very well 556 00:23:10,740 --> 00:23:14,340 set up projects they all use uh like 557 00:23:14,340 --> 00:23:17,280 multiple entries for fuzzing as opposed 558 00:23:17,280 --> 00:23:19,200 to having like one fuzzing session for 559 00:23:19,200 --> 00:23:20,940 the entire program this is good only 560 00:23:20,940 --> 00:23:23,340 when you have very small programs but 561 00:23:23,340 --> 00:23:25,679 the bigger it is the more it makes sense 562 00:23:25,679 --> 00:23:27,960 for having like multiple small fuzzers 563 00:23:27,960 --> 00:23:30,059 instead of one big one 564 00:23:30,059 --> 00:23:32,580 then persistent mode obviously this is 565 00:23:32,580 --> 00:23:36,659 super uh funding and parallelism so 566 00:23:36,659 --> 00:23:39,179 basically having multiple CPUs work at 567 00:23:39,179 --> 00:23:42,419 once AFL has this nice functionality 568 00:23:42,419 --> 00:23:45,659 that allows those independent fathers to 569 00:23:45,659 --> 00:23:48,600 share and compare notes kind of right so 570 00:23:48,600 --> 00:23:50,400 if any of them will figure out a new 571 00:23:50,400 --> 00:23:52,620 path throughout the program it will tell 572 00:23:52,620 --> 00:23:55,020 the others guys I found this you know 573 00:23:55,020 --> 00:23:57,539 you can also try it so this is like one 574 00:23:57,539 --> 00:24:00,240 way of using uh parallelism another one 575 00:24:00,240 --> 00:24:03,539 is and we'll cover this a little bit in 576 00:24:03,539 --> 00:24:05,640 a in in in the next section which is 577 00:24:05,640 --> 00:24:07,799 about detectability you can have 578 00:24:07,799 --> 00:24:10,799 different detectability criteria in a 579 00:24:10,799 --> 00:24:13,620 cluster so different fuzzers that run 580 00:24:13,620 --> 00:24:15,179 independently we'll be looking for the 581 00:24:15,179 --> 00:24:17,280 different kind of bugs and this will 582 00:24:17,280 --> 00:24:19,200 overall improve your chances of finding 583 00:24:19,200 --> 00:24:20,820 something significant 584 00:24:20,820 --> 00:24:23,280 so again it's important to have like a 585 00:24:23,280 --> 00:24:25,320 lot of bandwidth and the more CPUs you 586 00:24:25,320 --> 00:24:27,240 have the better off you are again 587 00:24:27,240 --> 00:24:29,760 computer science 101 I'm not sure if you 588 00:24:29,760 --> 00:24:33,360 guys if you like mathematics uh fun fact 589 00:24:33,360 --> 00:24:35,280 if you have infinite number of computers 590 00:24:35,280 --> 00:24:37,620 you will find and assuming all of the 591 00:24:37,620 --> 00:24:41,460 other conditions were were met then you 592 00:24:41,460 --> 00:24:43,140 will find all of the bugs within 593 00:24:43,140 --> 00:24:46,640 basically One Step so 594 00:24:47,340 --> 00:24:50,700 okay detection criteria 595 00:24:50,700 --> 00:24:52,620 and this is this is actually the most 596 00:24:52,620 --> 00:24:56,178 difficult bit I would say 597 00:24:56,340 --> 00:24:58,280 so let's say that we we have solved the 598 00:24:58,280 --> 00:25:01,500 we solved our tactical problems right so 599 00:25:01,500 --> 00:25:03,720 we figured out how to hit the parts of 600 00:25:03,720 --> 00:25:05,580 codes that we want to hit so we have 601 00:25:05,580 --> 00:25:08,340 coverage and we did what we could have 602 00:25:08,340 --> 00:25:11,100 to make this as fast as could be so we 603 00:25:11,100 --> 00:25:14,220 have solved speed so what else 604 00:25:14,220 --> 00:25:17,159 and well the problem is that the when 605 00:25:17,159 --> 00:25:18,900 compared to unit testing for instance 606 00:25:18,900 --> 00:25:21,720 right when you write a units test you 607 00:25:21,720 --> 00:25:24,120 simply make the program run with some 608 00:25:24,120 --> 00:25:25,980 input and then compare it to some 609 00:25:25,980 --> 00:25:27,960 magical value that you happen to know is 610 00:25:27,960 --> 00:25:30,120 true right that's super easy to set up 611 00:25:30,120 --> 00:25:34,500 but with others it's worse because you 612 00:25:34,500 --> 00:25:36,419 don't know all of the test cases that 613 00:25:36,419 --> 00:25:38,580 the father will figure out so also it's 614 00:25:38,580 --> 00:25:40,679 difficult to tell if the behavior of the 615 00:25:40,679 --> 00:25:42,539 program was correct or not 616 00:25:42,539 --> 00:25:45,299 so this is why detection detectability 617 00:25:45,299 --> 00:25:47,340 generally is a problem it's a it's a big 618 00:25:47,340 --> 00:25:48,360 one 619 00:25:48,360 --> 00:25:51,840 and when it comes to memory safety it's 620 00:25:51,840 --> 00:25:53,880 also a problem because software written 621 00:25:53,880 --> 00:25:55,740 in C or C plus plus it's not necessarily 622 00:25:55,740 --> 00:25:57,779 going to crash just before just because 623 00:25:57,779 --> 00:26:02,279 we entered uh an input that causes 624 00:26:02,279 --> 00:26:04,380 something that shouldn't shouldn't have 625 00:26:04,380 --> 00:26:06,419 happened software generally is quite 626 00:26:06,419 --> 00:26:10,200 resilient and we can we can like put 627 00:26:10,200 --> 00:26:12,720 some small buffer overflows to it and it 628 00:26:12,720 --> 00:26:14,820 will not crash and the only way the 629 00:26:14,820 --> 00:26:18,240 father knows that uh the back was hit is 630 00:26:18,240 --> 00:26:21,000 by itself the software crashing so this 631 00:26:21,000 --> 00:26:23,400 is like number one detection Criterion 632 00:26:23,400 --> 00:26:25,380 and there could be other ones like for 633 00:26:25,380 --> 00:26:27,659 instance you can be looking at timeouts 634 00:26:27,659 --> 00:26:29,700 and this way you can be looking at 635 00:26:29,700 --> 00:26:31,559 inputs that will cause the software to 636 00:26:31,559 --> 00:26:34,140 run particularly long so this could be 637 00:26:34,140 --> 00:26:38,460 like the Nile of service vector 638 00:26:39,299 --> 00:26:43,520 and of course there are other other ways 639 00:26:43,520 --> 00:26:46,799 which I will cover shortly so when it 640 00:26:46,799 --> 00:26:48,240 comes to memory safety this is what I 641 00:26:48,240 --> 00:26:50,279 was particularly after right because I I 642 00:26:50,279 --> 00:26:52,799 found a code written in C and this code 643 00:26:52,799 --> 00:26:55,580 was parsing untrusted input 644 00:26:55,580 --> 00:26:59,580 that you you could upload files to 645 00:26:59,580 --> 00:27:02,760 and so I was I was uh after memory 646 00:27:02,760 --> 00:27:04,740 safety member safety is a big problem I 647 00:27:04,740 --> 00:27:07,340 will not cover it like fully today 648 00:27:07,340 --> 00:27:10,919 but like the most uh important issues 649 00:27:10,919 --> 00:27:12,919 are like spatial 650 00:27:12,919 --> 00:27:15,299 issues so special issues are essentially 651 00:27:15,299 --> 00:27:18,360 out of bounds reads and rights so buffer 652 00:27:18,360 --> 00:27:21,179 overflows underflows and stuff like that 653 00:27:21,179 --> 00:27:23,760 and temporal temporal memory safety 654 00:27:23,760 --> 00:27:26,279 refers to use after freeze this is like 655 00:27:26,279 --> 00:27:29,220 number one bug in the industry when it 656 00:27:29,220 --> 00:27:31,020 comes to exploitation probably so if you 657 00:27:31,020 --> 00:27:32,880 would look like a typical browser 658 00:27:32,880 --> 00:27:35,279 exploit it will typically gonna it is 659 00:27:35,279 --> 00:27:37,500 typically gonna abuse after free 660 00:27:37,500 --> 00:27:40,380 and additional reads and undefined 661 00:27:40,380 --> 00:27:42,900 Behavior this is a thing in C and C plus 662 00:27:42,900 --> 00:27:46,080 plus and couple other things so how to 663 00:27:46,080 --> 00:27:49,559 improve the odds that the program that 664 00:27:49,559 --> 00:27:51,600 you are fuzzing is gonna crash on any of 665 00:27:51,600 --> 00:27:55,080 those there is a beautiful piece of 666 00:27:55,080 --> 00:27:57,539 technology called sanitizers so you have 667 00:27:57,539 --> 00:28:00,559 to like compile this program with 668 00:28:00,559 --> 00:28:03,600 appropriate sanitizer so for a special 669 00:28:03,600 --> 00:28:05,820 memory safety issues it's going to be 670 00:28:05,820 --> 00:28:09,600 other sanitizer also it will find some 671 00:28:09,600 --> 00:28:11,039 use after fees not all of them 672 00:28:11,039 --> 00:28:12,179 unfortunately 673 00:28:12,179 --> 00:28:14,400 also not not all buffer oversles because 674 00:28:14,400 --> 00:28:15,840 quite frankly there are some limitations 675 00:28:15,840 --> 00:28:19,020 to to these Technologies uh thread 676 00:28:19,020 --> 00:28:21,840 sanitizer is going to help you find 677 00:28:21,840 --> 00:28:25,919 um race conditions so and memory 678 00:28:25,919 --> 00:28:27,419 sanitizer is going to help you find 679 00:28:27,419 --> 00:28:29,220 uninitialized rates 680 00:28:29,220 --> 00:28:31,220 and this is what I said earlier about 681 00:28:31,220 --> 00:28:33,840 parallelism you can compile multiple 682 00:28:33,840 --> 00:28:36,720 versions of your Target and have the 683 00:28:36,720 --> 00:28:40,200 fathers test for it concurrently at the 684 00:28:40,200 --> 00:28:41,580 same time right looking for different 685 00:28:41,580 --> 00:28:44,360 criterions 686 00:28:44,940 --> 00:28:46,220 so 687 00:28:46,220 --> 00:28:49,260 sanitizers the first thing that that you 688 00:28:49,260 --> 00:28:51,000 should be using second thing is 689 00:28:51,000 --> 00:28:54,779 assertions this is if you because like 690 00:28:54,779 --> 00:28:56,640 memory safety is not the only thing that 691 00:28:56,640 --> 00:28:57,960 you could be looking for with fasting 692 00:28:57,960 --> 00:28:59,760 you can be looking for logic bugs as 693 00:28:59,760 --> 00:29:00,799 well 694 00:29:00,799 --> 00:29:04,080 and for that the the best thing that 695 00:29:04,080 --> 00:29:06,059 that actually works is assertion so if 696 00:29:06,059 --> 00:29:08,400 your developers are happy with using 697 00:29:08,400 --> 00:29:11,520 assertions you are lucky person because 698 00:29:11,520 --> 00:29:13,740 it's going to be much easier to to fast 699 00:29:13,740 --> 00:29:16,559 and much more likely to to like figure 700 00:29:16,559 --> 00:29:18,960 out that we have hit uh interesting 701 00:29:18,960 --> 00:29:21,360 states that should never happen and this 702 00:29:21,360 --> 00:29:23,880 is obviously a bug of some sorts 703 00:29:23,880 --> 00:29:27,120 I mentioned timeouts earlier and like 704 00:29:27,120 --> 00:29:29,159 the hard truth here is that there is no 705 00:29:29,159 --> 00:29:31,440 silver bullets to this it's really 706 00:29:31,440 --> 00:29:34,260 complex to to set it up right and you 707 00:29:34,260 --> 00:29:36,779 and this last problem 708 00:29:36,779 --> 00:29:38,880 is actually the the biggest of them all 709 00:29:38,880 --> 00:29:41,220 and you need to you you can spend a lot 710 00:29:41,220 --> 00:29:43,799 of time figuring out uh how to find 711 00:29:43,799 --> 00:29:45,360 different categories of bugs so even if 712 00:29:45,360 --> 00:29:48,240 you have fast quite a lot uh the 713 00:29:48,240 --> 00:29:50,159 software it's it there's still some 714 00:29:50,159 --> 00:29:52,620 capacity for additional bugs and that 715 00:29:52,620 --> 00:29:54,360 could be there which is also a good news 716 00:29:54,360 --> 00:29:56,760 for you if you are back hunters or uh 717 00:29:56,760 --> 00:29:59,100 you you you participate in bug Bounty 718 00:29:59,100 --> 00:30:02,100 even if software that you are looking at 719 00:30:02,100 --> 00:30:04,860 was already fast right but it was fast 720 00:30:04,860 --> 00:30:07,440 for instance years ago there is a lot of 721 00:30:07,440 --> 00:30:09,240 progress being made in this technology 722 00:30:09,240 --> 00:30:11,399 so those sanitizers gets better and 723 00:30:11,399 --> 00:30:13,919 better you can take a look at a piece of 724 00:30:13,919 --> 00:30:16,320 software that was fast before like eight 725 00:30:16,320 --> 00:30:18,360 years before or five years before and 726 00:30:18,360 --> 00:30:20,700 you can still find something also you 727 00:30:20,700 --> 00:30:22,320 know people modify software so they 728 00:30:22,320 --> 00:30:24,360 introduce new bugs so there's plenty of 729 00:30:24,360 --> 00:30:26,100 opportunity for you to find something 730 00:30:26,100 --> 00:30:28,380 interesting 731 00:30:28,380 --> 00:30:30,799 okay so that's a 732 00:30:30,799 --> 00:30:34,740 trophy slide I I was able to to find 733 00:30:34,740 --> 00:30:37,980 some stuff with this approaches and this 734 00:30:37,980 --> 00:30:40,799 is one of my fathers that that found on 735 00:30:40,799 --> 00:30:43,620 one of the sessions 11 so-called unique 736 00:30:43,620 --> 00:30:46,860 box but quite frankly AFL is not 737 00:30:46,860 --> 00:30:50,100 particularly good at the duplication so 738 00:30:50,100 --> 00:30:52,799 this number is 739 00:30:52,799 --> 00:30:56,399 and not really true but overall me and 740 00:30:56,399 --> 00:30:59,700 my friend we have found 30 zero days 741 00:30:59,700 --> 00:31:01,380 with this very approach in the software 742 00:31:01,380 --> 00:31:03,360 that we have found so the this really 743 00:31:03,360 --> 00:31:07,080 works I you you can really try it and 744 00:31:07,080 --> 00:31:09,960 this is what I actually encourage you go 745 00:31:09,960 --> 00:31:13,500 find those needles in those Haystacks uh 746 00:31:13,500 --> 00:31:16,799 look at the attack surface of your 747 00:31:16,799 --> 00:31:19,740 application look for memory safety 748 00:31:19,740 --> 00:31:22,200 issues there it's much more likely than 749 00:31:22,200 --> 00:31:23,520 you think that you will find something 750 00:31:23,520 --> 00:31:26,880 and when you do you can use this very 751 00:31:26,880 --> 00:31:32,159 approach to get rid of those bugs thank 752 00:31:32,159 --> 00:31:32,800 you very much 753 00:31:32,800 --> 00:31:41,460 [Applause] 754 00:31:41,460 --> 00:31:44,120 questions 755 00:31:44,520 --> 00:31:45,650 let's 756 00:31:45,650 --> 00:31:48,689 [Music] 757 00:31:53,340 --> 00:31:55,080 if you have a question you can come up 758 00:31:55,080 --> 00:31:57,620 to the mic here 759 00:32:00,140 --> 00:32:02,820 congratulations for a talk could you 760 00:32:02,820 --> 00:32:04,440 explain a little bit this persistent 761 00:32:04,440 --> 00:32:06,960 mode that you talked about before 762 00:32:06,960 --> 00:32:10,080 Yeah so basically when you do a like a 763 00:32:10,080 --> 00:32:13,080 standard type of fuzzing every time you 764 00:32:13,080 --> 00:32:16,020 your father will figure out a new test 765 00:32:16,020 --> 00:32:18,779 case it will run application 766 00:32:18,779 --> 00:32:22,380 and a lot of software have pretty heavy 767 00:32:22,380 --> 00:32:25,799 initializations when they start so you 768 00:32:25,799 --> 00:32:29,820 will waste a lot of CPUs by making it uh 769 00:32:29,820 --> 00:32:32,360 like start over every time 770 00:32:32,360 --> 00:32:36,539 and persistent mode is like an idea to 771 00:32:36,539 --> 00:32:37,980 solve this so basically you start the 772 00:32:37,980 --> 00:32:40,860 software and for instance you then 773 00:32:40,860 --> 00:32:43,440 generate like 10 000 test cases 774 00:32:43,440 --> 00:32:45,779 and then you'll start the software again 775 00:32:45,779 --> 00:32:47,760 because of course if you keep it in 776 00:32:47,760 --> 00:32:49,740 memory too long then it's gonna you you 777 00:32:49,740 --> 00:32:52,380 may find some issues that are false 778 00:32:52,380 --> 00:32:54,480 positive sources so you you should clean 779 00:32:54,480 --> 00:32:56,340 the memory every once in a while so 780 00:32:56,340 --> 00:32:58,320 that's basically the the approach here 781 00:32:58,320 --> 00:33:00,240 there is also a similar approach called 782 00:33:00,240 --> 00:33:02,580 the fork server in the original AFL but 783 00:33:02,580 --> 00:33:05,039 I think uh persistent mode is much more 784 00:33:05,039 --> 00:33:07,879 flexible than this 785 00:33:09,740 --> 00:33:12,240 all right thank you for the talk um have 786 00:33:12,240 --> 00:33:13,980 you compared results of like static 787 00:33:13,980 --> 00:33:16,080 analysis tools to the findings you found 788 00:33:16,080 --> 00:33:18,600 with Dynamic approaches like this you 789 00:33:18,600 --> 00:33:20,279 maybe I'll duplicate them with static 790 00:33:20,279 --> 00:33:21,440 analysis 791 00:33:21,440 --> 00:33:23,240 yes 792 00:33:23,240 --> 00:33:28,279 I I love static analysis uh 793 00:33:29,760 --> 00:33:32,720 in theory 794 00:33:33,559 --> 00:33:36,539 and people who are laughing they know 795 00:33:36,539 --> 00:33:41,039 why and I I can give you a quick I will 796 00:33:41,039 --> 00:33:42,899 not like tell you what kind of vendor 797 00:33:42,899 --> 00:33:45,260 was that but there was a vendor pitching 798 00:33:45,260 --> 00:33:48,720 software that is supposedly like finding 799 00:33:48,720 --> 00:33:52,320 memory safety issues in CC Plus Code and 800 00:33:52,320 --> 00:33:54,960 I I got like a commercial license to 801 00:33:54,960 --> 00:33:58,440 test it I wrote some Snippets in CC plus 802 00:33:58,440 --> 00:34:00,960 with very obvious very hard to find 803 00:34:00,960 --> 00:34:04,820 buffer overflows use after freeze and 804 00:34:04,820 --> 00:34:09,000 like the software found like maybe two 805 00:34:09,000 --> 00:34:10,699 out of 10 of them 806 00:34:10,699 --> 00:34:13,980 even though all of them were super you 807 00:34:13,980 --> 00:34:15,179 know obvious 808 00:34:15,179 --> 00:34:17,879 so with fasting you can find the kind of 809 00:34:17,879 --> 00:34:20,339 stuff that you never dreamed about it's 810 00:34:20,339 --> 00:34:21,960 uh I'm not saying that there's anything 811 00:34:21,960 --> 00:34:23,639 wrong with static analysis in general 812 00:34:23,639 --> 00:34:25,440 for static analysis I would say that 813 00:34:25,440 --> 00:34:26,940 there are very special special use cases 814 00:34:26,940 --> 00:34:29,699 like for instance once one use case that 815 00:34:29,699 --> 00:34:31,560 I like is let's say that you want to 816 00:34:31,560 --> 00:34:33,659 eradicate uh 817 00:34:33,659 --> 00:34:35,760 uh command injection let's say in your 818 00:34:35,760 --> 00:34:37,918 code right and you figure out what kind 819 00:34:37,918 --> 00:34:40,440 of uh in in any programming language 820 00:34:40,440 --> 00:34:43,560 there will be like a limited amount of 821 00:34:43,560 --> 00:34:46,500 ways in which you can run a shell 822 00:34:46,500 --> 00:34:48,179 command and you can say to your 823 00:34:48,179 --> 00:34:50,820 developers that there is your company's 824 00:34:50,820 --> 00:34:52,739 policy that it is forbidden to use any 825 00:34:52,739 --> 00:34:55,139 of them and then you create a rule in 826 00:34:55,139 --> 00:34:58,020 sust like you know set it up with CI CD 827 00:34:58,020 --> 00:35:00,960 and it will work brilliantly right and 828 00:35:00,960 --> 00:35:02,460 if you have this in any of your 829 00:35:02,460 --> 00:35:04,200 dependencies you can mark an exception 830 00:35:04,200 --> 00:35:06,480 for that so this is a perfect use case 831 00:35:06,480 --> 00:35:09,140 for uh static analysis when it works 832 00:35:09,140 --> 00:35:11,220 brilliantly and there are like other 833 00:35:11,220 --> 00:35:12,960 like for instance one of other 834 00:35:12,960 --> 00:35:14,880 approaches at memory safety that 835 00:35:14,880 --> 00:35:17,720 Microsoft take in this original 836 00:35:17,720 --> 00:35:20,099 libraries for cc plus plus you have a 837 00:35:20,099 --> 00:35:22,920 lot of potentially vulnerable code and 838 00:35:22,920 --> 00:35:25,079 they wrote safer versions of it and 839 00:35:25,079 --> 00:35:28,380 again they used SAS to make developers 840 00:35:28,380 --> 00:35:31,320 use the safer versions of functions not 841 00:35:31,320 --> 00:35:33,119 the unsafe version of actions so again 842 00:35:33,119 --> 00:35:35,820 very good use case in my so I would say 843 00:35:35,820 --> 00:35:37,619 those two methods are kind of different 844 00:35:37,619 --> 00:35:40,619 and they were yeah they work together 845 00:35:40,619 --> 00:35:43,200 quite well as well 846 00:35:43,200 --> 00:35:45,720 next question 847 00:35:45,720 --> 00:35:47,940 uh do you have any comments on uh doing 848 00:35:47,940 --> 00:35:49,800 asynchronous fuzzing like doing a 849 00:35:49,800 --> 00:35:52,079 limited set inside the CI pipeline just 850 00:35:52,079 --> 00:35:53,400 to give feedback immediately to the 851 00:35:53,400 --> 00:35:55,260 developer versus doing a full set 852 00:35:55,260 --> 00:35:57,420 fuzzing uh asynchronous from what the 853 00:35:57,420 --> 00:35:58,980 developer actually sees and then gives 854 00:35:58,980 --> 00:36:01,440 reports later on after 855 00:36:01,440 --> 00:36:05,099 can you repeat please so to get uh 856 00:36:05,099 --> 00:36:07,619 faster feedback to the developers uh 857 00:36:07,619 --> 00:36:09,359 when they're actively working on the 858 00:36:09,359 --> 00:36:10,260 product 859 00:36:10,260 --> 00:36:11,400 um they don't want to do the full 860 00:36:11,400 --> 00:36:13,020 fuzzing just yet they just wanted like a 861 00:36:13,020 --> 00:36:15,660 small subset of fuzzing just to get some 862 00:36:15,660 --> 00:36:18,359 basic feedback but then the the Ci or 863 00:36:18,359 --> 00:36:21,060 the build system will do a full uh 864 00:36:21,060 --> 00:36:24,060 fuzzing a secret is from what the 865 00:36:24,060 --> 00:36:25,680 developer is paying attention pay 866 00:36:25,680 --> 00:36:27,300 attention to like get a report like a 867 00:36:27,300 --> 00:36:29,720 day or two later 868 00:36:29,720 --> 00:36:32,700 yeah I'm not sure what's uh yeah I I 869 00:36:32,700 --> 00:36:34,619 understand you but I I don't exactly 870 00:36:34,619 --> 00:36:38,280 know what the question is here but I 871 00:36:38,280 --> 00:36:40,619 okay like if you were doing a smaller 872 00:36:40,619 --> 00:36:45,240 set what would you be looking for okay 873 00:36:45,980 --> 00:36:49,260 hard to say really but I I also when I 874 00:36:49,260 --> 00:36:51,599 was doing that I I was having a similar 875 00:36:51,599 --> 00:36:54,180 approach so I was doing small attacks as 876 00:36:54,180 --> 00:36:56,280 opposed to one big attack and I was 877 00:36:56,280 --> 00:36:58,680 delivering those backs to developers in 878 00:36:58,680 --> 00:37:02,040 batches it worked very well and there is 879 00:37:02,040 --> 00:37:03,900 software that could do something similar 880 00:37:03,900 --> 00:37:05,460 to what you just said like for instance 881 00:37:05,460 --> 00:37:07,859 for python it's gonna be hypothesis I'm 882 00:37:07,859 --> 00:37:09,180 not sure if you guys are familiar with 883 00:37:09,180 --> 00:37:11,520 this Library it's quite nice so it's 884 00:37:11,520 --> 00:37:13,079 it's maybe not 885 00:37:13,079 --> 00:37:15,240 fuzzing per se what it is doing but it's 886 00:37:15,240 --> 00:37:17,160 something between fuzzing so it's 887 00:37:17,160 --> 00:37:19,560 somewhat Dynamic but and not as static 888 00:37:19,560 --> 00:37:21,440 as unit tests for instance 889 00:37:21,440 --> 00:37:24,119 so it's kind of nice and it's so fast 890 00:37:24,119 --> 00:37:26,520 that you can use it exactly in the motor 891 00:37:26,520 --> 00:37:28,260 that as you as you suggested right so 892 00:37:28,260 --> 00:37:30,000 you can you can run it all the time it's 893 00:37:30,000 --> 00:37:32,640 better than unit tests but not as good 894 00:37:32,640 --> 00:37:34,859 as full-fledged fuzzing but much easier 895 00:37:34,859 --> 00:37:37,440 to set up so something in between so I 896 00:37:37,440 --> 00:37:39,480 could recommend this 897 00:37:39,480 --> 00:37:41,460 and fuzzing generally you would set it 898 00:37:41,460 --> 00:37:42,839 up somewhere in some completely 899 00:37:42,839 --> 00:37:44,220 different infrastructure completely 900 00:37:44,220 --> 00:37:46,740 separate from cicd and you would like 901 00:37:46,740 --> 00:37:48,900 keep it running 24 7. 902 00:37:48,900 --> 00:37:50,400 this is like the traditional approach 903 00:37:50,400 --> 00:37:52,440 you set up some cluster and it just runs 904 00:37:52,440 --> 00:37:55,020 some companies have made it like fully 905 00:37:55,020 --> 00:37:57,660 automatic so it's like having another QA 906 00:37:57,660 --> 00:38:01,260 team on your stuff and this cluster when 907 00:38:01,260 --> 00:38:03,780 it finds something he will create an 908 00:38:03,780 --> 00:38:06,000 issue in jira or whatever system you you 909 00:38:06,000 --> 00:38:08,520 use and then when it will be fixed the 910 00:38:08,520 --> 00:38:10,320 same cluster will check if that fix 911 00:38:10,320 --> 00:38:13,800 actually fixes this attack vectors that 912 00:38:13,800 --> 00:38:16,200 that were working before 913 00:38:16,200 --> 00:38:18,540 so it could be made fully automatic 914 00:38:18,540 --> 00:38:21,420 although it's it takes some work it's 915 00:38:21,420 --> 00:38:23,760 not like out of the box solution that 916 00:38:23,760 --> 00:38:26,400 that you can use 917 00:38:26,400 --> 00:38:27,839 all right let's go ahead and put our 918 00:38:27,839 --> 00:38:28,870 hands together 919 00:38:28,870 --> 00:38:33,750 [Applause] 920 00:38:34,020 --> 00:38:37,059 [Music]