1 00:00:02,260 --> 00:00:04,400 Welcome to the annual DEF CON convention. 2 00:00:04,720 --> 00:00:09,740 This meeting was held in exciting Las Vegas, Nevada from July 9th through the 11th, 1999. 3 00:00:11,640 --> 00:00:17,500 This is video tape number 40, Security Problems Associated with Giant Sign Scripting. 4 00:00:24,440 --> 00:00:31,940 And what we do is we find and we fully disclose the holes that we find in these web services. 5 00:00:33,020 --> 00:00:34,780 So what kind of holes are these? 6 00:00:35,000 --> 00:00:36,520 Okay, these are the kinds of holes. 7 00:00:37,240 --> 00:00:43,060 By holes, I don't mean hacking into eBay and changing their website, posting up some alternate message. 8 00:00:43,600 --> 00:00:47,480 What I mean is gaining access to an arbitrary website. 9 00:00:47,500 --> 00:00:53,720 An arbitrary number of usernames and passwords from the eBay servers or the Hotmail servers, 10 00:00:54,900 --> 00:00:56,880 Exciter, Yahoo Mail, things like that. 11 00:00:59,540 --> 00:01:05,120 And the way that, what we focus on really is not working at the level of networking. 12 00:01:05,520 --> 00:01:06,840 So we work a little bit higher. 13 00:01:06,940 --> 00:01:08,800 We work at the level of the application itself. 14 00:01:10,400 --> 00:01:14,900 So we're not going in and we're not trying to compromise a firewall. 15 00:01:15,340 --> 00:01:15,460 Okay? 16 00:01:17,500 --> 00:01:18,500 We're not taking root on the server. 17 00:01:18,960 --> 00:01:25,300 We're actually taking advantage of holes that are in the web application layer. 18 00:01:25,640 --> 00:01:29,040 So hypertext transfer protocol and above the actual application itself. 19 00:01:29,880 --> 00:01:29,920 Okay. 20 00:01:30,440 --> 00:01:31,740 And we'll see how that's done. 21 00:01:33,520 --> 00:01:38,060 And some of our targets have been, like I say, Hotmail, Yahoo, eBay, Lycos, Eudora, 22 00:01:38,120 --> 00:01:42,080 a whole bunch of services powered by iNet Address and ExciteMail. 23 00:01:44,920 --> 00:01:45,960 So, yeah. 24 00:01:45,960 --> 00:01:49,080 So we are going to spend some time talking about Java, JavaScript, VBScript, Shockwave, 25 00:01:49,280 --> 00:01:51,200 and all these client-side technologies. 26 00:01:51,440 --> 00:01:51,560 Okay? 27 00:01:51,640 --> 00:01:56,360 Because the way, it's funny, a lot of these large corporations spend a lot of money, 28 00:01:56,420 --> 00:01:59,720 a lot of energy, pay a lot of attention to gaining a really secure network. 29 00:02:01,080 --> 00:02:04,420 And it turns out that the application itself is inherently insecure. 30 00:02:04,600 --> 00:02:08,600 So you don't have to know a bloody thing about networking in order to get in and compromise the system. 31 00:02:09,620 --> 00:02:14,500 And frighteningly enough, you don't actually even need to know a lot about server-side, 32 00:02:14,540 --> 00:02:15,940 I mean, client-side programming. 33 00:02:15,940 --> 00:02:21,600 A few lines of JavaScript is all it took to gain an arbitrary number of Hotmail usernames 34 00:02:21,600 --> 00:02:21,960 and passwords. 35 00:02:28,720 --> 00:02:29,240 Okay. 36 00:02:29,380 --> 00:02:31,420 And just a little bit about our resources. 37 00:02:32,140 --> 00:02:37,600 Like I say, we're a small group and everything we do is pretty well financed out of our own pocket. 38 00:02:38,300 --> 00:02:45,700 We run our stuff off really old boxes, 486s, running free BSD, and we lease a backroom space 39 00:02:45,940 --> 00:02:47,020 from our internet service provider. 40 00:02:47,240 --> 00:02:50,220 Our major cost is our internet service provider, 41 00:02:50,400 --> 00:02:51,460 which is about $200 a month. 42 00:02:51,580 --> 00:02:52,700 We do most of our work from home. 43 00:02:53,600 --> 00:02:56,020 So we don't collect any money from the holes that we find. 44 00:02:56,700 --> 00:02:59,260 We don't have any form of advertising or sponsorship, 45 00:02:59,480 --> 00:03:01,020 and we don't sell a product or a service. 46 00:03:01,720 --> 00:03:04,300 So we all have, you know, day jobs, 47 00:03:04,440 --> 00:03:07,360 and this is sort of what we do when we come home 48 00:03:07,360 --> 00:03:09,620 and to unwind, I guess. 49 00:03:13,020 --> 00:03:16,460 Okay, so the philosophy behind these sort of the exploits 50 00:03:16,460 --> 00:03:17,680 that we find, like I say, 51 00:03:18,180 --> 00:03:19,920 we find that in order to, 52 00:03:19,980 --> 00:03:22,240 when we do find a major hole in a large web service, 53 00:03:23,220 --> 00:03:26,240 we find that the best way to get it fixed 54 00:03:26,240 --> 00:03:28,460 is basically to fully disclose the nature of the problem. 55 00:03:28,740 --> 00:03:31,120 That means provide full source and instructions 56 00:03:31,120 --> 00:03:32,320 on how it can be done, 57 00:03:32,440 --> 00:03:35,380 and also, and this is really helpful for working with the media, 58 00:03:35,600 --> 00:03:37,780 actually provide an online working demo 59 00:03:38,320 --> 00:03:39,520 so that anybody can go, 60 00:03:39,620 --> 00:03:40,920 go to the site and pop credit from themselves. 61 00:03:41,360 --> 00:03:43,180 And, you know, there was a really interesting talk yesterday 62 00:03:43,860 --> 00:03:45,540 about a fellow here that was talking about 63 00:03:45,940 --> 00:03:47,940 how to, how you can interact with the media. 64 00:03:48,380 --> 00:03:52,900 And he was suggesting that you shift the onus to the hacker 65 00:03:52,900 --> 00:03:56,740 to educate, educate the media. 66 00:03:57,240 --> 00:03:59,000 Whether or not that's fair, that's actually the case. 67 00:03:59,060 --> 00:04:00,760 And my recommendation is that 68 00:04:02,180 --> 00:04:03,600 don't let the media write your story. 69 00:04:03,640 --> 00:04:04,340 Write your own story. 70 00:04:04,400 --> 00:04:05,440 Put it up on your own website 71 00:04:05,440 --> 00:04:06,660 and then just point them to the website. 72 00:04:06,860 --> 00:04:08,420 That's the best way for them to get the facts straight. 73 00:04:11,180 --> 00:04:14,460 Okay. Anyway, the net result of finding these holes 74 00:04:14,460 --> 00:04:16,260 is that they result in a better web-based service. 75 00:04:16,460 --> 00:04:18,980 Okay. So the whole point of finding these security holes 76 00:04:18,980 --> 00:04:23,500 is to improve the service, not to go out and, you know, 77 00:04:23,500 --> 00:04:26,220 bring them down by storing thousands of user names 78 00:04:26,220 --> 00:04:27,240 and passwords in a database 79 00:04:27,240 --> 00:04:30,200 and then writing a program that does some funny stuff. 80 00:04:34,540 --> 00:04:36,920 Okay. So in the experts we found, 81 00:04:36,980 --> 00:04:39,600 there's been sort of a funny kind of a pattern, a life cycle, 82 00:04:39,620 --> 00:04:40,720 almost, to the exploit. 83 00:04:42,220 --> 00:04:44,880 It tends to be the same thing over and over again. 84 00:04:44,940 --> 00:04:48,700 When you find a hole, and again, I'm focusing on these holes 85 00:04:48,700 --> 00:04:53,460 that are accomplished through client-side programming. 86 00:04:54,460 --> 00:04:58,140 Generally, the first thing we do is we warn the web-based service 87 00:04:58,140 --> 00:05:00,180 that they do, in fact, have a major security hole. 88 00:05:00,620 --> 00:05:04,760 And it's quite common, actually, to get ignored or banned 89 00:05:04,760 --> 00:05:09,420 or just plainly refuted, or all three. 90 00:05:10,940 --> 00:05:13,040 So the next step, the next thing that we do, 91 00:05:13,100 --> 00:05:15,240 is we post a working demo on the source code on our website. 92 00:05:17,300 --> 00:05:21,340 After that, usually, the web community picks up on it. 93 00:05:21,380 --> 00:05:22,800 It gets into bug tracking news groups, 94 00:05:23,000 --> 00:05:24,780 and the web media picks it up. 95 00:05:24,960 --> 00:05:28,460 Align.com and news.com and slash.com and things like that. 96 00:05:29,740 --> 00:05:31,400 And if it generates enough interest, 97 00:05:31,880 --> 00:05:34,240 which is usually the case if it's a major enough hole, 98 00:05:34,360 --> 00:05:36,400 then the paper media picks it up. 99 00:05:36,740 --> 00:05:39,520 A local paper or a national paper or something 100 00:05:39,520 --> 00:05:39,920 like that. 101 00:05:40,040 --> 00:05:41,540 And it starts getting thrown around the papers. 102 00:05:42,840 --> 00:05:45,240 And basically, once the web media picks it up, 103 00:05:45,280 --> 00:05:47,800 the online service itself will have a knee-jerk reaction. 104 00:05:49,360 --> 00:05:51,920 And they will quickly try and fix the problem overnight, 105 00:05:52,500 --> 00:05:55,540 which is a sort of a, uh-oh, patch. 106 00:05:56,720 --> 00:05:59,800 There's a major problem, and that suddenly the information 107 00:05:59,800 --> 00:06:01,880 is posted out there on the web for anyone to see. 108 00:06:02,280 --> 00:06:03,880 And the first thing that they want to do 109 00:06:03,880 --> 00:06:05,620 is they want to patch the problem as quickly as possible. 110 00:06:05,720 --> 00:06:08,840 So generally, they will put out a patch that specifically targets, 111 00:06:08,840 --> 00:06:12,580 uh, the, uh, the demonstration that's been put online, right? 112 00:06:14,180 --> 00:06:17,240 Without actually, in many cases, solving the underlying problem. 113 00:06:17,500 --> 00:06:20,340 So it's not uncommon for them to release a quick fix 114 00:06:20,700 --> 00:06:22,860 and then to be able to compromise that again the next day. 115 00:06:24,240 --> 00:06:25,280 Which is pretty funny. 116 00:06:27,740 --> 00:06:30,820 And, of course, the net result is that we all get rich and famous. 117 00:06:31,000 --> 00:06:32,560 Well, not rich and famous. 118 00:06:35,840 --> 00:06:38,620 But it does result in a better product, and we feel much better about ourselves. 119 00:06:42,600 --> 00:06:43,040 Okay. 120 00:06:43,480 --> 00:06:47,660 So, just briefly, I'd like to talk about, just to sort of set the stage for, 121 00:06:47,680 --> 00:06:52,760 uh, set the stage for understanding how, how can it be so easy 122 00:06:52,760 --> 00:06:56,500 to gain access to all this data sitting behind ultra-secure firewalls, etc. 123 00:06:56,960 --> 00:07:01,580 To set the stage, I'm going to have to talk a little bit about, um, HTML 124 00:07:01,580 --> 00:07:05,520 and the interaction between a web client and a web server. 125 00:07:06,040 --> 00:07:06,480 Okay. 126 00:07:07,000 --> 00:07:08,520 Okay, so HTML in brief. 127 00:07:08,620 --> 00:07:09,980 Let's get this over with in 22 seconds. 128 00:07:10,040 --> 00:07:12,780 Just out of curiosity, how many people here actually have worked in HTML? 129 00:07:13,620 --> 00:07:15,140 Oh, the vast majority. Okay. 130 00:07:15,200 --> 00:07:17,200 And I was sort of thinking that you were all networking gurus 131 00:07:17,200 --> 00:07:18,880 that, uh, didn't bother going up that high. 132 00:07:19,360 --> 00:07:20,260 Okay. That's cool. 133 00:07:22,300 --> 00:07:25,300 Okay, so, in that case, I, I really can make this brief. 134 00:07:25,360 --> 00:07:28,820 As we all know, at its simplest, uh, HTML is, uh, 135 00:07:29,280 --> 00:07:32,260 is a series of tags that, that's applied to a text in a text document 136 00:07:32,260 --> 00:07:35,580 to mark it up so that when it's displayed by a browser, the browser will, 137 00:07:35,680 --> 00:07:38,420 you know, to make a, a long story short, so that the browser will know 138 00:07:38,620 --> 00:07:39,440 how to display it, right? 139 00:07:39,460 --> 00:07:44,780 How to format it, what images to display, um, and things like that. 140 00:07:45,440 --> 00:07:48,060 So, yeah, the browser reads the tags for information on formatting, 141 00:07:48,300 --> 00:07:50,900 uh, you know, creating hyperlinks, displaying images, 142 00:07:51,840 --> 00:07:54,600 and that's really what a super simple web page is, right? 143 00:07:54,740 --> 00:07:56,840 At its heart, the web is all about text and images. 144 00:07:57,140 --> 00:07:58,720 At least that, that's what it was originally. 145 00:07:58,840 --> 00:08:02,320 And then, the web became more complicated than that, right? 146 00:08:02,380 --> 00:08:05,480 Suddenly people, well, actually this was built in from the very beginning, 147 00:08:05,620 --> 00:08:07,740 but the web became more complicated because 148 00:08:07,740 --> 00:08:12,080 we now had the power to do server-side processing, right? 149 00:08:12,160 --> 00:08:16,920 We had the ability to tie the front end into a back end through HTML forms. 150 00:08:19,300 --> 00:08:21,440 So, that's server-side processing, right? 151 00:08:21,580 --> 00:08:22,880 CGI scripting initially. 152 00:08:24,020 --> 00:08:27,300 So we could connect the front end to the back end. 153 00:08:27,800 --> 00:08:29,400 And then another cool thing came along. 154 00:08:29,980 --> 00:08:33,920 Suddenly we found that we could do client-side scripting, right? 155 00:08:34,140 --> 00:08:37,720 So using things like JavaScript, Java, Apple, Shockwave, 156 00:08:37,720 --> 00:08:38,840 Flash, right? 157 00:08:38,940 --> 00:08:40,640 And all the stuff that comes in with the plug-ins. 158 00:08:41,140 --> 00:08:44,940 Suddenly we had the option to either do processing right in the browser itself, 159 00:08:45,720 --> 00:08:50,620 or to transfer all the knowledge or all the data that a user fills out in a form, 160 00:08:50,840 --> 00:08:52,560 send that back over to the server, 161 00:08:52,640 --> 00:08:56,420 and then have the server do some form of processing and create a follow-up page. 162 00:09:00,340 --> 00:09:00,780 Okay. 163 00:09:04,440 --> 00:09:04,880 So. 164 00:09:04,880 --> 00:09:07,860 The link between the front end and the back end. 165 00:09:08,080 --> 00:09:08,900 Let's look at that. 166 00:09:09,260 --> 00:09:09,620 Okay? 167 00:09:09,740 --> 00:09:11,960 Because I want to talk, focus a little bit on the back end. 168 00:09:12,020 --> 00:09:12,940 The server-side programming. 169 00:09:13,220 --> 00:09:16,340 The link between the front end and the back end is an HTML form. 170 00:09:16,640 --> 00:09:17,560 What is a form? 171 00:09:17,700 --> 00:09:21,120 A form is just a collection of graphical user interface elements. 172 00:09:21,480 --> 00:09:21,820 Right? 173 00:09:21,880 --> 00:09:28,780 So things like text boxes, text fields, radio buttons, check boxes, things like that. 174 00:09:29,020 --> 00:09:29,420 Right? 175 00:09:29,440 --> 00:09:30,080 That's a form. 176 00:09:31,140 --> 00:09:33,160 And it's implemented as an HTML tag. 177 00:09:33,720 --> 00:09:34,160 Okay? 178 00:09:34,680 --> 00:09:38,400 Now the tag, that form tag that makes those graphical user interface elements 179 00:09:38,400 --> 00:09:40,160 also provides other information. 180 00:09:40,820 --> 00:09:40,900 Okay? 181 00:09:42,860 --> 00:09:46,080 It also points to, you can see up here. 182 00:09:46,600 --> 00:09:48,120 Here's an example of a form tag. 183 00:09:48,220 --> 00:09:48,400 Right? 184 00:09:48,480 --> 00:09:53,520 You can see that actually, it has an action attribute there that actually points to 185 00:09:53,520 --> 00:09:56,940 the server-side programming that's going to process the form data. 186 00:09:57,380 --> 00:09:57,860 Right? 187 00:09:59,680 --> 00:10:03,720 It also has an attribute called method, which can either be set to post or get. 188 00:10:03,720 --> 00:10:10,040 That just basically, that basically specifies how the data is going to be transmitted to 189 00:10:10,040 --> 00:10:10,440 the server. 190 00:10:11,160 --> 00:10:14,880 And here you have some input tags and those actually create the graphical user interface 191 00:10:14,880 --> 00:10:15,700 elements themselves. 192 00:10:16,200 --> 00:10:16,360 Okay? 193 00:10:16,420 --> 00:10:18,260 So in a form you have two things. 194 00:10:18,340 --> 00:10:21,340 The form allows you to create the graphical user interface elements. 195 00:10:22,780 --> 00:10:26,620 And inside those, inside the form, the form holds the data. 196 00:10:26,940 --> 00:10:27,380 Okay? 197 00:10:27,460 --> 00:10:28,740 That the user will be typing in. 198 00:10:30,160 --> 00:10:30,600 Okay? 199 00:10:30,760 --> 00:10:32,700 So if you have a name and password field. 200 00:10:33,260 --> 00:10:33,700 Right? 201 00:10:33,700 --> 00:10:36,760 In a web application, someone types their name and password into a form. 202 00:10:38,440 --> 00:10:43,580 That data is a part of the form and can be accessed, as we'll see later, through client-side 203 00:10:43,580 --> 00:10:44,140 scripting. 204 00:10:44,280 --> 00:10:44,520 Okay? 205 00:10:44,580 --> 00:10:45,980 It's considered to be a part of the form now. 206 00:10:46,520 --> 00:10:50,100 Accessible through the document object model, which I'll talk about a bit later. 207 00:10:50,300 --> 00:10:50,640 Okay. 208 00:10:50,680 --> 00:10:54,260 So anyway, the big picture is that the form ties the front end to the back end and it 209 00:10:54,260 --> 00:10:56,440 contains the data that people fill in in the form itself. 210 00:10:58,440 --> 00:10:58,780 Okay. 211 00:10:58,940 --> 00:11:00,420 So people go to the form. 212 00:11:00,460 --> 00:11:01,380 They fill out all their information. 213 00:11:01,500 --> 00:11:02,200 They fill out their username. 214 00:11:02,300 --> 00:11:03,040 They fill out the password. 215 00:11:03,040 --> 00:11:04,460 They click the submit button. 216 00:11:04,500 --> 00:11:05,060 And what happens? 217 00:11:05,260 --> 00:11:11,780 All that great data in the form gets packaged up and sent over to the server-side program 218 00:11:11,780 --> 00:11:14,820 that is specified here in this action field. 219 00:11:15,060 --> 00:11:15,480 All right? 220 00:11:15,500 --> 00:11:16,760 So it gets sent over to the server-side program. 221 00:11:17,120 --> 00:11:21,480 The server-side program takes those name-value pairs, in other words, the data from the form, 222 00:11:21,620 --> 00:11:26,380 does something useful, who knows what, and then creates a follow-up page. 223 00:11:27,220 --> 00:11:27,660 Okay. 224 00:11:27,660 --> 00:11:28,580 We're all familiar with this. 225 00:11:28,640 --> 00:11:29,740 I'm not going to belabor the point. 226 00:11:29,820 --> 00:11:31,260 But, you know, we've all used search engines. 227 00:11:31,340 --> 00:11:31,520 Right? 228 00:11:31,520 --> 00:11:35,800 We've all, many of us have probably used webmail and e-commerce sites. 229 00:11:35,940 --> 00:11:36,060 Okay. 230 00:11:36,120 --> 00:11:39,540 This is the basic premise behind all that cool stuff. 231 00:11:39,880 --> 00:11:40,300 Okay. 232 00:11:40,740 --> 00:11:44,240 Most of the time, you're actually just sending the data over to a server-side program. 233 00:11:48,640 --> 00:11:51,800 So what is the form? 234 00:11:51,960 --> 00:11:56,200 The form really constitutes the basis of a web application. 235 00:11:56,960 --> 00:11:57,480 Right? 236 00:11:57,560 --> 00:12:01,380 It's pretty hard to have a web application or a portal site or whatever you want to call 237 00:12:01,380 --> 00:12:04,920 it without using forms, without tying the front end to the back end. 238 00:12:05,340 --> 00:12:05,560 Right? 239 00:12:07,820 --> 00:12:11,220 This form will contain user authentication information. 240 00:12:12,600 --> 00:12:17,820 In some way, shape, or form, a web application has to keep track of its users. 241 00:12:18,140 --> 00:12:18,460 Right? 242 00:12:18,760 --> 00:12:20,220 It has to keep track of who you are. 243 00:12:20,520 --> 00:12:21,440 What are you ordering? 244 00:12:21,600 --> 00:12:22,460 What's your credit card number? 245 00:12:22,740 --> 00:12:23,220 Okay. 246 00:12:24,420 --> 00:12:28,860 But the basic user authentication information is quite likely, quite often, passed back 247 00:12:28,860 --> 00:12:31,300 and forth between the client and the server. 248 00:12:31,300 --> 00:12:32,040 Okay. 249 00:12:32,360 --> 00:12:36,080 So usually, just by looking at a form and a page, you can pick up a lot of really useful 250 00:12:36,080 --> 00:12:36,440 information. 251 00:12:37,100 --> 00:12:42,500 So the bottom line is that when you are in a session with a web application, what you 252 00:12:42,500 --> 00:12:48,000 don't want is you wouldn't like it if somebody else could see the values inside your form. 253 00:12:48,520 --> 00:12:48,920 Okay. 254 00:12:48,980 --> 00:12:49,840 Because that's your data. 255 00:12:50,000 --> 00:12:53,920 It's your username, your password, your credit card number is what's sitting in that 256 00:12:53,920 --> 00:12:54,140 form. 257 00:12:54,240 --> 00:12:54,400 Right? 258 00:12:54,620 --> 00:12:58,280 And generally speaking, it would be pretty hard for someone to be able to reach into 259 00:12:58,280 --> 00:13:00,320 that form and grab that data out of there. 260 00:13:00,320 --> 00:13:01,480 Because it's on your webpage. 261 00:13:01,700 --> 00:13:01,840 Right? 262 00:13:01,880 --> 00:13:02,920 Nobody else has it, just you. 263 00:13:03,160 --> 00:13:07,640 Everybody has their own username and password embedded in the form that they get from the 264 00:13:07,640 --> 00:13:08,320 web application. 265 00:13:09,340 --> 00:13:10,280 So what's the problem? 266 00:13:10,400 --> 00:13:11,520 How can there be a security hole? 267 00:13:18,620 --> 00:13:21,200 Well, to understand that, we have to have a look at the other side. 268 00:13:21,280 --> 00:13:22,200 Let's look at the flip side now. 269 00:13:22,240 --> 00:13:23,360 Let's just look at the client side. 270 00:13:23,800 --> 00:13:27,220 Let's say we want to do processing but we don't want to communicate with the server. 271 00:13:27,380 --> 00:13:27,620 Right? 272 00:13:27,620 --> 00:13:30,140 We don't want to send all that data back to the server for processing. 273 00:13:30,180 --> 00:13:31,700 We want to do it all in the browser itself. 274 00:13:32,080 --> 00:13:37,900 We can do that using client side technologies like JavaScript, VBScript, Shockwave, Flash, 275 00:13:39,140 --> 00:13:40,080 Java applets. 276 00:13:40,440 --> 00:13:40,720 Okay? 277 00:13:41,280 --> 00:13:45,720 So of those, you can sort of break all those client side technologies down into two major 278 00:13:45,720 --> 00:13:46,060 groups. 279 00:13:47,380 --> 00:13:52,680 In one case, the actual code is sitting right inside the HTML document. 280 00:13:53,100 --> 00:13:53,580 Okay. 281 00:13:53,620 --> 00:13:57,580 So it's right inside script tags, smack right there in the HTML document. 282 00:13:57,620 --> 00:13:58,180 Okay? 283 00:13:59,280 --> 00:14:01,340 Examples of that are JavaScript and VBScript. 284 00:14:03,360 --> 00:14:10,480 In the other case, the code is not sitting right in the HTML document, but it's actually 285 00:14:10,480 --> 00:14:12,400 sitting in a separate file on the web server. 286 00:14:12,640 --> 00:14:18,520 And what the browser does is the browser has to go fetch that file, download it, execute 287 00:14:18,520 --> 00:14:18,860 it. 288 00:14:19,260 --> 00:14:19,760 Okay? 289 00:14:20,320 --> 00:14:24,020 So either the code is directly in the HTML document or it's in a separate document, 290 00:14:24,160 --> 00:14:26,480 like a class file if it's Java. 291 00:14:26,640 --> 00:14:26,800 Right? 292 00:14:27,100 --> 00:14:27,600 Okay. 293 00:14:29,480 --> 00:14:32,640 So which of these, out of these two categories, which is the most powerful? 294 00:14:32,740 --> 00:14:33,960 Which presents the biggest threat? 295 00:14:34,160 --> 00:14:35,160 Well, we all present a threat. 296 00:14:35,260 --> 00:14:39,620 We've shown holes with both kinds of client side technologies. 297 00:14:39,880 --> 00:14:42,820 But generally speaking, category A is more powerful. 298 00:14:43,260 --> 00:14:43,440 Okay? 299 00:14:43,440 --> 00:14:48,440 Category A has more direct control over the document object model, has more control over 300 00:14:48,440 --> 00:14:52,440 being able to manipulate the different aspects of an HTML document. 301 00:14:52,720 --> 00:14:53,080 Okay? 302 00:14:53,120 --> 00:14:57,580 So JavaScript and VBScript are more powerful. 303 00:14:57,580 --> 00:15:04,880 And of those two, JavaScript is more powerful simply because it's supported in more browsers. 304 00:15:05,100 --> 00:15:05,220 Okay? 305 00:15:05,260 --> 00:15:08,360 JavaScript is supported in both Netscape and Internet Explorer. 306 00:15:10,260 --> 00:15:14,300 Although I'm sure Microsoft is calling it JScript or something ridiculous like that. 307 00:15:16,160 --> 00:15:17,760 Oh, I already seen that one. 308 00:15:27,060 --> 00:15:28,460 I think we just saw this one. 309 00:15:31,460 --> 00:15:31,820 Okay. 310 00:15:32,620 --> 00:15:34,600 So how powerful is this JavaScript anyway? 311 00:15:34,720 --> 00:15:35,300 What can it do? 312 00:15:35,420 --> 00:15:36,280 What can it not do? 313 00:15:38,040 --> 00:15:38,400 Okay. 314 00:15:38,420 --> 00:15:39,940 Well, first that's, I mean, it's very powerful. 315 00:15:40,120 --> 00:15:42,220 So let's start with what JavaScript can't do. 316 00:15:42,440 --> 00:15:42,800 Okay. 317 00:15:42,840 --> 00:15:45,560 JavaScript cannot reach into the local file system. 318 00:15:46,340 --> 00:15:46,700 Okay? 319 00:15:46,720 --> 00:15:47,740 And that can be very powerful. 320 00:15:47,760 --> 00:15:50,560 and I know that you can use JavaScript to set cookies and stuff, 321 00:15:50,680 --> 00:15:53,580 but in general, JavaScript cannot reach into the local file system. 322 00:15:53,660 --> 00:15:55,900 So you don't have to worry about downloading somebody's HTML page 323 00:15:55,900 --> 00:15:58,020 and having a rogue JavaScript applet, 324 00:15:58,080 --> 00:16:01,440 or a rogue piece of JavaScript that's going to go deleting your hard drive. 325 00:16:02,740 --> 00:16:05,300 JavaScript can't reach into your local file system. 326 00:16:12,960 --> 00:16:14,220 Now what it can do, 327 00:16:15,380 --> 00:16:17,200 there's another restriction that I want to talk about, 328 00:16:17,760 --> 00:16:21,160 how many of us, well I suppose that if many of us are familiar with HTML, 329 00:16:21,360 --> 00:16:23,600 we're also familiar with framed documents, right? 330 00:16:23,760 --> 00:16:26,440 So that's when you go to a website and the website is broken up into frames, 331 00:16:26,700 --> 00:16:29,640 each frame holds a different HTML document, right? 332 00:16:29,700 --> 00:16:33,520 So in that case, the website is containing more than one HTML document at a time. 333 00:16:33,880 --> 00:16:36,880 Can JavaScript be in one of those documents 334 00:16:36,880 --> 00:16:40,680 and reach over and manipulate what's going on in one of the other frames? 335 00:16:41,180 --> 00:16:41,920 It depends. 336 00:16:43,580 --> 00:16:46,200 If the HTML document in those other frames 337 00:16:46,200 --> 00:16:47,740 is basically coming from the same, 338 00:16:47,760 --> 00:16:48,220 same domain, 339 00:16:48,500 --> 00:16:49,940 no, it can't. 340 00:16:50,080 --> 00:16:51,760 If it's a different website entirely, 341 00:16:52,060 --> 00:16:53,360 no, not really, it can't. 342 00:16:56,600 --> 00:17:00,580 Same applies for actually having another browser window open at the same time 343 00:17:00,580 --> 00:17:02,700 that has another HTML document loaded into it. 344 00:17:03,240 --> 00:17:07,860 Okay, so that's what JavaScript cannot do. 345 00:17:08,020 --> 00:17:09,320 What can JavaScript do? 346 00:17:10,540 --> 00:17:12,240 Well, JavaScript can do a lot. 347 00:17:12,920 --> 00:17:17,040 Usually it's used for things like validating its legitimate uses, 348 00:17:17,040 --> 00:17:19,620 or things like form validation and image swapping. 349 00:17:19,800 --> 00:17:22,400 You know, when you surf around the web and you move your mouse over 350 00:17:22,400 --> 00:17:25,940 and then your bar in the image lights up or something like that, right? 351 00:17:25,980 --> 00:17:26,820 That's done with JavaScript. 352 00:17:27,520 --> 00:17:30,300 Or you type in, you go to a page and you type in your name 353 00:17:30,300 --> 00:17:31,940 and you click the submit button, 354 00:17:32,340 --> 00:17:34,080 but you forgot to type in your last name. 355 00:17:34,320 --> 00:17:37,300 Even before the browser bothers to contact the server, 356 00:17:37,480 --> 00:17:39,340 a client-side process will occur 357 00:17:39,740 --> 00:17:43,880 where it validates a form input to see whether or not you forgot to fill in one of the fields, right? 358 00:17:44,300 --> 00:17:46,580 So that's called form validation, you do that with JavaScript. 359 00:17:55,620 --> 00:17:59,980 Now, what makes JavaScript powerful is that 360 00:18:00,980 --> 00:18:06,520 we can open up a sort of HTML document for output. 361 00:18:06,760 --> 00:18:09,840 So it can write arbitrary text to the browser. 362 00:18:10,020 --> 00:18:12,640 So it can create a follow-up page, right? 363 00:18:12,660 --> 00:18:15,680 It can dynamically create an HTML document, okay? 364 00:18:17,140 --> 00:18:22,860 It can also look around in the HTML document that it's embedded in, okay? 365 00:18:22,900 --> 00:18:27,720 So it can, if there's also a form on the same page as the JavaScript, 366 00:18:28,580 --> 00:18:31,240 or even in a separate frame that it has access to, 367 00:18:31,840 --> 00:18:34,220 the JavaScript can reach right into that form 368 00:18:34,220 --> 00:18:39,020 and pull out whatever data is in that form, okay? 369 00:18:39,300 --> 00:18:41,860 So JavaScript can suck the data out of a form. 370 00:18:43,160 --> 00:18:46,400 Now, so far, it still isn't clear how this could compromise security, right? 371 00:18:46,400 --> 00:18:51,280 Because the JavaScript is on your page, the form is on your page, right? 372 00:18:51,380 --> 00:18:53,340 Or the page of an internet service provider. 373 00:18:53,720 --> 00:18:57,300 So why would anybody write JavaScript to compromise their own form? 374 00:19:01,060 --> 00:19:02,740 Well, let's see what the problem is. 375 00:19:10,460 --> 00:19:15,080 Actually, before I tell you the big secret about how it compromises security, 376 00:19:15,160 --> 00:19:16,200 there's one more thing I want to cover. 377 00:19:17,640 --> 00:19:23,400 Is JavaScript only limited to, is its power only limited to the client side? 378 00:19:23,640 --> 00:19:25,220 Or can it actually interact with the server? 379 00:19:25,660 --> 00:19:28,780 Well, it can't directly interact with the server. 380 00:19:28,980 --> 00:19:31,900 But like I say, what it can do is it can read information from the form. 381 00:19:32,400 --> 00:19:37,400 And what it can do is it can also send data, okay? 382 00:19:37,480 --> 00:19:41,900 It can basically redirect the browser to a new arbitrary URL, okay? 383 00:19:42,000 --> 00:19:46,380 So using a GET request, it can actually contact any server-side provider. 384 00:19:46,400 --> 00:19:47,860 It can send that data to the backend program anywhere on the web, okay? 385 00:19:48,640 --> 00:19:52,840 So it could read the information from the form and then send that data to an arbitrary 386 00:19:52,840 --> 00:19:54,640 server by a GET request. 387 00:19:55,200 --> 00:19:59,840 Or it could change the data in the form so that it's sending bogus data to the backend 388 00:19:59,840 --> 00:20:01,200 program, right? 389 00:20:04,000 --> 00:20:10,000 And also, like I say, it can redirect to any, it can create dynamically any follow-up page 390 00:20:10,000 --> 00:20:13,440 or it can redirect to any existing webpage on the web, okay? 391 00:20:14,020 --> 00:20:16,380 So it's still not clear how this compromises security. 392 00:20:16,380 --> 00:20:18,040 I'm just giving you a taste of the power of JavaScript. 393 00:20:18,840 --> 00:20:23,460 Okay, but what we've learned so far is that, obviously, JavaScript can manipulate an HTML 394 00:20:23,460 --> 00:20:25,380 document in which it is embedded, okay? 395 00:20:25,480 --> 00:20:31,660 So it has almost total control over the HTML document in which it resides, as well as 396 00:20:31,660 --> 00:20:36,860 being able to control follow-up documents or documents in other frames and windows from 397 00:20:36,860 --> 00:20:37,440 the same domain. 398 00:20:38,800 --> 00:20:44,720 So, given that information, would it be wise to allow a user to post their own JavaScript 399 00:20:45,220 --> 00:20:46,360 into a browser? 400 00:20:46,360 --> 00:20:47,580 Would it be a public web application? 401 00:20:48,980 --> 00:20:54,320 If you were a portal, okay, if you were a web service provider, would it be a good idea 402 00:20:54,320 --> 00:20:59,820 to allow users to post JavaScript onto the same page as your own forms, the forms that 403 00:20:59,820 --> 00:21:04,640 thousands of users are going to be using to authenticate themselves and send data back 404 00:21:04,640 --> 00:21:05,680 and forth to your service? 405 00:21:06,360 --> 00:21:07,540 Hmm, let me think about that. 406 00:21:07,800 --> 00:21:08,760 No, it's not. 407 00:21:12,360 --> 00:21:15,620 Okay, but surprisingly, surprisingly... 408 00:21:15,620 --> 00:21:18,560 It happens all the time, okay? 409 00:21:19,820 --> 00:21:21,860 So what are the susceptible online services? 410 00:21:22,220 --> 00:21:26,720 Well, the susceptible online services is any web application that gives the user the ability 411 00:21:26,720 --> 00:21:32,820 to post HTML, okay, including JavaScript, that will be incorporated into the website's 412 00:21:32,820 --> 00:21:36,420 own HTML content and then viewed by other people, right? 413 00:21:36,500 --> 00:21:38,500 So what are some examples of these susceptible services? 414 00:21:38,780 --> 00:21:45,320 Things like webmail, online auctions, web-based chat rooms, basically any service with a 415 00:21:45,320 --> 00:21:47,140 chat area, okay? 416 00:21:48,560 --> 00:21:54,620 So that's just, those are just some general categories, but basically any service, okay, 417 00:21:54,680 --> 00:22:02,500 any service where a user can post their own stuff into the web application is walking 418 00:22:02,500 --> 00:22:03,640 on thin ice. 419 00:22:04,040 --> 00:22:06,080 So let's have a look at webmail services. 420 00:22:09,140 --> 00:22:14,340 Okay, so what we were able to do, we posted online working demos that stole usernames 421 00:22:14,340 --> 00:22:19,940 and passwords from Microsoft's Hotmail using JavaScript, both before and after they released 422 00:22:19,940 --> 00:22:25,540 a patch, Yahoo Mail using Java, and Microsoft's Hotmail, again, using Shockwave. 423 00:22:25,840 --> 00:22:30,780 And we also found vulnerabilities in the webmail services of Yahoo, Lycos, Eudora, 424 00:22:30,800 --> 00:22:34,300 Excite, Eudora, and all the sites powered by iNet Address and Mail Excite. 425 00:22:35,500 --> 00:22:39,880 What was the real-world effect if this had gone unnoticed? 426 00:22:40,080 --> 00:22:44,260 Well, the implications of stealing usernames and passwords from these services is that 427 00:22:44,260 --> 00:22:44,320 it's not a good thing. 428 00:22:44,340 --> 00:22:49,540 It allows the bad guy to, in the case of a webmail service, to delete, send, and read 429 00:22:49,540 --> 00:22:51,000 the victim's email, okay? 430 00:22:51,280 --> 00:22:53,480 To check other mail accounts by mail checking. 431 00:22:53,680 --> 00:22:57,540 For those of you that use Hotmail, you'll know that you can configure it to check email 432 00:22:57,540 --> 00:22:58,880 on your other accounts, okay? 433 00:23:00,100 --> 00:23:05,300 Access the address book, change the password of the webmail account itself, play around 434 00:23:05,300 --> 00:23:05,860 with preferences. 435 00:23:06,000 --> 00:23:11,560 Basically, it's just, you wouldn't want a script kitty getting into your webmail. 436 00:23:12,760 --> 00:23:16,840 And I know I won't help you crack Hotmail to find out if your spouse is cheating on 437 00:23:16,840 --> 00:23:21,080 you, just to answer a lot of the email that I tend to get for some reason. 438 00:23:28,300 --> 00:23:29,780 Okay, so how does it work? 439 00:23:29,860 --> 00:23:37,200 How is it that a large webmail service, how is it that posting JavaScript can affect a 440 00:23:37,200 --> 00:23:38,000 large webmail service? 441 00:23:38,580 --> 00:23:38,980 Okay. 442 00:23:40,340 --> 00:23:40,740 Here's... 443 00:23:40,740 --> 00:23:41,000 Here's... 444 00:23:41,000 --> 00:23:48,140 Here's one example of an algorithm that illustrates the problem. 445 00:23:49,060 --> 00:23:54,120 Okay, so imagine that you've logged into your Hotmail or some other webmail account, right? 446 00:23:54,420 --> 00:23:57,280 And you send someone an email, okay? 447 00:23:57,700 --> 00:24:05,080 And in many of these webmail services, you're allowed to use HTML to, you know, make your 448 00:24:05,080 --> 00:24:06,400 email a little more interesting, right? 449 00:24:06,480 --> 00:24:08,080 Maybe you want to send an image, right? 450 00:24:08,100 --> 00:24:10,260 Maybe you want to include a shockwave or something like that. 451 00:24:10,320 --> 00:24:10,620 So... 452 00:24:10,620 --> 00:24:14,460 So many of these webmail applications allow you to include HTML. 453 00:24:15,180 --> 00:24:21,580 So imagine that your email, your webmail, actually contains some script tags with some 454 00:24:21,580 --> 00:24:22,380 JavaScript in it. 455 00:24:22,640 --> 00:24:24,300 Okay, so you send it off to the other person. 456 00:24:24,340 --> 00:24:31,840 The other person checks their webmail, and what happens when they view the page? 457 00:24:32,000 --> 00:24:36,280 Well, the JavaScript starts running, and the first thing that it does is it sucks the authentication 458 00:24:36,740 --> 00:24:38,080 information from their form. 459 00:24:38,260 --> 00:24:38,780 Okay? 460 00:24:39,420 --> 00:24:46,160 Then it goes and it changes every hyperlink in every frame to point to a different server-side 461 00:24:46,160 --> 00:24:52,300 program, not Hotmail, for example, but instead your own server-side mailing program, okay? 462 00:24:53,500 --> 00:24:58,620 To be more specific, you're pointing to a server-side mailing program, and you're including 463 00:24:58,620 --> 00:25:00,460 your own query string, okay? 464 00:25:00,560 --> 00:25:03,320 Your own information that you're going to send to the server-side program. 465 00:25:03,760 --> 00:25:05,560 And what information might that be? 466 00:25:05,620 --> 00:25:08,600 Well, in a worst-case scenario, it could be that authentication data. 467 00:25:08,600 --> 00:25:08,720 Right? 468 00:25:08,920 --> 00:25:10,260 The username and password, for example. 469 00:25:12,600 --> 00:25:17,340 So the JavaScript redirects to this mailing program. 470 00:25:17,540 --> 00:25:21,140 The mailing program sends the username and password off to who knows who? 471 00:25:21,180 --> 00:25:22,140 Mr. Bad Guy, I guess. 472 00:25:23,360 --> 00:25:29,180 And the mailing program itself then does a redirect and sends the user back to the normal, 473 00:25:29,200 --> 00:25:33,740 legitimate follow-up page of the web application so that, in their eyes, nothing unusual has 474 00:25:33,740 --> 00:25:33,960 occurred. 475 00:25:34,260 --> 00:25:34,480 Right? 476 00:25:34,520 --> 00:25:35,660 It's all transparent to the user. 477 00:25:37,160 --> 00:25:38,580 Now, up at the very top, I think. 478 00:25:38,580 --> 00:25:42,880 Let's say that this is webmail x.1, snagging username and password old. 479 00:25:43,200 --> 00:25:49,980 And the reason that's old is that very few webmail services now will include any really 480 00:25:49,980 --> 00:25:53,900 useful or directly useful authentication information in their forms. 481 00:25:53,960 --> 00:25:55,940 Usually, it's a little bit hard to decipher. 482 00:25:56,260 --> 00:25:58,300 More like a session key or something like that. 483 00:25:58,920 --> 00:25:59,460 Okay. 484 00:25:59,500 --> 00:26:02,440 So this may have worked a little while ago. 485 00:26:03,520 --> 00:26:07,480 It may work in the smaller services still, but generally, 486 00:26:08,580 --> 00:26:10,480 it wouldn't work that well nowadays. 487 00:26:11,480 --> 00:26:11,920 Okay. 488 00:26:12,000 --> 00:26:13,680 Something a little trickier. 489 00:26:14,240 --> 00:26:17,280 Let's have a look at how you could get the same effect using spoofing. 490 00:26:18,620 --> 00:26:19,060 Okay. 491 00:26:19,160 --> 00:26:25,100 So again, you go and you send someone an email that contains JavaScript. 492 00:26:25,920 --> 00:26:30,500 Now, this time, again, the JavaScript alters every hyperlink in every frame of the web 493 00:26:30,500 --> 00:26:30,920 application. 494 00:26:31,300 --> 00:26:31,340 Right? 495 00:26:31,420 --> 00:26:35,960 So guaranteed, at some point, someone is going to click on one of these rigged links. 496 00:26:36,280 --> 00:26:36,720 Right? 497 00:26:37,080 --> 00:26:37,520 Right? 498 00:26:37,660 --> 00:26:37,800 Right? 499 00:26:37,900 --> 00:26:38,340 Right? 500 00:26:38,340 --> 00:26:38,520 Right? 501 00:26:38,580 --> 00:26:39,040 On those links. 502 00:26:39,260 --> 00:26:43,020 The JavaScript dynamically creates a follow-up page. 503 00:26:43,680 --> 00:26:45,700 What does a follow-up page look like? 504 00:26:45,880 --> 00:26:53,020 Well, the follow-up page is an exact duplicate of a legitimate page that says, well, you 505 00:26:53,020 --> 00:26:54,520 have just timed out of this service. 506 00:26:54,700 --> 00:26:55,820 Please re-log in. 507 00:26:55,880 --> 00:26:56,940 Enter your username and password. 508 00:26:57,540 --> 00:26:57,560 Right? 509 00:26:57,780 --> 00:27:03,620 And these web service applications generally really do have a page that says that. 510 00:27:03,680 --> 00:27:03,900 Right? 511 00:27:04,240 --> 00:27:06,380 So in this case, you make it look exactly like that. 512 00:27:06,460 --> 00:27:08,060 You inform the user that they've timed out. 513 00:27:08,640 --> 00:27:10,040 Of course, they really haven't. 514 00:27:10,160 --> 00:27:10,260 Right? 515 00:27:10,400 --> 00:27:14,140 And then they wonder, ah, didn't they experience that moment of frustration? 516 00:27:14,300 --> 00:27:15,460 Like, jeez, I didn't time out. 517 00:27:15,580 --> 00:27:16,040 Oh, fine. 518 00:27:16,480 --> 00:27:16,840 Whatever. 519 00:27:17,180 --> 00:27:21,900 And then they go and they type their username and password back into the form, which you 520 00:27:21,900 --> 00:27:22,840 conveniently provided. 521 00:27:23,280 --> 00:27:25,920 And of course, that form is of your own engineering. 522 00:27:26,140 --> 00:27:27,180 And where does it point to? 523 00:27:27,340 --> 00:27:31,660 Well, again, it points to, let's see, and this is, what does it do? 524 00:27:35,040 --> 00:27:35,400 Yeah. 525 00:27:35,600 --> 00:27:36,620 So in this case, you. 526 00:27:37,540 --> 00:27:39,780 Once you've gone that far, really, it's in your domain. 527 00:27:39,940 --> 00:27:40,140 Right? 528 00:27:40,140 --> 00:27:41,320 So you can do whatever you want with it. 529 00:27:41,400 --> 00:27:45,200 You can redirect to a service side mailing program, mail it back to the bad guy. 530 00:27:47,880 --> 00:27:50,000 This is not so old. 531 00:27:50,160 --> 00:27:55,880 This is, I think this still works, actually. 532 00:27:57,800 --> 00:28:03,620 We pointed this problem out in Microsoft's Hotmail service, and they came up with a couple 533 00:28:03,620 --> 00:28:03,940 patches. 534 00:28:04,200 --> 00:28:06,540 But as far as I know, it still works. 535 00:28:06,540 --> 00:28:13,700 It works for their, you can't actually send data in the message body of an email, but 536 00:28:13,700 --> 00:28:18,140 it still works as an attachment, using, not using JavaScript, but using another client 537 00:28:18,140 --> 00:28:20,720 side technology, which I'll leave you to figure out what it is. 538 00:28:22,300 --> 00:28:22,740 Okay. 539 00:28:23,100 --> 00:28:23,700 Example three. 540 00:28:26,120 --> 00:28:30,140 Here's another twist on the same theme. 541 00:28:30,680 --> 00:28:34,040 So let's say that the web service provider finally catches on, and they say, hey, wait 542 00:28:34,040 --> 00:28:34,180 a minute. 543 00:28:34,940 --> 00:28:36,300 This JavaScript is bad. 544 00:28:36,300 --> 00:28:36,580 Bad news. 545 00:28:36,860 --> 00:28:37,280 That's it. 546 00:28:37,340 --> 00:28:38,800 I am filtering out JavaScript. 547 00:28:39,200 --> 00:28:39,800 So, fine. 548 00:28:40,060 --> 00:28:41,140 They filter out their JavaScript. 549 00:28:41,420 --> 00:28:43,640 Does that mean that the web application is now secure? 550 00:28:43,880 --> 00:28:44,480 Actually, no. 551 00:28:46,040 --> 00:28:50,920 What happens is, it turns out that you can do the exact same thing using slight twist. 552 00:28:50,980 --> 00:28:54,400 You can do the exact same thing with many client side technologies. 553 00:28:54,720 --> 00:28:54,860 Okay. 554 00:28:54,940 --> 00:28:56,640 So let's have a look at how you can do it with applets. 555 00:28:57,520 --> 00:29:01,020 In this case, you send someone an email containing a Java applet. 556 00:29:01,220 --> 00:29:02,500 What does the applet look like? 557 00:29:02,660 --> 00:29:03,800 Well, it doesn't have to look like anything. 558 00:29:04,020 --> 00:29:06,240 It can just be a one pixel by one pixel app. 559 00:29:06,240 --> 00:29:10,340 Applet that is white on the white background so the person can't even see it. 560 00:29:10,480 --> 00:29:12,240 It doesn't have to be a visible applet. 561 00:29:13,140 --> 00:29:13,620 Okay. 562 00:29:14,460 --> 00:29:18,840 So the, obviously, the user receives your email. 563 00:29:18,940 --> 00:29:19,960 They receive the applet. 564 00:29:20,560 --> 00:29:22,440 And the applet starts running. 565 00:29:22,600 --> 00:29:23,600 And what does the applet do? 566 00:29:23,820 --> 00:29:30,480 Well, it turns out that applets have a method available to them that can actually load our 567 00:29:30,480 --> 00:29:33,760 HTML documents into a specific frame of the frame set. 568 00:29:34,340 --> 00:29:36,220 I think it's called set applet.com. 569 00:29:36,220 --> 00:29:37,280 Text or something like that. 570 00:29:38,120 --> 00:29:45,540 So the applet itself has the ability to load an arbitrary HTML document into a different frame. 571 00:29:46,300 --> 00:29:46,740 Okay. 572 00:29:48,400 --> 00:29:49,740 So what does the applet do? 573 00:29:49,840 --> 00:29:55,100 Well, it loads a, now, for those of you that are familiar with web mail service, 574 00:29:55,260 --> 00:29:57,220 you'll know that it's a framed environment, right? 575 00:29:59,060 --> 00:30:02,640 On the left-hand frame, you have your control panel, right? 576 00:30:02,720 --> 00:30:05,440 It's like, you know, compose new mail, check mail. 577 00:30:06,220 --> 00:30:07,440 You can do whatever, all these options. 578 00:30:07,860 --> 00:30:14,420 And the right-hand frame, you actually have email messages themselves, right? 579 00:30:14,980 --> 00:30:16,020 So what does the applet do? 580 00:30:16,140 --> 00:30:21,100 Well, the applet goes into the left-hand frame, the frame that contains all the, basically, 581 00:30:21,340 --> 00:30:23,360 the control pad for the mail service. 582 00:30:23,540 --> 00:30:29,140 And it replaces it with the bad guy's own HTML document, which, lo and behold, is an 583 00:30:29,140 --> 00:30:31,840 exact duplicate of the control panel, okay? 584 00:30:32,120 --> 00:30:34,700 But, of course, it's been engineered to do something slightly different. 585 00:30:35,100 --> 00:30:35,540 Okay. 586 00:30:35,540 --> 00:30:41,940 This new control panel is engineered so that every single link on the control panel basically 587 00:30:42,480 --> 00:30:48,660 is a link to load, guess what, a timeout message into the right-hand frame, again, from the 588 00:30:48,660 --> 00:30:49,900 bad guy's own UI server. 589 00:30:51,080 --> 00:30:55,100 Obviously, that page is totally under the control of the bad guy, and whenever the user 590 00:30:55,100 --> 00:30:58,780 enters their own re-login information, it's sent right back to the bad guy. 591 00:30:59,700 --> 00:31:02,800 Now, it turns out you can also do the exact same thing with Shockwave. 592 00:31:06,520 --> 00:31:12,980 Now, the interesting thing here is that in the eyes of the browser itself, no security 593 00:31:12,980 --> 00:31:14,980 violation is going on with JavaScript, right? 594 00:31:15,380 --> 00:31:16,940 Because where is the JavaScript? 595 00:31:17,200 --> 00:31:22,100 The JavaScript is in an HTML document that's actually being served out from the web service 596 00:31:22,100 --> 00:31:22,440 itself. 597 00:31:22,820 --> 00:31:26,460 As far as the browser is concerned, that JavaScript is Hotmail's JavaScript. 598 00:31:27,200 --> 00:31:32,980 It has free reign to go into any frame, change whatever it likes, alter the forms, right? 599 00:31:33,260 --> 00:31:34,060 And why? 600 00:31:34,180 --> 00:31:34,960 All because... 601 00:31:35,540 --> 00:31:40,020 The web mail services allow people to post up their own JavaScript, which then gets incorporated 602 00:31:40,020 --> 00:31:41,400 into their own page. 603 00:31:41,880 --> 00:31:43,180 See, that's the problem. 604 00:31:44,380 --> 00:31:48,980 Once that JavaScript is incorporated into their page, it has free reign. 605 00:31:50,660 --> 00:31:51,260 Okay. 606 00:31:57,820 --> 00:32:01,060 Web-based auctions, same general idea. 607 00:32:01,360 --> 00:32:05,400 We posted an online working demo of JavaScript exploit that stole usernames and passwords, 608 00:32:05,540 --> 00:32:10,120 using keywords of eBay users, and also, interestingly, it can be extended to replicate itself 609 00:32:10,120 --> 00:32:15,540 by inserting itself into people's own auctions, and this was coined the eBay-la virus, and 610 00:32:15,540 --> 00:32:17,240 it caught a little bit of media attention. 611 00:32:17,380 --> 00:32:18,640 That was a pretty funny name, I thought. 612 00:32:19,400 --> 00:32:20,860 eBay-la, Ebola, get it? 613 00:32:23,680 --> 00:32:25,040 Okay, so what is the exploit? 614 00:32:25,680 --> 00:32:32,620 In this twist, you post an item up for auction at eBay, and I don't know how many people 615 00:32:32,620 --> 00:32:33,540 here have actually been to eBay. 616 00:32:34,280 --> 00:32:34,720 Right. 617 00:32:34,780 --> 00:32:35,080 Okay. 618 00:32:35,540 --> 00:32:39,520 So you know that when you post an item at eBay, right, all the items have associated 619 00:32:39,520 --> 00:32:40,180 descriptions. 620 00:32:40,700 --> 00:32:44,600 And when you go to post your own item up, there's a place where you can type in your 621 00:32:44,600 --> 00:32:46,500 own description of what the item is going to be, right? 622 00:32:46,640 --> 00:32:53,660 And eBay has decided to let you use any sort of HTML tags you want in your description 623 00:32:53,660 --> 00:32:55,160 of the item that you want to sell. 624 00:32:55,940 --> 00:32:56,460 Uh-oh. 625 00:32:57,760 --> 00:33:02,640 So, in your description, you type out your script tags, insert some JavaScript, and what 626 00:33:02,640 --> 00:33:03,660 does this JavaScript do? 627 00:33:03,660 --> 00:33:05,900 Well, let's talk a little bit about eBay. 628 00:33:06,840 --> 00:33:13,520 It turns out that when another person comes, right, to view your item that's up for auction, 629 00:33:14,280 --> 00:33:15,720 what does that look like on the screen? 630 00:33:15,960 --> 00:33:21,680 Well, there's a description of the item, right, and right underneath the description 631 00:33:21,680 --> 00:33:29,360 of the item is, oh, a form, so that if you want to bid on the item, you can enter your 632 00:33:30,720 --> 00:33:33,380 username, password to make your bid, right? 633 00:33:34,040 --> 00:33:38,180 So, basically, the description of the item is on the exact same page as the form where 634 00:33:38,180 --> 00:33:39,780 you enter your username and password. 635 00:33:41,600 --> 00:33:42,100 Uh-oh. 636 00:33:42,200 --> 00:33:42,720 All right. 637 00:33:42,740 --> 00:33:43,120 That's bad. 638 00:33:44,300 --> 00:33:46,760 Because, as we all know, the item description contains JavaScript. 639 00:33:47,060 --> 00:33:48,000 What does the JavaScript do? 640 00:33:48,300 --> 00:33:52,460 Well, the JavaScript will immediately start playing around with the form, okay? 641 00:33:52,800 --> 00:33:54,420 And there's a whole bunch of things that it can do. 642 00:33:54,500 --> 00:33:58,260 It can suddenly say, well, yes, thank you for typing in your username and password, 643 00:33:58,440 --> 00:34:00,680 but I don't think we'll be sending that to eBay right away. 644 00:34:00,960 --> 00:34:03,360 First, let's send that off to Mr. Badger. 645 00:34:03,380 --> 00:34:09,940 And, uh, on a server side mailing program, that does a redirect to a normal, back to 646 00:34:09,940 --> 00:34:12,580 the normal eBay follow-up page, right? 647 00:34:13,200 --> 00:34:15,120 So, from the point of view of the user, what's happened? 648 00:34:15,560 --> 00:34:17,040 They've seen an item description. 649 00:34:17,460 --> 00:34:18,760 They placed a bid on it. 650 00:34:19,760 --> 00:34:20,520 Next page. 651 00:34:21,100 --> 00:34:23,120 They're told that their bidder was registered. 652 00:34:25,020 --> 00:34:25,820 Great, right? 653 00:34:25,960 --> 00:34:27,700 From their point of view, nothing unusual has happened. 654 00:34:29,280 --> 00:34:29,680 Okay. 655 00:34:29,820 --> 00:34:33,220 So, what are the implications of, in this case, with this web application, what are 656 00:34:33,220 --> 00:34:33,360 the implications? 657 00:34:33,380 --> 00:34:35,620 What are the implications of stealing the usernames and passwords? 658 00:34:36,000 --> 00:34:39,260 Well, in this case, you can use them to, uh, create new options. 659 00:34:39,960 --> 00:34:41,400 And, uh, what does that do? 660 00:34:41,480 --> 00:34:43,540 That actually automatically charges the victim's account. 661 00:34:43,980 --> 00:34:44,420 Right? 662 00:34:44,480 --> 00:34:48,540 So, suddenly, we're not just dealing with, with, uh, email. 663 00:34:48,680 --> 00:34:50,260 We're dealing with real money. 664 00:34:51,780 --> 00:34:54,000 You can place the bids in the victim's name. 665 00:34:54,100 --> 00:34:56,100 You can retract legitimate bids in the victim's name. 666 00:34:56,200 --> 00:34:57,800 You can change the victim's username and password. 667 00:34:58,100 --> 00:34:59,820 You can prematurely close an auction. 668 00:35:00,460 --> 00:35:03,360 And, uh, also, eBay is, uh, has, uh, you know, it's, it's a, it's a, it's a, it's 669 00:35:03,380 --> 00:35:07,720 a really big, really, really, really powerful, server-side programs that allow you to change 670 00:35:07,720 --> 00:35:11,900 the description of your own item even after it's gone up for bid. 671 00:35:13,420 --> 00:35:14,180 How do you do that? 672 00:35:14,220 --> 00:35:15,660 You enter your username and password. 673 00:35:15,900 --> 00:35:20,300 So, if I know your username and password, if I've stolen your username and password, 674 00:35:20,460 --> 00:35:25,960 and it turns out that you, yourself, are an eBay user that is running an auction, well, 675 00:35:25,980 --> 00:35:31,260 now I can go into your auction, post my eBay code into your auction. 676 00:35:31,640 --> 00:35:32,040 Right? 677 00:35:32,260 --> 00:35:32,400 Right? 678 00:35:32,400 --> 00:35:40,660 That can actually be done automatically, so that in effect what you have is a virus that is spreading from auction item to auction item. 679 00:35:42,680 --> 00:35:50,020 Somebody goes to the auction, they place a bid, if they themselves are running an auction, bang, suddenly the code is in there, auction item description. 680 00:35:50,640 --> 00:35:59,220 Now that was never actually, I never actually wrote that, I just wrote, I never wrote the self-replicating kind, although it would have been trivial to extend it. 681 00:35:59,220 --> 00:36:09,880 And eBay eventually patched the problem after two and a half months. 682 00:36:14,900 --> 00:36:16,800 Okay, so that's the bad news. 683 00:36:22,160 --> 00:36:28,520 What's the good news? Is there a way that designers can take advantage of this information to improve their site? Yes there is. 684 00:36:29,320 --> 00:36:43,880 Okay, if you're running a kind of a web service where users must be allowed to post their own HTML content to public areas, okay, especially to public areas that contain forms, right, then you should take the following steps. 685 00:36:45,660 --> 00:36:51,820 One, filter the content for client-side processes slash tags, right? 686 00:36:52,300 --> 00:36:58,900 So try, you know, it's hard, but at least make the attempt to filter out script tags, applet tags, shockwave, flash. 687 00:36:59,360 --> 00:37:00,860 Things like that, okay? 688 00:37:01,880 --> 00:37:16,020 And when the time does come for you to write your filtering software, a common mistake that I see is that the programs are written from the perspective of filtering in, from filtering out instead of filtering in. 689 00:37:16,300 --> 00:37:18,200 What's the difference between filtering out and filtering in? 690 00:37:18,480 --> 00:37:28,600 Well, it's the difference between starting from the premise that you're going to let everything in, except for that, that, that, and that, as opposed to saying, I'm not letting anything in. 691 00:37:29,540 --> 00:37:31,100 Except that, that, that, that, that. 692 00:37:32,420 --> 00:37:33,680 The latter is what you want. 693 00:37:33,880 --> 00:37:36,420 You want to start with the premise, I'm not letting anything in. 694 00:37:37,020 --> 00:37:38,860 Well, okay, maybe some plain text. 695 00:37:39,140 --> 00:37:40,420 Well, okay, maybe hyperlinks. 696 00:37:40,740 --> 00:37:42,380 Maybe this, maybe that, right? 697 00:37:42,480 --> 00:37:43,880 So be choosy about what you let in. 698 00:37:44,240 --> 00:37:55,760 Don't try and figure out everything that you want to filter out because, you know, there are a lot of sneaky ways to embed JavaScript and client-side processes into a web page. 699 00:37:55,920 --> 00:37:58,860 And there's no way you're going to be able to keep up with the technology. 700 00:38:00,060 --> 00:38:01,460 The evolution of the technology. 701 00:38:01,760 --> 00:38:10,940 It's much harder to try and keep up with all the latest tags and all the different ways to embed it in the HTML than it is to just say, I'm not letting anything in, except you, you, and you. 702 00:38:12,180 --> 00:38:19,240 And one of the reasons that it's really hard to filter out this client-side technology is because you can write a filter. 703 00:38:19,320 --> 00:38:23,980 Sure, it's easy to write a filter that will go in and, you know, filter out all the script tags and stuff. 704 00:38:24,600 --> 00:38:28,780 But, you know, to do that, your program is going to have to be looking for certain tokens. 705 00:38:28,780 --> 00:38:29,040 Right? 706 00:38:29,180 --> 00:38:34,060 It's going to have to be looking for HTML tags that have a certain structure. 707 00:38:35,540 --> 00:38:37,300 But browsers are so flexible. 708 00:38:38,100 --> 00:38:47,000 It turns out that even if you do type in a tag, and let's say you leave out the closing bracket, well, the filter won't pick it up because it's not a well-formed HTML tag. 709 00:38:47,180 --> 00:38:47,320 Right? 710 00:38:47,680 --> 00:38:50,340 But the browser will figure out what the person is trying to do. 711 00:38:50,940 --> 00:38:51,320 Okay. 712 00:38:51,400 --> 00:38:52,840 So it's just really hard. 713 00:38:53,060 --> 00:38:53,820 Don't even try. 714 00:38:53,860 --> 00:38:57,180 Don't even try to pick out what you want to, you know, filter out. 715 00:38:57,280 --> 00:38:58,760 I strongly recommend filtering out. 716 00:38:58,760 --> 00:38:59,160 Just bring it in instead. 717 00:39:01,440 --> 00:39:01,920 Okay. 718 00:39:02,000 --> 00:39:11,780 Also, if you really must allow your users to post JavaScript information, to post their own JavaScript content, display it in its own browser window. 719 00:39:12,160 --> 00:39:17,700 And you can use your own JavaScript to make sure that that new window does not contain a reference to its parent window. 720 00:39:18,120 --> 00:39:18,600 Okay. 721 00:39:18,620 --> 00:39:27,940 That way, any JavaScript that's posted by a user will not be able to make a reference to the parent and will not be able to go and start playing around with anything other than the window in which it is displayed. 722 00:39:28,840 --> 00:39:37,320 And obviously, you should never place a form on the same page or a follow-up page from all unfiltered content. 723 00:39:39,280 --> 00:39:41,220 So those are just some tips. 724 00:39:41,400 --> 00:39:46,420 Hopefully, it will propagate its way back to the designers of web applications. 725 00:39:49,960 --> 00:39:56,940 It's, like I say, it would be great if this information was used to maybe shift, at least in some cases, you know. 726 00:39:56,940 --> 00:39:58,740 It's great to have excellent network security. 727 00:39:58,740 --> 00:40:02,620 It's really great to have great network administrators and have a totally secure network environment. 728 00:40:02,940 --> 00:40:12,660 But, hey, if your web application itself is insecure, you're spending a lot of money to protect stuff behind a firewall that can be accessed, you know, in a few lines of JavaScript, right? 729 00:40:12,700 --> 00:40:13,500 So what are the priorities? 730 00:40:13,880 --> 00:40:14,280 Okay. 731 00:40:14,640 --> 00:40:15,880 I'll take some questions now. 732 00:40:15,960 --> 00:40:19,260 And, unfortunately, I have to leave in half an hour and go back to Canada. 733 00:40:19,600 --> 00:40:23,540 But I'll be out by the pool for about half an hour if anybody wants to talk to me before I leave. 734 00:40:23,600 --> 00:40:24,440 And I'll take some questions now. 735 00:40:24,660 --> 00:40:25,700 Thank you. 736 00:40:30,480 --> 00:40:30,880 . 737 00:40:38,480 --> 00:40:42,680 Well, when I say the web, I'm talking about webmail applications, right? 738 00:40:42,740 --> 00:40:45,740 So I'm talking about things like Hotmail and stuff like that. 739 00:40:45,980 --> 00:40:49,900 Now, there is also some ability to tinker around with things like Outlook and stuff. 740 00:40:50,380 --> 00:40:55,220 If you can shut off JavaScript, I mean, if you're paranoid, yeah, turn off JavaScript. 741 00:40:55,320 --> 00:40:56,840 But JavaScript isn't the only problem, right? 742 00:40:57,040 --> 00:40:57,440 Yeah. 743 00:40:58,740 --> 00:40:59,320 . 744 00:41:09,280 --> 00:41:09,960 . 745 00:41:09,960 --> 00:41:10,300 . 746 00:41:10,300 --> 00:41:10,640 . 747 00:41:10,640 --> 00:41:11,200 . 748 00:41:11,200 --> 00:41:11,320 . 749 00:41:11,320 --> 00:41:11,580 . 750 00:41:11,580 --> 00:41:11,600 . 751 00:41:11,600 --> 00:41:11,620 . 752 00:41:11,620 --> 00:41:12,240 . 753 00:41:35,560 --> 00:41:36,880 Could you either say that louder 754 00:41:36,880 --> 00:41:38,060 or can someone in the front repeat that 755 00:41:38,060 --> 00:41:39,080 so I can hear the question? 756 00:41:54,220 --> 00:41:55,720 Yeah, there have been a lot of, 757 00:41:56,240 --> 00:41:57,560 there's sort of been a stream of holes 758 00:41:57,560 --> 00:41:59,540 that have allowed you to do things like that. 759 00:41:59,720 --> 00:42:02,780 And yeah, sure, another approach is to look into your cache 760 00:42:02,780 --> 00:42:05,360 and stuff like that and mail that back. 761 00:42:05,680 --> 00:42:09,360 Usually the most, for the purpose of our demonstrations, 762 00:42:10,040 --> 00:42:12,080 you know, it seemed that the most, 763 00:42:12,200 --> 00:42:14,180 the way to catch people's attention 764 00:42:14,180 --> 00:42:15,300 that there's a security problem 765 00:42:15,300 --> 00:42:17,880 is to just steal the usernames and passwords 766 00:42:17,880 --> 00:42:21,500 because that, you know, 767 00:42:21,500 --> 00:42:22,980 the goal is to get the media's attention 768 00:42:22,980 --> 00:42:25,700 and to create a solution to the problem. 769 00:42:25,860 --> 00:42:27,280 So you have to do something that people can identify 770 00:42:27,280 --> 00:42:27,540 with. 771 00:42:27,560 --> 00:42:27,860 That's right. 772 00:42:27,980 --> 00:42:28,840 Everybody knows what it means 773 00:42:28,840 --> 00:42:30,000 to steal a username and password. 774 00:42:30,460 --> 00:42:31,920 But yeah, obviously, you know, 775 00:42:31,960 --> 00:42:33,960 this isn't the only thing you can do. 776 00:42:34,000 --> 00:42:34,620 You can use this. 777 00:42:35,660 --> 00:42:38,480 If you're a designer of a web application, 778 00:42:38,740 --> 00:42:39,540 you want to patch this 779 00:42:39,540 --> 00:42:40,620 because, you know, 780 00:42:40,620 --> 00:42:42,240 I'm sure there are much more creative ways 781 00:42:42,240 --> 00:42:44,220 to do bad stuff 782 00:42:44,220 --> 00:42:46,160 than I've been able to show up on with my overhead. 783 00:42:46,640 --> 00:42:47,040 Yeah. 784 00:42:47,380 --> 00:42:48,800 Can you bring up the concept 785 00:42:48,800 --> 00:42:49,940 of using all of those 786 00:42:49,940 --> 00:42:52,580 for using the edge of the application 787 00:42:53,060 --> 00:42:53,940 that you're using? 788 00:42:55,620 --> 00:42:56,780 Yeah, well, cookies are just, 789 00:42:56,880 --> 00:42:57,540 I think it's a good question. 790 00:42:57,560 --> 00:42:58,800 Cookies are just another technology 791 00:42:58,800 --> 00:43:01,640 at the disposal of someone 792 00:43:01,640 --> 00:43:03,540 that's doing client-side scripting. 793 00:43:03,680 --> 00:43:05,400 So it's just a facet, 794 00:43:05,400 --> 00:43:06,680 something that you can take advantage of 795 00:43:06,680 --> 00:43:08,800 if you want to, you know, 796 00:43:08,800 --> 00:43:11,300 if you do suck some information out of somewhere, 797 00:43:11,420 --> 00:43:13,540 you may want to store it in a cookie 798 00:43:13,540 --> 00:43:14,320 for whatever reason. 799 00:43:20,640 --> 00:43:22,600 Cookies in and of themselves 800 00:43:22,600 --> 00:43:24,360 are not inherently dangerous. 801 00:43:27,560 --> 00:43:28,340 They're just a tool. 802 00:43:28,400 --> 00:43:29,140 There's nothing particularly 803 00:43:29,140 --> 00:43:30,520 inherently dangerous about a cookie. 804 00:43:32,500 --> 00:43:33,660 Okay, I guess I'm running out of time. 805 00:43:33,760 --> 00:43:35,120 So thanks a lot. 806 00:43:35,880 --> 00:43:36,480 Thank you.