1 00:00:00,000 --> 00:00:07,440 Okay. So it is with great pleasure I introduce a good friend of mine. FX and I have known each 2 00:00:07,440 --> 00:00:13,240 other since, was it DEF CON 9 where we ran into each other out in the pool? And I was trying to 3 00:00:13,240 --> 00:00:18,480 keep him supported while he was telling me about his talk. And I discovered he's a really smart 4 00:00:18,480 --> 00:00:25,080 guy. So you're going to learn a lot from him. But we have to start with a couple of shots of 5 00:00:25,080 --> 00:00:46,660 Jägermeister. Thank you. Oh, yeah, bring more Jäger. So today we're talking about safer sex 6 00:00:46,660 --> 00:00:53,880 online. How to get not owned by watching porn. Because the problem being the porn comes in 7 00:00:53,880 --> 00:00:54,380 flash fights. 8 00:00:55,080 --> 00:01:05,600 Okay. So just in the beginning, it's a defense talk. So I'm not semantic. So I'm not telling 9 00:01:05,600 --> 00:01:12,000 you this is going to protect you 100%. Because defense and security is actually just about 10 00:01:12,000 --> 00:01:19,580 making shit happen less often. You can't really prevent it from happening all the time. So this 11 00:01:19,580 --> 00:01:24,220 is what I want to talk about here. We're going to quickly go over the motivation of this 12 00:01:25,080 --> 00:01:33,060 work. So the five of you that probably sit there go like Cisco and then flash. What the fuck? This 13 00:01:33,060 --> 00:01:40,100 explains why. And then the flash attack surface and who actually has issues with flash security. 14 00:01:40,600 --> 00:01:46,200 And I'm getting to the tool demo pretty quickly. So you can either switch talks or then sit 15 00:01:46,200 --> 00:01:54,640 through the rest and see how it works. So the idea, this whole thing was actually initiated by a 16 00:01:55,080 --> 00:02:02,500 colleague from the German federal office for information security. In contrast to your NSA, our 17 00:02:03,120 --> 00:02:12,060 office actually also cares about the citizens and the citizen security. Now that's actually their 18 00:02:12,060 --> 00:02:18,200 official mission partially. So they care about things like flash and client side security. And so 19 00:02:18,200 --> 00:02:24,680 we looked at a couple of rich Internet application platforms and flash essentially turned out to 20 00:02:24,680 --> 00:02:30,140 suck a lot more than all the others in terms of security. And we tried to figure out how to fix 21 00:02:30,140 --> 00:02:37,560 that and unfuck flash without firing everyone at Adobe. Because that just simply wasn't in our 22 00:02:37,560 --> 00:02:44,160 reach. Not that I would have not considered it. And so and then we also discovered that the 23 00:02:44,160 --> 00:02:50,640 traditional detection methods actually don't work too well. And I'm coming to this in the talk. And 24 00:02:50,640 --> 00:02:54,660 we also, we see a shitload of new flash exploits all the time. So we're going to talk a little bit 25 00:02:54,680 --> 00:03:00,280 about that. And we didn't want to build yet another antivirus engine. So we wanted to build 26 00:03:00,280 --> 00:03:06,620 something that is signature free. That is, if the code is actually working, doesn't require any 27 00:03:06,620 --> 00:03:13,260 attention anymore and not constant updating and stuff. So that is the higher theoretical goal 28 00:03:13,260 --> 00:03:20,220 behind this work. What type of attack surface are we looking for when we load a flash file into a 29 00:03:20,220 --> 00:03:24,660 flash player? Well, the things that usually, like, you know, we're looking for when we're 30 00:03:24,680 --> 00:03:30,220 looking for a break in software when you try to exploit it are parsers, like the piece of code 31 00:03:30,220 --> 00:03:36,120 that actually takes apart the protocol file format. And now the flash file format is actually a 32 00:03:36,120 --> 00:03:42,200 container format that contains vector graphics, pixel graphics, fonts, sound data, video data of 33 00:03:42,200 --> 00:03:48,680 all types and virtual machine code. What can possibly go wrong? Pretty much everything. So 34 00:03:48,680 --> 00:03:54,540 let's say 80 percent of the software is parsing and it's all written in C by people from Adobe. 35 00:03:55,940 --> 00:04:05,760 And hence we have a problem. So the first type of person that has problems is end users, like you 36 00:04:05,760 --> 00:04:13,180 get owned by surfing porn. What commonly happens is you have a malicious flash file somewhere in 37 00:04:13,180 --> 00:04:19,060 the web page or a malicious flash is loaded up while you're watching the porn in the background. 38 00:04:19,360 --> 00:04:24,660 And then your flash player plug-in in the browser gets popped. And then it's like, you know, 39 00:04:24,680 --> 00:04:31,480 you're in a hurry to get out. And this is in almost all cases by modifying the flash file format in a 40 00:04:31,480 --> 00:04:35,760 way that when it is parsed, the parser breaks, like integer overflows and buffer overflows, 41 00:04:35,860 --> 00:04:43,440 basically. You also have functionality-based attacks, like DNS rebinding, CSRF style attacks 42 00:04:43,440 --> 00:04:49,420 where you essentially use flash to speak UPnP to your home router and open a port so it gets 43 00:04:49,420 --> 00:04:54,660 forwarded. Or it is used in exploit toolkits. The problem is 98 percent of the time, we have the 44 00:04:54,660 --> 00:05:02,940 27% of all browsers have flash. And a quote I hear someone saying was telling people not 45 00:05:02,940 --> 00:05:12,260 to use flashes like telling people to not smoke. That doesn't work. So what the end 46 00:05:12,260 --> 00:05:18,300 user actually wants is something that does Adobe's job. Which is validating that the 47 00:05:18,300 --> 00:05:23,400 file he is about to load in the flash player is actually valid and well formatted because 48 00:05:23,400 --> 00:05:28,820 if it's valid and well formatted, then it's probably not going to make the flash player fall 49 00:05:28,820 --> 00:05:36,980 over. And if you can guarantee that it's well formatted, then you probably have a file that you 50 00:05:36,980 --> 00:05:45,500 can watch without getting popped. The thing here is that you actually really want to have that in 51 00:05:45,500 --> 00:05:53,300 your web browser on demand. And for end users, performance of such a method for protecting 52 00:05:53,400 --> 00:05:59,880 is actually critical. As AV vendors know all the time, because people hate to wait for their 53 00:05:59,880 --> 00:06:07,480 porn. So if it's, you know, if it loads slowly, then, you know, it's not cool. Unless you grew up 54 00:06:07,480 --> 00:06:17,880 in the mailbox times, then, yeah, you were used to seeing people in pieces. The other group of 55 00:06:17,880 --> 00:06:23,380 people that actually really suffer from flash attacks are website owners and ad networks. And 56 00:06:23,400 --> 00:06:29,040 interestingly enough here, it's not file format based attacks that they're concerned with. 57 00:06:29,300 --> 00:06:34,320 It's actually functionality based attacks. So, you know, there is program code in flash files. 58 00:06:34,620 --> 00:06:44,120 And of course you can program your banner to go to a nonmalicious URL. Hello. To go to a 59 00:06:44,120 --> 00:06:52,520 nonmalicious URL. And then it gets uploaded into the advertisement network and they click on it, 60 00:06:52,520 --> 00:06:57,940 they test it, they see it's fine. They put it out into the content distribution network. And 61 00:06:57,940 --> 00:07:04,720 then your banner changes behavior and forwards users' browsers to malicious sites. That happened 62 00:07:04,720 --> 00:07:10,020 to a couple of news media sites, including the New York Times. So it's an actual problem for 63 00:07:10,020 --> 00:07:18,100 them. Their requirements on flash security are somewhat different. Sure, well formatted files is 64 00:07:18,100 --> 00:07:22,500 also of interest to them. Because it helps the people testing them. But it's a little bit of a 65 00:07:22,500 --> 00:07:29,340 challenge. It's not getting owned. But desired is also the ability to say, well, contractually we 66 00:07:29,340 --> 00:07:35,080 give you banner space to forward to users that click on your banner to this particular URL. If 67 00:07:35,080 --> 00:07:40,380 you're diverting it, if you're forwarding them to a different URL, you're violating the contract. 68 00:07:40,640 --> 00:07:45,640 The problem is today they can't verify that. They have to trust the code. Because they get 69 00:07:45,640 --> 00:07:51,840 precompiled flash files. And it would be nice for them to say, well, we enforce that the code 70 00:07:51,840 --> 00:07:52,480 actually can't be used. And that's a little bit of a challenge for them. But it's a little bit of a 71 00:07:52,480 --> 00:07:57,340 challenge for them. They cannot do anything else. That, of course, is more computational 72 00:07:57,340 --> 00:08:03,600 expensive. Meaning you need more CPU power. But that's not a big problem for them. Because they 73 00:08:03,600 --> 00:08:09,660 will run a server site. They will actually run a verification process the moment the flash file 74 00:08:09,660 --> 00:08:22,460 gets uploaded. So we have flash provides its own security. Not. But it's a little bit of a 75 00:08:22,480 --> 00:08:27,080 challenge. But there is some configuration. Right? There's very limited configuration options. 76 00:08:27,560 --> 00:08:35,460 Like you can turn on and off the camera. For whatever that helps you if you got owned. And 77 00:08:35,920 --> 00:08:41,400 there is the possibility to disable a lot more things. Like disable file uploading or 78 00:08:41,400 --> 00:08:47,100 downloading. The problem is that sits in some configuration file that nobody actually uses. 79 00:08:47,780 --> 00:08:52,460 What the hell is going on next door? Do they have next door security? I don't know. I don't 80 00:08:52,460 --> 00:08:59,860 know. Like chicks or something? And another thing that flash doesn't have in terms of security 81 00:08:59,860 --> 00:09:04,500 is proof of origin. So there is absolutely no way that you can tell where the flash came from. 82 00:09:04,640 --> 00:09:14,140 There is no signature mechanism whatsoever. And then there is AVs. So here's the thing about AVs 83 00:09:14,140 --> 00:09:21,920 and flash. Flash files can be and most commonly are zip compressed inside. Like the whole thing is 84 00:09:21,920 --> 00:09:26,080 it compressed. They can be uncompressed, functional 85 00:09:26,080 --> 00:09:31,520 equivalent, it's just that it's compressed. So when you take the 86 00:09:31,520 --> 00:09:35,940 most common malware, it is called, no idea who came up with 87 00:09:35,940 --> 00:09:41,460 that name. If you upload that to virus tool, you get a coverage 88 00:09:41,460 --> 00:09:45,620 of about 70%. Now this is the compressed file. If you simply 89 00:09:45,620 --> 00:09:48,660 uncompressed the file, it's still the same file, it's just 90 00:09:48,660 --> 00:09:53,400 unzipped. And you upload it again, only 8 out of 40 AVs even 91 00:09:53,400 --> 00:09:58,180 detect most common flash malware that we've ever seen. So AVs are 92 00:09:58,180 --> 00:10:03,840 an epic fail when it comes to flash. Scratched apart when it 93 00:10:03,840 --> 00:10:10,800 comes to flash. So we had an alternative approach on this. So 94 00:10:10,800 --> 00:10:14,960 what we provide is a straight command line program, similar to 95 00:10:14,960 --> 00:10:18,640 command line AV. And what it does is, you have a command line 96 00:10:18,660 --> 00:10:21,580 program. You give it a flash input file that is potentially 97 00:10:21,580 --> 00:10:26,780 malicious. And you will receive an output file that is hopefully 98 00:10:26,780 --> 00:10:32,860 not. As simple as that. The idea here is that we actually run 99 00:10:32,860 --> 00:10:37,900 complete format verification on the file. And then produce a new 100 00:10:37,900 --> 00:10:43,580 file for you. And how do you use that? Well, we figured that we 101 00:10:43,580 --> 00:10:46,640 first with the release are going to target people that are 102 00:10:46,640 --> 00:10:48,640 security conscious anyway. So we have a lot of people that are 103 00:10:48,660 --> 00:10:52,220 not. So I thought if you're surfing with the IE6, then you 104 00:10:52,220 --> 00:10:55,140 probably don't care about flash security because you have other 105 00:10:55,140 --> 00:11:00,300 problems. But if you're surfing with Firefox and no script, then 106 00:11:00,300 --> 00:11:03,540 you're probably aware of a few of the things that happen on the 107 00:11:03,540 --> 00:11:08,720 Internet. And so you're probably more helpful as a target customer 108 00:11:08,720 --> 00:11:17,520 group. So the author of no script was nice enough to build a 109 00:11:18,660 --> 00:11:23,180 external filter interface that I proposed to him. So you can hook up 110 00:11:23,180 --> 00:11:26,140 other programs. You can write your own programs now that will do 111 00:11:26,140 --> 00:11:29,600 filtering of specific mine types. And then you can hook them into no 112 00:11:29,600 --> 00:11:34,780 script with no coding whatsoever. But he built it actually for us. So 113 00:11:34,780 --> 00:11:43,040 we can integrate our blitz up lighter into this no script thing. It 114 00:11:43,040 --> 00:11:48,160 required a lot of work on his side. And it's currently up and running. If 115 00:11:48,660 --> 00:11:51,860 you're up on the latest version of no script, you already have that 116 00:11:51,860 --> 00:11:55,960 option and you can configure it. And at this point we would like to 117 00:11:55,960 --> 00:12:01,060 thank Georgiou very much because it's not like we had to back him or 118 00:12:01,060 --> 00:12:04,220 something. It was sending him one e-mail proposing this and he's 119 00:12:04,220 --> 00:12:10,560 like, it's cool. And then he started writing code. I think I forgot to 120 00:12:10,560 --> 00:12:15,980 mention one thing. The name of the tool, blitz up lighter, is a 121 00:12:15,980 --> 00:12:18,640 German word, intentionally. I think it's a German word. It's a 122 00:12:18,660 --> 00:12:23,940 German word. Just to make it harder for you guys. It is the term that we 123 00:12:23,940 --> 00:12:28,720 use for lightning rod because it turns dangerous lightning into, you 124 00:12:28,720 --> 00:12:33,340 know, pretty flashes that don't kill anyone. So that's for the name of 125 00:12:33,340 --> 00:12:38,600 it. So here's how the no script integration looks like. It's really 126 00:12:38,600 --> 00:12:43,580 just the external filters tab and then you choose the exe file. And he 127 00:12:43,580 --> 00:12:48,520 also integrated it into the context menu. So, for example, if the 128 00:12:48,660 --> 00:12:52,920 tool will not allow you to see a certain piece of porn and you really 129 00:12:52,920 --> 00:12:56,980 want to see it, it's one click away to say for this site, don't run a 130 00:12:56,980 --> 00:13:04,360 filter. I want to get owned. The shake is just too hot. So if you 131 00:13:04,360 --> 00:13:08,340 want to integrate blitz up lighter into web pages, that's also a 132 00:13:08,340 --> 00:13:14,560 trivial thing since it's command line. You're just running it on the 133 00:13:14,560 --> 00:13:18,600 web server when the upload happened and check the return value. The 134 00:13:18,660 --> 00:13:23,220 operating system exit value of the program works the same way every 135 00:13:23,220 --> 00:13:29,160 command line AV ever worked. Depending on the feedback we get, we're going to 136 00:13:29,160 --> 00:13:35,300 set up a XML RPC or SOAP or whatever service. You can use AJAX or 137 00:13:35,300 --> 00:13:40,460 whatever to send flash files first to us and then get the flash files from 138 00:13:40,460 --> 00:13:45,940 us into your web platform. If you want to have such a service being 139 00:13:45,940 --> 00:13:48,640 implemented, then please contact us. Drop us a message. If you want to have 140 00:13:48,660 --> 00:13:52,920 such a service, drop me an e-mail, something like that. It would be easily 141 00:13:52,920 --> 00:13:59,400 doable, but I'm sick of doing stuff that nobody wants to use. And it's open 142 00:13:59,400 --> 00:14:06,580 source. Because I don't believe in black or yellow boxes that promise to make me 143 00:14:06,580 --> 00:14:09,720 secure and someone else rich because they usually only fulfill the second 144 00:14:09,720 --> 00:14:16,340 requirement. And that is not good. So I believe that we should actually start 145 00:14:16,340 --> 00:14:18,480 applying principle from the crypto 146 00:14:18,660 --> 00:14:23,540 graphy world to the defense world, saying if you use a defense mechanism, you have to be able to 147 00:14:23,540 --> 00:14:28,160 verify that it actually does what you're expecting it to do. And for this, the source code is 148 00:14:28,160 --> 00:14:35,880 very helpful. We would also love to see integration into other pieces of software. So you're 149 00:14:35,880 --> 00:14:42,180 welcome to sign up and get the source ball. That's the URL. But it's going to be on the last 150 00:14:42,180 --> 00:14:48,640 slide anyway. And now I'm going to show you the thing in order for you to be able to see what's 151 00:14:53,360 --> 00:15:06,220 going on. So this is my very, very small version of the Internet. It has a glass martini and two 152 00:15:06,220 --> 00:15:13,280 exploits. So let's first look at the glass of martini. This is what no script is supposed to do, 153 00:15:13,300 --> 00:15:17,880 right? Like it prevents the shit from even executing. But if I choose to actually want to see 154 00:15:17,880 --> 00:15:25,120 that, it is loading flash and it's taking like on this shitty netbook, it takes about like nine 155 00:15:25,120 --> 00:15:32,620 seconds until I get my glass of martini. So this is, you can verify this is flash by seeing the 156 00:15:32,620 --> 00:15:38,240 options that I don't see right now. Yeah, I don't have it on my screen here. So it's kind of 157 00:15:38,240 --> 00:15:47,860 funny. Are you, is that the back button? Cool. So here you can see what's going on. You can see 158 00:15:47,880 --> 00:15:57,100 it's an in the wild exploit. For a relatively recent vulnerability. As you can see, I'm going to 159 00:15:57,100 --> 00:16:04,180 fire this. And so nothing happens on your side, but on my screen, which is the primary screen, I 160 00:16:04,180 --> 00:16:11,140 get a pop up that looks like this. And it explains that this exploit didn't even bother to set the 161 00:16:11,140 --> 00:16:16,360 length fields in the first header. Like the first length field ever in this entire file to set that 162 00:16:16,360 --> 00:16:17,860 one right. So I'm going to fire this. And I'm going to fire this. And I'm going to fire this. And 163 00:16:17,860 --> 00:16:19,580 I'm going to fire this. And if I actually hit remove, it will fire. Which speaks volumes of 164 00:16:19,580 --> 00:16:26,620 like the flash player parser because that would be accepted. So you see two buttons. You can just 165 00:16:26,620 --> 00:16:31,880 hit escape and it disappears. But to the left, there is also a button that says tell the people 166 00:16:31,880 --> 00:16:38,260 they suck. Which sends us this lock. Because if we filter the porn, you really wanted to see, then 167 00:16:38,260 --> 00:16:46,760 you can complain by pressing this button. So and then, you know, you get a replacement file. You 168 00:16:46,760 --> 00:16:47,840 can actually configure the replacement file. So you can actually put in here, you know, at the 169 00:16:47,840 --> 00:16:50,300 placement file so if you want to flip the finger at exploits you 170 00:16:50,300 --> 00:16:58,780 can do that. Let me see. Back button? Cool. Here's another 171 00:16:58,780 --> 00:17:02,140 one. I actually like had to figure out what the 172 00:17:02,140 --> 00:17:05,040 vulnerability was and write this trigger for the vulnerability 173 00:17:05,040 --> 00:17:09,520 myself. So this one actually cares about setting the length 174 00:17:09,520 --> 00:17:17,080 fields correctly. And here you see a, well, first I see it. A 175 00:17:17,080 --> 00:17:22,780 more concrete example of how far we go down. I'm going to mark 176 00:17:22,780 --> 00:17:29,640 this here. Yeah. Well, I had to mark it first. So this is where 177 00:17:29,640 --> 00:17:33,240 we actually go down into the byte code and one of the 178 00:17:33,240 --> 00:17:37,020 individual byte codes had an invalid argument which will 179 00:17:37,020 --> 00:17:42,600 exploit the flash player but the format verification has caught 180 00:17:42,600 --> 00:17:46,160 it and would have caught it before the vulnerability was 181 00:17:46,160 --> 00:17:47,060 forwarded. So this is where we actually go down into the 182 00:17:47,080 --> 00:17:51,540 code and we're verifying the entire format. So this is what 183 00:17:51,540 --> 00:18:01,020 you get. Are you impressed? Now let's see if I can get this 184 00:18:01,480 --> 00:18:08,240 back to presentation mode. Awesome. Didn't work at 185 00:18:08,240 --> 00:18:12,280 black hat. So now that you know what you get, let me explain how 186 00:18:12,280 --> 00:18:17,060 it works. So what is flash in the inside other than Fox? So 187 00:18:17,080 --> 00:18:23,020 it's a, as I said, it's a container file format. But it is 188 00:18:23,020 --> 00:18:25,680 heavily version dependent. Every data structure in this file 189 00:18:25,680 --> 00:18:28,340 format is extremely version dependent and the version is 190 00:18:28,340 --> 00:18:31,200 set right in the beginning in the header. So the file declares 191 00:18:31,200 --> 00:18:35,080 what version it is. Which influences a lot of things how 192 00:18:35,080 --> 00:18:38,940 the flash player behaves. But also how the data structures 193 00:18:38,940 --> 00:18:42,640 look like. The problem with flash, or one of the problems 194 00:18:42,640 --> 00:18:45,840 with flash is it's all the way backward compatible to version 3 195 00:18:45,840 --> 00:18:47,060 of the file format. So it's a little bit more complicated than 196 00:18:47,080 --> 00:18:51,620 that. So as someone said, trying to be backwards compatible is 197 00:18:51,620 --> 00:18:54,940 like trying to stay close best friends with all your ex 198 00:18:54,940 --> 00:19:00,840 girlfriends. And we know how good that works. So that's your 199 00:19:00,840 --> 00:19:06,180 problem. I already mentioned that you can compress flash 200 00:19:06,180 --> 00:19:09,520 files. But that really doesn't matter too much. In principle, 201 00:19:09,660 --> 00:19:12,720 the file format is composed of tags. And tags are simple type 202 00:19:12,720 --> 00:19:16,340 length value data structures like containers. In which then 203 00:19:16,340 --> 00:19:17,060 specifically, you can have a lot of data structures. So you can 204 00:19:17,080 --> 00:19:21,980 take data structures for this tag type reside. A few examples of 205 00:19:21,980 --> 00:19:27,120 tag types. You have control tags. You have essentially like 206 00:19:27,120 --> 00:19:31,140 start and end the movie and set labels and bullshit. Then you 207 00:19:31,140 --> 00:19:34,460 have things that display objects. And we're going to talk 208 00:19:34,460 --> 00:19:38,800 about these more later. You will actually notice that those tag 209 00:19:38,800 --> 00:19:42,060 types here, they have something like they have numbers behind 210 00:19:42,560 --> 00:19:46,880 them sometimes. So place object and place object two are 211 00:19:47,080 --> 00:19:50,280 two different tag types. And place object two actually doesn't 212 00:19:50,280 --> 00:19:53,860 place two objects as you would first assume. But it's their 213 00:19:53,860 --> 00:19:58,540 second attempt to get the data structure right. By the fact that 214 00:19:58,540 --> 00:20:03,320 we have a place object three, you see how well that went. And 215 00:20:03,940 --> 00:20:07,720 that's a reoccurring pattern in Adobe's design is like even op 216 00:20:07,720 --> 00:20:11,700 codes have second and third versions. We also have bit map 217 00:20:11,700 --> 00:20:17,060 data. You see there is a defined bits JPEG two and three. And 218 00:20:17,080 --> 00:20:21,220 I don't know like how hard can it be to not fuck up a JPEG data 219 00:20:21,220 --> 00:20:26,380 structure. But anyway. And they have a special tag type that is a 220 00:20:26,380 --> 00:20:30,220 button which is nothing else than a shape. But it has 221 00:20:30,220 --> 00:20:36,660 functionality connected to it. Here's an example of a data 222 00:20:36,660 --> 00:20:41,820 structure. So they tend to lend themselves very nicely to buffer 223 00:20:41,820 --> 00:20:45,040 overflows and integer overflows. Because they have a shit load of 224 00:20:45,040 --> 00:20:47,060 length and counter fields. And there are a lot of things that 225 00:20:47,080 --> 00:20:51,640 are all 32 bit long. And they can easily contradict each other 226 00:20:51,640 --> 00:20:56,780 by design. Which they, well, if you set in this case, if you set 227 00:20:56,780 --> 00:21:00,180 one of the length fields on a negative value as marked out 228 00:21:00,180 --> 00:21:05,300 demonstrated in 2007, you can exploit the flash player. One of 229 00:21:05,300 --> 00:21:10,760 the many ways you can do that. So what BlitzSupply does is what 230 00:21:10,760 --> 00:21:14,960 I call normalization through recreation. So we ensure, we 231 00:21:14,960 --> 00:21:17,060 parse everything that we find. In the code that we have, we 232 00:21:17,080 --> 00:21:20,120 have the greatest detail we can possibly do. Based on the 233 00:21:20,120 --> 00:21:23,640 specification. We're really strict on enforcing that all the 234 00:21:23,640 --> 00:21:26,580 cross references and all the relations between length fields, 235 00:21:26,760 --> 00:21:31,900 pointers, indexes, all that are really, really completely tested 236 00:21:32,300 --> 00:21:36,680 and completely understood. Once we did that, and code makes 237 00:21:36,680 --> 00:21:41,160 sense of the porn, we throw away the original file and create new 238 00:21:41,160 --> 00:21:45,520 porn based on the information we parsed out. That has the benefit 239 00:21:45,520 --> 00:21:47,060 of providing perfect information to the user. So we have the 240 00:21:47,080 --> 00:21:50,600 perfectly clean porn to the flash player. So you don't get 241 00:21:50,600 --> 00:21:54,720 owned. It also makes writing stable exploits a bitch because 242 00:21:54,720 --> 00:21:59,680 all the offsets change all the time. And that's essentially what 243 00:21:59,680 --> 00:22:05,200 we do. And that's essentially what I call normalization. How 244 00:22:05,200 --> 00:22:09,340 do we do that? So first of all, we're writing yet another parser 245 00:22:09,340 --> 00:22:13,060 for flash. So we want to, we don't want to increase your 246 00:22:13,060 --> 00:22:15,700 attack surface. We want to decrease it. Right? So we 247 00:22:15,700 --> 00:22:17,060 better not write the parser. We don't want to increase your 248 00:22:17,080 --> 00:22:17,740 attack surface. So we're writing yet another parser in an 249 00:22:17,740 --> 00:22:22,480 unmanaged language. We're using the .NET runtime to ensure that 250 00:22:22,480 --> 00:22:26,640 things like out of bounds and integer overflows will be caught 251 00:22:27,100 --> 00:22:30,960 by our runtime and not by our code. If we would check for all 252 00:22:30,960 --> 00:22:33,880 the possible integer overflows in a file format manually in C 253 00:22:33,880 --> 00:22:38,200 code, we A, would fuck it up. Well, I most certainly would. And 254 00:22:38,200 --> 00:22:41,860 B, it would be a lot of code. Why would I do that? There is a 255 00:22:41,860 --> 00:22:46,260 runtime for that. It also means it runs nicely on Linux and BSD 256 00:22:47,080 --> 00:22:50,960 and it targets .NET 2.0. So it's perfectly binary compatible 257 00:22:50,960 --> 00:22:55,140 with mono 1.2 which is currently shipping on most Linux platforms. 258 00:22:55,740 --> 00:23:01,720 And, you know, Mac users can kiss my silly ass. It was their 259 00:23:01,720 --> 00:23:08,360 choice when they bought it. So for all the TLV data structures 260 00:23:08,360 --> 00:23:10,760 that we have, not just the tags, but everything that is 261 00:23:10,760 --> 00:23:14,120 like type length and then block, we just move it into individual 262 00:23:14,120 --> 00:23:17,060 memory streams and operate on those memory streams. And that's 263 00:23:17,080 --> 00:23:17,780 what we're going to do with the memory streams. Because then 264 00:23:17,780 --> 00:23:20,380 every out of bounds operation will actually throw an exception 265 00:23:20,380 --> 00:23:25,400 and it does. The parser only accepts data structures that are 266 00:23:25,400 --> 00:23:28,980 documented in the Swift file format specification. Which 267 00:23:28,980 --> 00:23:33,680 unfortunately is not very commonly updated. So if there 268 00:23:33,680 --> 00:23:37,100 is undocumented opcodes or any other bullshit going on, we're 269 00:23:37,100 --> 00:23:41,880 going to reject the file. And the parser also verifies all the 270 00:23:41,880 --> 00:23:46,440 version dependence. So you cannot claim to be a Swift version 6 271 00:23:47,080 --> 00:23:49,920 and then use some advanced functionality from version 8. 272 00:23:51,720 --> 00:23:57,500 Here's an example on why running on a .NET CLR is so cool. The 273 00:23:57,500 --> 00:24:02,600 exploit I mentioned before, 2007-0071 from Mark Dowd. If you're 274 00:24:02,600 --> 00:24:06,920 trying to read this into Blitz, this is in the code where the 275 00:24:06,920 --> 00:24:10,120 actual exception is triggered for the negative value of the scene 276 00:24:10,120 --> 00:24:15,600 count. So the run time caught it right there when we parse it. And 277 00:24:15,600 --> 00:24:16,480 that is fantastic. 278 00:24:18,660 --> 00:24:25,020 And this is what you get as an output later on. Let me tell you 279 00:24:25,020 --> 00:24:28,800 a little bit about Adobe virtual machines within flash. This is 280 00:24:28,800 --> 00:24:34,580 fun. And also a history lesson on how to not do stuff. So the 281 00:24:34,580 --> 00:24:38,780 flash player actually contains two virtual machines. Completely 282 00:24:38,780 --> 00:24:42,120 independent two virtual machines. They're respectively 283 00:24:42,120 --> 00:24:46,940 called AVM 1 and 2. AVM 1 is historically grown thingy that 284 00:24:47,080 --> 00:24:51,920 they came up with in flash version 4. And something about 285 00:24:51,920 --> 00:24:56,520 like 80% of the flash on the Internet are still AVM 1. AVM 2 286 00:24:56,520 --> 00:25:03,940 is a virtual machine for ECMA 262 JavaScript specification. But 287 00:25:03,940 --> 00:25:08,320 of course the VM is completely by Adobe's design which is not 288 00:25:08,320 --> 00:25:13,520 necessarily good. AVM 1 is programmed in action script 1 and 289 00:25:13,520 --> 00:25:16,780 2. That's what most web designers use. And action script 290 00:25:16,780 --> 00:25:23,240 3 is what is closer to JavaScript. And it's not so 291 00:25:23,240 --> 00:25:28,500 widely used in the, you know, I call them RGB caspers. Like 292 00:25:28,500 --> 00:25:32,100 people that make blinking web pages. So they struggle to 293 00:25:32,100 --> 00:25:36,820 understand OOP. So the whole JavaScript object and event 294 00:25:36,820 --> 00:25:42,280 handler idea just escapes them. So they stay with the AVM 1. 295 00:25:42,400 --> 00:25:46,720 That's the reason why we have so much code there. So I said a 296 00:25:46,720 --> 00:25:49,280 version 4. The data was introduced in version 4 of this 297 00:25:49,280 --> 00:25:52,380 web file format. It was already a Turing complete stack machine 298 00:25:52,880 --> 00:25:56,880 with variables and stuff. But someone must have left university 299 00:25:56,880 --> 00:26:02,060 after the first course. Because all the data, like the only data 300 00:26:02,060 --> 00:26:06,400 type it could do was string. So if you would add two numbers, you 301 00:26:06,400 --> 00:26:08,920 would actually push two strings onto the stack and then the add 302 00:26:08,920 --> 00:26:12,640 instruction would try to make sense of them to a number and 303 00:26:12,640 --> 00:26:16,700 then add them and then push back a string. And so that was the 304 00:26:16,700 --> 00:26:17,820 reason why I said the Lindaiter. So. In version 5 they realized 305 00:26:17,820 --> 00:26:22,800 that's a shitty idea. Introduced type variables and also 306 00:26:22,800 --> 00:26:25,320 introduced a constant pool. Someone must have made it 307 00:26:25,320 --> 00:26:29,940 through the first 20 pages of the Java specification. And they 308 00:26:29,940 --> 00:26:37,800 introduced objects and methods. Which, is that good? Yeah. Which 309 00:26:37,800 --> 00:26:40,500 then in version 6 they discovered that objects actually 310 00:26:40,500 --> 00:26:43,740 need to be initialized before they run. So they introduced a 311 00:26:43,740 --> 00:26:46,680 tag type for that. And I actually since PC is quite common I think 312 00:26:46,680 --> 00:26:49,500 introduced versions, they now discovered it would be cool to 313 00:26:49,500 --> 00:26:52,360 check the ‑‑ they introduced types and now it would be cool 314 00:26:52,360 --> 00:26:56,040 to actually check what type a variable is. So they introduced 315 00:26:56,040 --> 00:27:01,880 that. And in version 7, then they added new functionality to 316 00:27:01,880 --> 00:27:06,840 their objects. For example, they discovered exceptions. And 317 00:27:06,840 --> 00:27:12,080 type casting. And object inheritance. Version 8 never 318 00:27:12,080 --> 00:27:17,740 happened. I don't even want to know. And version 9 then brings 319 00:27:17,740 --> 00:27:22,260 in the AVM 2 with a complete file format within the file 320 00:27:22,260 --> 00:27:26,100 format. So they have a complete new file format that is called 321 00:27:26,100 --> 00:27:30,180 ABC file format that goes into one new tag type. And so you 322 00:27:30,180 --> 00:27:34,200 have yet another file format in the file format. And then version 323 00:27:34,200 --> 00:27:37,780 10 is what we're currently watching the porn on. Now keep 324 00:27:37,780 --> 00:27:41,980 in mind, this is all still supported. Back to the 325 00:27:42,080 --> 00:27:46,620 string additions. So where would you actually look for code 326 00:27:46,620 --> 00:27:50,280 within a flash file? There's a tag type called do action. 327 00:27:50,560 --> 00:27:55,080 Sounds like one. There's the majority of the AVM 1 code is 328 00:27:55,080 --> 00:27:59,940 supposed to be there. And then there's the do in action tag 329 00:27:59,940 --> 00:28:04,220 which I said is used for the initialization of objects. But 330 00:28:04,220 --> 00:28:07,020 can contain pretty much any code you want. Like there's no 331 00:28:07,020 --> 00:28:11,440 restrictions that are put into place by the player. Then there 332 00:28:11,440 --> 00:28:12,060 is the button. This is the button. This is the button that 333 00:28:12,080 --> 00:28:15,640 I already mentioned. So the define button 2 tag contains a 334 00:28:15,640 --> 00:28:20,660 button record to data structure that can carry conditional 335 00:28:20,660 --> 00:28:26,160 button actions. Which is actually blobs of code. So you 336 00:28:26,160 --> 00:28:29,300 have a graphical element in a file format, a vector graphic 337 00:28:29,300 --> 00:28:32,720 element and you attach a piece of code to it. Now they obviously 338 00:28:32,720 --> 00:28:37,720 really like this idea. Then went back to their fridge with the 339 00:28:37,720 --> 00:28:41,560 psychedelic drugs. Took some more. And specified the same 340 00:28:42,080 --> 00:28:47,080 behavior for shapes. So you can actually have two shapes like a 341 00:28:47,080 --> 00:28:52,680 star and an asshole. And if they overlap, they clip. So clipping 342 00:28:52,680 --> 00:28:56,160 is when one of the shapes is not completely shown. For which you 343 00:28:56,160 --> 00:28:58,440 do clipping calculations. If those clipping calculations 344 00:28:58,440 --> 00:29:02,400 happen, the asshole can actually have code attached to 345 00:29:02,400 --> 00:29:07,580 it that is executed when it gets clipped. Isn't that nice? So you 346 00:29:07,580 --> 00:29:10,080 actually have to parse the entire vector graphics definition 347 00:29:11,320 --> 00:29:15,600 to get to the code that is executed when someone like moves 348 00:29:15,600 --> 00:29:19,680 the mouse over it. Many security tools that we found and other 349 00:29:19,680 --> 00:29:22,340 tools actually don't parse that part of the code. They only 350 00:29:22,340 --> 00:29:26,240 parse the main part that is in the do action tag. So you can 351 00:29:26,240 --> 00:29:31,400 totally smuggle code away. The code itself, like the AVM one 352 00:29:31,400 --> 00:29:35,400 code, is variable length instructions. We all know how 353 00:29:35,400 --> 00:29:39,920 great those are. It has signed branch targets, six 354 00:29:40,080 --> 00:29:46,440 16-bit branch targets, which pose a problem. And then there's 355 00:29:46,440 --> 00:29:49,980 the two sickest things I've ever seen. So if you want to define a 356 00:29:49,980 --> 00:29:55,140 function, in every other executable format that has the 357 00:29:55,140 --> 00:29:59,600 notion of a function, you will have a separate area where you 358 00:29:59,600 --> 00:30:02,720 say, this is where I define my functions. This is what name it 359 00:30:02,720 --> 00:30:05,880 is. This is where it starts. This is where it ends. In AVM one, 360 00:30:06,100 --> 00:30:10,060 it is an instruction for the virtual machine. So function 361 00:30:10,080 --> 00:30:13,200 functions are defined by executing them. There is an 362 00:30:13,200 --> 00:30:16,100 instruction that says, I'm a function, and the next, like, 363 00:30:16,160 --> 00:30:22,540 20 bytes is code of me. And then the interpreter just, like, the 364 00:30:22,540 --> 00:30:25,760 virtual CPU just, like, goes over the 20 bytes, reads them in, 365 00:30:25,800 --> 00:30:29,940 and then there's a new function. This, of course, can be nested 366 00:30:29,940 --> 00:30:34,400 and, you know, they can be executed in line. So you define 367 00:30:34,400 --> 00:30:37,740 a function and it's right away executed. Anonymous functions. 368 00:30:40,080 --> 00:30:44,040 So this is just totally off the record sick. Well, they liked it 369 00:30:44,040 --> 00:30:47,240 so much that they implement their try catch finally blocks the same 370 00:30:47,240 --> 00:30:51,020 way. So there is an instruction that defines try catch finally in 371 00:30:51,020 --> 00:30:57,720 line when executing. This is obviously has a lot of design 372 00:30:57,720 --> 00:31:03,280 weaknesses. So to verify code, the first thing you want to 373 00:31:03,280 --> 00:31:06,900 verify is it doesn't jump in the middle of an instruction. Many of 374 00:31:06,900 --> 00:31:10,060 you have probably seen that in x86 code being done for the 375 00:31:10,080 --> 00:31:14,700 obfuscation. You can totally do that in flash as well. The 376 00:31:14,700 --> 00:31:18,140 funny thing is you can also just jump into the tag right before 377 00:31:18,140 --> 00:31:22,180 you in the flat file and execute some code in your MP3 or 378 00:31:22,180 --> 00:31:27,480 whatever. Like, hide your code in the nipples of the porn and 379 00:31:27,480 --> 00:31:31,580 then jump right there. In the image data, no problem. They do 380 00:31:31,580 --> 00:31:36,940 that. The 16 bit branch offset is also an interesting design 381 00:31:36,940 --> 00:31:39,860 decision. So I was wondering, when you have 16 bits signed, 382 00:31:40,080 --> 00:31:44,480 you can only jump over like 32K, right? Because then your bits run 383 00:31:44,480 --> 00:31:49,080 out. And so I was wondering what they do if you have an if statement 384 00:31:49,080 --> 00:31:52,360 with a large body. So I took the official flash player development 385 00:31:52,360 --> 00:31:57,160 environment, latest version CS4 and made an if statement with a 386 00:31:57,160 --> 00:32:00,840 large body. It perfectly, it never complained. It produced a 387 00:32:00,840 --> 00:32:04,260 flash file. It is perfectly invalid code because it jumps as 388 00:32:04,260 --> 00:32:10,020 far as it gets and then executes the rest of the body. The very 389 00:32:10,080 --> 00:32:12,780 curious length fields in the instruction set allow you to hide 390 00:32:12,780 --> 00:32:17,540 a lot of data in the tail of the instruction. And that's commonly 391 00:32:17,540 --> 00:32:23,760 done in flash code obfuscation software. So and as I said, the 392 00:32:23,760 --> 00:32:27,540 order of code execution is highly dependent on where the 393 00:32:27,540 --> 00:32:32,360 shape of the asshole currently is. So this is where Blitz 394 00:32:32,360 --> 00:32:34,800 Uplighter comes in and disassembles the whole thing and 395 00:32:34,800 --> 00:32:39,280 verifies a lot of things. So what we do when we disassemble it, 396 00:32:39,280 --> 00:32:40,060 the first thing we do when we disassemble it is we take the 397 00:32:40,080 --> 00:32:42,520 code and what we do is we go from byte offsets to instruction 398 00:32:42,520 --> 00:32:47,320 indices. So all the disassembly is an array. And if your byte 399 00:32:47,320 --> 00:32:51,400 offset actually doesn't resolve into a index in our array, then 400 00:32:51,400 --> 00:32:55,280 you're jumping somewhere you shouldn't jump to. And we are 401 00:32:55,280 --> 00:32:59,900 verifying the code flow stays within this code block and we 402 00:32:59,900 --> 00:33:02,740 verify all kinds of crazy shit about like this function 403 00:33:02,740 --> 00:33:07,740 declaration bullshit so they're not overlapping and all of that. 404 00:33:07,740 --> 00:33:15,220 And down to things like our all instruction, only part of 405 00:33:15,220 --> 00:33:19,200 exactly one function. Stuff like that. We just make sure it's 406 00:33:19,200 --> 00:33:22,900 good. Now once we make sure it's good, we still have that 407 00:33:22,900 --> 00:33:26,040 problem that remember when I talked about the ad networks and 408 00:33:26,040 --> 00:33:29,700 people that receive flash files? For them it's not a mail form 409 00:33:29,700 --> 00:33:32,860 flash file but functionality that can be implemented in flash 410 00:33:32,860 --> 00:33:36,740 AVM. So how do we actually get functional attacks to not work 411 00:33:36,740 --> 00:33:37,720 anymore? So the first thing we do is we take the code and we 412 00:33:37,720 --> 00:33:40,160 run static analysis on it. Now we have a nice and tidy swift 413 00:33:40,160 --> 00:33:44,280 file. We could run static analysis on it but static 414 00:33:44,280 --> 00:33:48,820 analysis provably will not resolve all possible cases. So 415 00:33:48,820 --> 00:33:53,480 we will not, it can be shown that we cannot possibly predict 416 00:33:53,480 --> 00:33:55,920 what the code is going to do. It's called the halting problem. 417 00:33:56,700 --> 00:34:02,580 Look it up. If we try to emulate it, we will run into the problem 418 00:34:02,580 --> 00:34:05,140 that our emulator does something and the flash player does 419 00:34:05,140 --> 00:34:07,700 something. And if our emulator does something and the flash 420 00:34:07,700 --> 00:34:10,280 player does something and the emulator isn't sick enough to be 421 00:34:10,280 --> 00:34:13,560 Adobe compliant, then we're actually like going two 422 00:34:13,560 --> 00:34:16,240 different ways with the code. So that's also not a good 423 00:34:16,240 --> 00:34:22,120 approach. However, when you do run time analysis, like if you 424 00:34:22,120 --> 00:34:26,160 have the specimen, what you usually do, run time analysis 425 00:34:26,160 --> 00:34:30,260 anywhere in this assembly, you set a break point at the point 426 00:34:30,260 --> 00:34:33,860 of execution, let's say the sys call. And no matter how much 427 00:34:33,860 --> 00:34:37,380 obfuscation was going on before and how complicated the argument 428 00:34:37,700 --> 00:34:41,480 was compiled together, at the point of the sys call, you just 429 00:34:41,480 --> 00:34:45,460 set a break point and you see what the argument was. So we 430 00:34:45,460 --> 00:34:47,660 want to do the same thing with the flash files. The problem is 431 00:34:47,660 --> 00:34:50,340 we're not part of the show anymore when the porn gets 432 00:34:50,340 --> 00:34:53,380 played, right? We already produced an output file. We're 433 00:34:53,380 --> 00:34:56,680 not debugging the flash player. But what we can do is we can 434 00:34:56,680 --> 00:35:00,720 actually patch the AVM code to do the check we wanted to do right 435 00:35:00,720 --> 00:35:04,960 at the point of execution. And this is what we do. So here's an 436 00:35:04,960 --> 00:35:07,680 example. There is action gating. This is an example of an action 437 00:35:07,700 --> 00:35:14,140 gating URL to second attempt at getting the op code right. That 438 00:35:14,140 --> 00:35:16,920 actually is the most common function that forwards your 439 00:35:16,920 --> 00:35:20,600 browser to a different URL and is used by most of the 440 00:35:20,600 --> 00:35:23,360 downloaders, like the flash downloaders that just download 441 00:35:23,360 --> 00:35:28,420 like scare wear onto your machine. So when we handle the 442 00:35:28,420 --> 00:35:31,060 flash file, for example, we know its origin. We know where it 443 00:35:31,060 --> 00:35:34,380 came from. No script passes this on to us. So we can actually 444 00:35:34,380 --> 00:35:37,680 patch more strict same origin policy checks. We can actually 445 00:35:37,680 --> 00:35:40,320 get the op code into the flash code itself than the player 446 00:35:40,320 --> 00:35:44,060 would actually do. And this is how it looks like in a code flow 447 00:35:44,060 --> 00:35:49,280 graph. So on the left-hand side, you see a basic block 448 00:35:49,280 --> 00:35:53,160 graph of AVM one code. And pretty much in the middle of it, 449 00:35:53,240 --> 00:35:58,140 there is a block with the ID 31. And this is where the actual 450 00:35:58,140 --> 00:36:02,700 execution of the action get URL happens. And before that, he's 451 00:36:02,700 --> 00:36:05,260 pushing the arguments on the stack. In this case, for 452 00:36:05,260 --> 00:36:07,660 example, it's pushing arguments out of the console. So this is 453 00:36:07,680 --> 00:36:12,260 a constant pull on the stack. So I'm coming back to those cases 454 00:36:12,260 --> 00:36:15,720 in a minute. But just notice that there's this one block 455 00:36:16,360 --> 00:36:22,240 where the actual action is fired. All op codes start with 456 00:36:22,240 --> 00:36:29,700 the word action. So don't feel silly or like a movie producer 457 00:36:30,400 --> 00:36:33,960 when you work with this shit. It's totally normal to say action 458 00:36:33,960 --> 00:36:37,660 every five minutes. So when we put in the code, we get the 459 00:36:37,680 --> 00:36:40,400 code, we patch it. This is what comes out. So you see that the 460 00:36:40,400 --> 00:36:45,500 one basic block with the ID 31 was split into three. The upper 461 00:36:45,500 --> 00:36:49,500 one, doing the validation and the string comparison, a strict 462 00:36:49,500 --> 00:36:53,240 string comparison between where the flash file came from and 463 00:36:53,240 --> 00:36:58,400 where it wants to forward to. And then if it's happy with the 464 00:36:58,400 --> 00:37:00,960 comparison, it forwards the browser. If it's not happy, 465 00:37:01,040 --> 00:37:06,940 it's just cleaning up the stack and not doing it which is what we 466 00:37:08,780 --> 00:37:14,080 So just to give you a feeling, there is a complete assembler 467 00:37:14,080 --> 00:37:19,160 for AVM 1 and 2. You can write flash assembly and text files 468 00:37:19,650 --> 00:37:24,440 and use that as replacement so you have a pretty high level of 469 00:37:24,440 --> 00:37:31,960 freedom. So this is the assembly for AVM 1 to how it calls 470 00:37:31,960 --> 00:37:36,400 methods and on the right-hand side you see all the 471 00:37:37,700 --> 00:37:42,520 instructions you need to execute to even figure out which method 472 00:37:42,520 --> 00:37:47,100 of which object is called. So you see it's a lot of code that 473 00:37:47,100 --> 00:37:51,660 goes into just finding out what the method of the object was. And 474 00:37:51,660 --> 00:37:55,080 if you actually decide to not call the method of the object, 475 00:37:55,200 --> 00:37:57,680 that's the amount of code that you need to clean up the stack 476 00:37:58,020 --> 00:38:01,940 and do stack unwinding in AVM 1. So this is the assembly for 477 00:38:01,960 --> 00:38:05,940 AVM 1. So when you apply this to a piece of malware, example 478 00:38:05,940 --> 00:38:13,700 Gnida, you see this is the complete code of Gnida. The one 479 00:38:13,700 --> 00:38:18,000 to the left in blue is the original code. The one to the 480 00:38:18,000 --> 00:38:23,600 right is the same code and all the red dots and places you see 481 00:38:23,600 --> 00:38:26,100 there, this is where we patched in additional checks 482 00:38:26,100 --> 00:38:29,900 automatically. You see it's quite a code inflation. So we're 483 00:38:30,290 --> 00:38:31,940 looking at 200,000, 200,000, 200,000, 200,000, 200,000, 200,000 484 00:38:31,960 --> 00:38:36,480 250% code inflation just to check that it's not doing 485 00:38:36,480 --> 00:38:40,700 something evil. I mean, it's still nice because it totally 486 00:38:40,700 --> 00:38:45,500 protects you. Every single call is protected, but it inflated the 487 00:38:45,500 --> 00:38:49,140 code way too much and so maybe the porn starts no longer being 488 00:38:49,600 --> 00:38:55,400 fluent. And you also run into problems with the signed jump 489 00:38:55,400 --> 00:38:58,980 targets because like the stuff you patch in is too big so you 490 00:38:58,980 --> 00:39:01,940 can't jump over it anymore. So there's a lot of stuff that you 491 00:39:01,960 --> 00:39:04,420 have to deal with. Therefore, we introduce static analysis into 492 00:39:04,420 --> 00:39:08,480 it. We can provably not determine every single call 493 00:39:08,480 --> 00:39:12,640 argument, especially not the dynamically generated, but we 494 00:39:12,640 --> 00:39:15,140 can try to prove the static generated. We can prove 495 00:39:15,140 --> 00:39:17,660 staticness for individual arguments. For that, we just 496 00:39:17,660 --> 00:39:22,520 need stack tracing. So what we do is we trace the stack back on 497 00:39:22,520 --> 00:39:27,060 the individual instructions and if we can tell it's a static 498 00:39:27,060 --> 00:39:31,940 argument, then we do the check right there. And then we can 499 00:39:31,960 --> 00:39:34,940 compare and don't patch the check code into the flash file. 500 00:39:35,260 --> 00:39:41,160 In order to determine the values, we actually need to obtain 501 00:39:41,160 --> 00:39:44,840 a code flow graph as well because of course the constant 502 00:39:44,840 --> 00:39:48,220 pool is not part of the file format, but it is another 503 00:39:48,220 --> 00:39:51,720 instruction. So since the constant pool creation is an 504 00:39:51,720 --> 00:39:55,380 instruction, you can actually overwrite your own constant pool 505 00:39:55,380 --> 00:39:59,180 in your own code. So we actually have to do complete code flow 506 00:39:59,180 --> 00:40:01,640 analysis in order to figure out which constant pool currently 507 00:40:01,960 --> 00:40:10,640 is on. On top of that, we're still a bit working on, but it's 508 00:40:10,640 --> 00:40:15,420 already part of the code, on higher level verification. So you 509 00:40:15,420 --> 00:40:18,640 can essentially say, this is the object, this is the method, 510 00:40:18,820 --> 00:40:21,260 and I want to have the following string comparison with the 511 00:40:21,260 --> 00:40:25,680 second argument of this method call, no matter if it's AVM one 512 00:40:25,680 --> 00:40:31,640 or two. And how that works right now is we have our own virtual 513 00:40:31,960 --> 00:40:35,800 machine, actually two, which get executed with individual parts 514 00:40:35,800 --> 00:40:38,780 of this question, like give me the second argument to this 515 00:40:38,780 --> 00:40:43,740 instruction here. So in those two possible cases, it's a static 516 00:40:43,740 --> 00:40:48,780 analysis engine. So it executes this step and tries to figure 517 00:40:48,780 --> 00:40:53,080 out the second argument. If it cannot provably figure out what 518 00:40:53,080 --> 00:40:55,980 the second argument is, or it can prove that it is a dynamic 519 00:40:55,980 --> 00:41:01,200 argument, then it will emit the respective, then it will stop 520 00:41:01,200 --> 00:41:01,940 execution. So what is the transaction type? This is the 521 00:41:01,940 --> 00:41:05,660 And then we run the same process again, but in a different mode. 522 00:41:05,860 --> 00:41:16,620 Instead of trying to prove staticness, it will actually emit the steps that it took in the first run as AVM1 code or AVM2 code. 523 00:41:17,000 --> 00:41:27,780 This allows us to have very small pieces in those steps and ensure that our static analysis tests and the tests we do in the actual AVM1 code are functional equivalent. 524 00:41:27,780 --> 00:41:33,640 Because otherwise we run into the problem that we test something different here than there, and that's not very useful. 525 00:41:35,200 --> 00:41:40,640 So we recently introduced AVM2 into BlitzSuppliter, so both AVMs are now covered. 526 00:41:42,600 --> 00:41:52,440 There's an interesting bit about the AVM2 specification, the ABC file format that I said they put complete file format into the file format. 527 00:41:52,660 --> 00:41:54,320 So there's an interesting thing here. 528 00:41:54,400 --> 00:41:56,320 There was apparently one way. 529 00:41:56,980 --> 00:41:57,760 One way. 530 00:41:57,780 --> 00:41:59,960 One-eyed guy between all the blind. 531 00:42:00,360 --> 00:42:03,760 And he wrote the specs, so he tried really hard to be smart. 532 00:42:03,960 --> 00:42:11,860 And he actually had a good trick to prevent all his less talented colleagues at Adobe from having integer overflows. 533 00:42:12,100 --> 00:42:17,960 He will actually put, like, all the length fields and counter fields at 30 bits, not 32 bits. 534 00:42:18,200 --> 00:42:23,100 So if you're an untalented programmer, you can add four of them and still not have an integer overflow. 535 00:42:23,880 --> 00:42:25,420 That is actually pretty smart. 536 00:42:26,360 --> 00:42:27,560 However, when you... 537 00:42:27,780 --> 00:42:36,880 When you take the official Tamarind, it's the open source implementation of AVM2, and it's pretty much the official thing, so it's Adobe people writing it. 538 00:42:38,780 --> 00:42:42,960 When you look into that, how they parse it, this is their C code. 539 00:42:43,160 --> 00:42:44,060 Of course they've written it in C. 540 00:42:44,220 --> 00:42:45,640 Nothing can possibly go wrong. 541 00:42:46,840 --> 00:42:56,120 This is how they parse the 30-bit field, and if I may direct your attention to the third line at the bottom, they're actually parsing 32-bit. 542 00:42:56,560 --> 00:42:57,760 So this... 543 00:42:57,780 --> 00:43:02,320 This one guy was actually pretty smart, but, yeah, he was pretty alone. 544 00:43:05,420 --> 00:43:11,000 Other than that, AVM2 is design-wise a lot closer to its predecessor as it should be. 545 00:43:11,720 --> 00:43:19,000 They finally figured out that you should have one constant pool, and they finally figured out that you should not define functions by instructions. 546 00:43:19,500 --> 00:43:21,440 I'm very grateful for that. 547 00:43:22,880 --> 00:43:27,080 The stack tracing is a little bit harder, but it's... 548 00:43:27,080 --> 00:43:44,800 Yeah, so the end goal is to really have it all unified, so for whoever wants to enforce rules in the code, that the definition is high-level enough for them to model their contractual requirements into actual code patches. 549 00:43:48,760 --> 00:43:51,540 So what happens when we use our tool? 550 00:43:52,080 --> 00:43:56,440 So far, not a single exploit that we have a specimen of. 551 00:43:57,140 --> 00:44:00,640 I actually managed to pass through the BlitzUplighter tool. 552 00:44:01,200 --> 00:44:07,560 Most exploit code, if you've seen in the demo, doesn't even bother to set the length fields right, so we catch it very early. 553 00:44:09,060 --> 00:44:13,100 But even those fixed actually never went through. 554 00:44:13,740 --> 00:44:26,100 There's two where I don't have an actual exploit, which pretty recent from this year, that exploit JPEG parsing. 555 00:44:26,100 --> 00:44:29,200 So they even managed to fuck up the JPEG parser. 556 00:44:30,680 --> 00:44:39,260 This one will, the state right now, still pass through, because we're still not validating media content within the flash file. 557 00:44:39,440 --> 00:44:42,420 But all the others were blocked. 558 00:44:42,760 --> 00:44:48,460 And all the recent vulnerabilities that came out were automatically blocked, because we don't need fucking signatures. 559 00:44:51,500 --> 00:44:53,480 We're using it for a while already. 560 00:44:54,300 --> 00:44:55,600 It does play porn. 561 00:44:56,320 --> 00:44:57,920 YouTube works, YouPorn works. 562 00:45:00,420 --> 00:45:00,900 Yeah. 563 00:45:01,740 --> 00:45:08,940 And just in case something doesn't work, you can also, like, turn off individual tech type parsers. 564 00:45:09,020 --> 00:45:14,520 So if you find that the tech type parser for funds misbehaves on you, you just turn it off in the configuration. 565 00:45:15,240 --> 00:45:17,720 And remember, there's also the complain button. 566 00:45:19,680 --> 00:45:26,080 Flash files with code obfuscation employing, like Hulu.com, will get rejected, because we don't know what's going to happen. 567 00:45:26,100 --> 00:45:29,500 Because we cannot prove that the code flow doesn't do anything shitty. 568 00:45:30,300 --> 00:45:33,080 And this is why you can configure exceptions in no script. 569 00:45:34,140 --> 00:45:38,900 Many third parties with generators produce plain utter bullshit. 570 00:45:39,600 --> 00:45:41,520 Simply because the flash player doesn't care. 571 00:45:42,280 --> 00:45:43,000 We do. 572 00:45:43,360 --> 00:45:44,700 So, yeah. 573 00:45:45,140 --> 00:45:52,760 If you have third parties with generating code anywhere in your company, I would be grateful if you would try whether it's eaten or not. 574 00:45:53,040 --> 00:45:56,080 And if it's eaten, then go beat up the people that create this. 575 00:45:58,720 --> 00:46:03,220 At this stage, we really need people reporting compatibility issues. 576 00:46:03,560 --> 00:46:07,880 So if the tits are green instead of blue, complain. 577 00:46:08,240 --> 00:46:10,760 Because that's something we cannot automatically test for. 578 00:46:11,020 --> 00:46:13,380 And there's just so much porn you can watch per day. 579 00:46:15,360 --> 00:46:16,920 And it's also highly annoying. 580 00:46:19,420 --> 00:46:22,080 So, we only, like, it's HTTP. 581 00:46:22,400 --> 00:46:25,100 You can sniff what we lock when you press complain. 582 00:46:25,480 --> 00:46:26,060 But it's just, you know, it's not going to work. 583 00:46:26,080 --> 00:46:27,000 It's just what you see in the dialogue. 584 00:46:28,020 --> 00:46:33,340 But I would ask you, if you're trying out this tool, really complain if shit doesn't work. 585 00:46:33,440 --> 00:46:37,080 Otherwise, we can't get it to the perfect state where we want it. 586 00:46:38,800 --> 00:46:41,700 If it does this to you, I also want to know. 587 00:46:42,080 --> 00:46:44,140 But the complain button will send it to Microsoft. 588 00:46:44,440 --> 00:46:49,160 So you actually would have to send me an email or go to the website where you can file bugs against me. 589 00:46:51,900 --> 00:46:53,680 Oh, I'm already at conclusions. Great. 590 00:46:54,040 --> 00:46:55,260 So, essentially, 591 00:46:56,080 --> 00:47:13,040 we're pretty confident that Blitzabliter, by principle, first and foremost, shows that signature-free recreation is a valuable way and alternative to detection paradigm, to AVs. 592 00:47:13,200 --> 00:47:22,660 By enforcing, by having secure parsers in managed languages and enforcing a structure that is documented and is tricked, 593 00:47:22,920 --> 00:47:26,060 you make it a lot harder for people to use. 594 00:47:26,080 --> 00:47:30,680 And you may be able to get through this to the broken parser at the end where you feed it to. 595 00:47:32,160 --> 00:47:37,400 We also think that automated code property verification and enforcement would be really, 596 00:47:37,480 --> 00:47:46,980 really interesting and useful for people that have that requirement and are also more applicable to other file formats. 597 00:47:48,200 --> 00:47:56,060 And we hope that this tool will actually decrease your attack surface and will allow you to not get owned when you use it. 598 00:47:56,080 --> 00:48:01,460 surf porn. Here's a couple of people working on this. Robert 599 00:48:01,460 --> 00:48:06,100 is one of our interns. He works on this code quite a lot. He 600 00:48:06,100 --> 00:48:09,560 hates Adobe as much as everyone else who wrote parsers for their 601 00:48:09,560 --> 00:48:15,680 file formats. Dirk is the guy who actually managed to be the 602 00:48:15,680 --> 00:48:21,020 free time for me so I can work on it. And Moonby is just 603 00:48:21,020 --> 00:48:23,620 generally awesome and actually plays tonight at the freak show 604 00:48:23,620 --> 00:48:28,320 so if you want to hear some good electronic music, come by. And 605 00:48:28,320 --> 00:48:35,320 that was it and I think I even have time for Q&A. And I have 606 00:48:35,320 --> 00:48:46,900 one more. Okay. First question gets it. What's the question? 607 00:48:53,620 --> 00:48:58,740 Proxy integration for squid is trivial. It's just command line. 608 00:48:59,020 --> 00:49:04,120 It really runs, you know, you can put it into squid, into a 609 00:49:04,120 --> 00:49:09,180 filter interface because it takes input and output. That's 610 00:49:09,180 --> 00:49:12,460 absolutely trivial but you can also link it into other code. 611 00:49:13,180 --> 00:49:21,620 It's a library. Okay. More questions? Did the 612 00:49:24,120 --> 00:49:30,040 question over here? Do you plan to talk to the people behind the 613 00:49:30,040 --> 00:49:40,140 flash block at all? Flash block is another browser plug-in? 614 00:49:40,440 --> 00:49:44,320 Yeah. It's specifically just to block flash. There's a lot of 615 00:49:44,320 --> 00:49:48,560 people that find no script. What browser is it for? 616 00:49:48,760 --> 00:49:53,600 Well, for firebox. Oh, totally. Like, I'm, you know, 617 00:49:53,620 --> 00:49:57,980 well, the point of giving this talk is I want feedback. And 618 00:49:58,480 --> 00:50:01,560 people that want to integrate it, that's the whole reason we make 619 00:50:01,560 --> 00:50:05,640 it public. And believe me, it's a lot of code. So I would love to 620 00:50:05,640 --> 00:50:09,380 have anyone who wants to integrate it anywhere, even in 621 00:50:09,380 --> 00:50:15,840 their, you know, I don't know, parking lot. So you think we 622 00:50:15,840 --> 00:50:19,820 should actively go out and seek them out? Well, I would say so 623 00:50:19,820 --> 00:50:23,000 because just because no script is so noisy, I think only super 624 00:50:23,620 --> 00:50:25,880 security people can, like, deal with how much you have to 625 00:50:25,880 --> 00:50:29,800 update stuff. Whereas flash block just makes all flash on the 626 00:50:29,800 --> 00:50:32,600 page just be placeholders by default. If you want to see the 627 00:50:32,600 --> 00:50:34,820 flash, you just click on it. So it's a lot more usable by 628 00:50:34,820 --> 00:50:37,420 normal users. So it would be more possible for them to 629 00:50:37,420 --> 00:50:43,960 manage this. Okay. Yeah. I'd try it. More questions? Any 630 00:50:43,960 --> 00:50:48,580 eagerness for me? Did we have issues with the Adobe 631 00:50:48,580 --> 00:50:52,860 documentation of their file format? Did we have issues 632 00:50:52,860 --> 00:50:55,780 with the Adobe documentation of their file format? Are you fucking 633 00:50:55,780 --> 00:51:04,280 kidding me? Of course we have. Dude, they have, like, the 634 00:51:04,280 --> 00:51:08,660 errata for the file format specification for ABC, for AVM2, 635 00:51:08,880 --> 00:51:12,800 sits on a fucking Mozilla Viki without being linked to from 636 00:51:12,800 --> 00:51:17,800 anywhere. Like, it requires some real Bing voodoo to actually get 637 00:51:17,800 --> 00:51:22,080 there. And then it contains things like, oops, those were 638 00:51:22,080 --> 00:51:22,840 actually in there. And then it contains things like, oops, 639 00:51:22,860 --> 00:51:25,760 and not full strings. Yeah, I noticed, we're trying to parse 640 00:51:25,760 --> 00:51:32,380 it, fuckers. Yeah. So that's my biggest thing with Adobe right 641 00:51:32,380 --> 00:51:38,820 now. I'm trying to get them to collaborate so we can tell them 642 00:51:38,820 --> 00:51:44,220 where our reading from the spec and the reality goes, like, this 643 00:51:44,220 --> 00:51:51,140 way. Because for example, on Adobe's site for, you know, on 644 00:51:51,140 --> 00:51:52,840 the definite for flash where they should have like a little bit of 645 00:51:52,840 --> 00:51:57,800 showcase flash in the samples. Half of the samples violate their own specification by 646 00:51:57,800 --> 00:52:04,600 not declaring the exception handlers they call. Does that answer your question? 647 00:52:05,000 --> 00:52:11,900 Do you want to go to a Q&A room? Okay. Do we have time for one more? 648 00:52:12,140 --> 00:52:15,440 You have time for one more question. Do we have one more question? 649 00:52:24,800 --> 00:52:36,020 We're expecting to improve the relationship with Adobe and get more specs. Okay. Thank 650 00:52:36,020 --> 00:52:37,880 you. Let's get drunk.