1 00:00:00,000 --> 00:00:05,780 Thank you very much everyone. It's nice to see everyone so excited straight away before I even said a word. 2 00:00:06,960 --> 00:00:10,700 But yeah, today I'm going to be talking about the security risks of Web 2.0. 3 00:00:11,120 --> 00:00:25,160 I'm not going to be deep diving into anything in particular, but what I'm trying to do today is give a wider coverage than maybe some other presentations on this topic. 4 00:00:25,160 --> 00:00:30,440 So I'm not going to talk about just one or two different vulnerabilities. I'm actually going to try and squeeze ten of them in. 5 00:00:30,500 --> 00:00:34,980 So I don't know if that makes me mad or not for trying to do that, but that's what we're going to cover today. 6 00:00:35,900 --> 00:00:46,700 So firstly, there'll be a very quick Web 2.0 definition, looking then at common vulnerabilities, some of the differences between Web 1.0 and Web 2.0 for those vulnerabilities. 7 00:00:47,940 --> 00:00:53,400 Why a security analyst's job, i.e. my job, is more difficult when it comes to Web 2.0 applications, 8 00:00:53,900 --> 00:00:55,140 and how to prevent these vulnerabilities. 9 00:00:55,160 --> 00:00:56,760 Why a security analyst's job, i.e. my job, is more difficult when it comes to Web 2.0 applications, and how to prevent these vulnerabilities in your own code. 10 00:00:57,840 --> 00:01:03,480 So my name is David Rook. I'm a security analyst for a company called Realex Payments in Ireland. 11 00:01:04,040 --> 00:01:12,440 We're a payments processing company. We do kind of in excess of, I think it's 6 billion euros worth of credit card transactions each year. 12 00:01:12,860 --> 00:01:17,000 I have a couple of different websites. Security Ninja is my blog. 13 00:01:17,660 --> 00:01:24,840 I do a lot of work with OS, contributing, helping setting up conferences, speaking at conferences and so on for them. 14 00:01:25,160 --> 00:01:29,260 I'm the security advisor for the Irish Internet Association. 15 00:01:30,320 --> 00:01:40,220 We have a web development working group where we try and help small development companies in Ireland understand how to deliver development projects, 16 00:01:40,280 --> 00:01:42,040 and I help them understand security issues. 17 00:01:42,940 --> 00:01:49,000 I've also found a few security issues in Facebook, and we'll look at one of those later on as well. 18 00:01:50,160 --> 00:01:53,960 So kind of, like I said, I just wanted to say up front what this presentation is, 19 00:01:54,080 --> 00:01:55,080 and what it is. 20 00:01:55,160 --> 00:02:00,380 So it's not going to be a technical discussion about Web 2.0 technologies and architectures. 21 00:02:00,480 --> 00:02:03,640 It will be a discussion about vulnerabilities in Web 2.0 applications. 22 00:02:04,300 --> 00:02:07,240 There's no zero days, no new attacks, or so on here. 23 00:02:07,460 --> 00:02:11,180 But it's also not just a discussion about cross-site scripting and SQL injection. 24 00:02:11,800 --> 00:02:15,660 We're going to look at, like I said before, 10 different vulnerabilities today, 25 00:02:16,280 --> 00:02:18,460 and how you can prevent them in your own code. 26 00:02:19,880 --> 00:02:24,440 So kind of on the screen there is Tim O'Reilly's quite famous quote, I think, by now. 27 00:02:24,440 --> 00:02:26,140 But what Web 2.0 is. 28 00:02:26,300 --> 00:02:29,580 But instead of trying to run through that, I've just got this image here, 29 00:02:29,700 --> 00:02:34,280 which probably allows you to understand the types of websites we're talking about. 30 00:02:34,400 --> 00:02:41,420 So Facebook, Wikipedia, YouTube, those types of websites are the kind of sites we're talking about today. 31 00:02:42,180 --> 00:02:50,900 So some of the key points about Web 2.0 is that we've kind of switched away from people visiting websites to read site-provided content 32 00:02:50,900 --> 00:02:53,700 to the sites essentially just becoming a framework. 33 00:02:53,700 --> 00:02:55,740 A framework that users come along and fill in. 34 00:02:55,940 --> 00:02:58,340 So things like social networking sites and YouTube. 35 00:03:00,140 --> 00:03:03,680 There's a desire to have a desktop look and feel to those web applications. 36 00:03:04,120 --> 00:03:06,860 There's also a feeling that kind of everything can go online now. 37 00:03:06,980 --> 00:03:11,460 So with things like Google Documents, you can do all your word processing, spreadsheets, et cetera, online. 38 00:03:11,780 --> 00:03:17,500 There's also things like iOS, which is a full operating system that you can use within your browser. 39 00:03:19,080 --> 00:03:22,880 There's the feeling to have kind of a syndication of content as well. 40 00:03:22,960 --> 00:03:23,140 So. 41 00:03:23,140 --> 00:03:27,880 So a user doesn't want to come back to your page ten times a day to see if you've made any updates. 42 00:03:28,060 --> 00:03:35,300 We use things like RSS and Atom and I guess even websites like Twitter nowadays to allow people to see updates to your site quickly. 43 00:03:36,460 --> 00:03:42,120 And another key point, which I think will become a bigger problem in the next probably year or so, 44 00:03:42,540 --> 00:03:44,720 is the offline storage of data and state. 45 00:03:45,020 --> 00:03:48,280 So probably Google Gears would be the leader in this at the moment, 46 00:03:48,320 --> 00:03:52,980 where it will essentially create, update, and delete databases on your local. 47 00:03:53,140 --> 00:03:53,580 File system. 48 00:03:53,900 --> 00:03:58,280 So there's kind of no concept of on or offline working with that. 49 00:03:58,460 --> 00:04:04,760 And if HTML5 ever gets approved, then that will also be bringing that kind of functionality along as well, 50 00:04:04,800 --> 00:04:10,320 creating these databases, allowing the sites to create databases on your file system. 51 00:04:10,420 --> 00:04:16,900 It's not particularly something I feel comfortable with, but if you want to know more about the issues around that, 52 00:04:17,080 --> 00:04:18,360 come and grab me afterwards. 53 00:04:18,500 --> 00:04:22,220 I've got a presentation I did last year that I can show you on that. 54 00:04:23,380 --> 00:04:26,780 Kind of for time reasons, I'm not going to step through everything on here, 55 00:04:26,820 --> 00:04:29,920 apart from kind of just to point out the last two points at the bottom. 56 00:04:31,000 --> 00:04:35,780 Web 1.0 we had poor security, and in Web 2.0 we're kind of repeating the same issues. 57 00:04:36,800 --> 00:04:41,040 Really, you know, some of the key points off that, you know, from a user point of view, 58 00:04:41,500 --> 00:04:46,160 their web experience has changed from coming along and reading content to coming along and providing content. 59 00:04:46,640 --> 00:04:49,820 There are different technologies there, different security issues. 60 00:04:51,200 --> 00:04:53,120 So the vulnerabilities we're going to look at... 61 00:04:53,140 --> 00:04:54,740 at today, probably by name 62 00:04:54,740 --> 00:04:56,700 a lot of these will be familiar to people. 63 00:04:56,920 --> 00:04:58,740 The cross-site scripting, cross-site request 64 00:04:58,740 --> 00:05:00,800 forgery, SQL injection, 65 00:05:01,180 --> 00:05:02,320 authentication and authorization 66 00:05:02,320 --> 00:05:04,980 flaws. And I guess if I was sitting 67 00:05:04,980 --> 00:05:06,700 in the crowd now, I'd probably be thinking that 68 00:05:06,700 --> 00:05:08,240 they are the same 69 00:05:08,240 --> 00:05:10,700 as Web 1.0. Well, 70 00:05:10,800 --> 00:05:12,720 in name at least they're the same. 71 00:05:13,140 --> 00:05:14,800 But we're going to look at how 72 00:05:15,420 --> 00:05:16,720 they're exploited differently 73 00:05:16,720 --> 00:05:17,700 in Web 2.0 today. 74 00:05:18,680 --> 00:05:20,140 And we're going to look at three 75 00:05:20,140 --> 00:05:22,600 vulnerabilities which I think are kind of 76 00:05:22,600 --> 00:05:24,580 Web 2.0 specific. So cross-site scripting 77 00:05:24,580 --> 00:05:26,340 worms, feed injections, 78 00:05:26,680 --> 00:05:28,540 sorry, just on the cross-site scripting 79 00:05:28,540 --> 00:05:30,120 worms, I'm not going to step through Sammy 80 00:05:30,120 --> 00:05:32,620 like probably everyone else has the last four years. 81 00:05:32,680 --> 00:05:34,440 I've got a different cross-site scripting 82 00:05:34,440 --> 00:05:36,480 worm for us to look at today. And then 83 00:05:36,480 --> 00:05:38,400 some of the problems that can occur with mashup 84 00:05:38,400 --> 00:05:39,880 and widgets websites. 85 00:05:41,540 --> 00:05:42,380 So first up 86 00:05:42,380 --> 00:05:44,480 is cross-site scripting. I think 87 00:05:44,480 --> 00:05:46,540 by now everyone knows that it's not a new 88 00:05:46,540 --> 00:05:48,540 vulnerability, but it certainly has the potential 89 00:05:48,540 --> 00:05:50,720 to be worse in Web 2.0. 90 00:05:50,820 --> 00:05:52,360 And these flaws occur whenever an 91 00:05:52,360 --> 00:05:53,260 application takes 92 00:05:54,180 --> 00:05:56,220 externally supplied input and uses 93 00:05:56,220 --> 00:05:58,300 that as an output into the browser. 94 00:05:58,640 --> 00:06:00,360 And there are kind of three main 95 00:06:00,360 --> 00:06:01,980 types of cross-site scripting. 96 00:06:02,020 --> 00:06:04,080 So I've reflected cross-site scripting attack 97 00:06:04,080 --> 00:06:06,320 and what I've done on these three 98 00:06:06,320 --> 00:06:08,000 points is I've got just a line about 99 00:06:08,000 --> 00:06:10,240 the vulnerability and an 100 00:06:10,240 --> 00:06:11,900 example of a bit of attack code there. 101 00:06:12,040 --> 00:06:14,240 So reflected cross-site 102 00:06:14,240 --> 00:06:16,060 scripting attack occurs whenever 103 00:06:16,060 --> 00:06:18,020 the user supplied data 104 00:06:18,020 --> 00:06:20,100 is reflected back to 105 00:06:20,100 --> 00:06:21,820 the user in the browser immediately. So 106 00:06:21,820 --> 00:06:23,880 it's all on the client side. It's dynamically 107 00:06:23,880 --> 00:06:26,120 created on the client side. So if you're 108 00:06:26,120 --> 00:06:28,100 only relying on server-side protections, then it 109 00:06:28,100 --> 00:06:28,780 won't help you here. 110 00:06:29,640 --> 00:06:32,420 The second type is, is a stored cross-site 111 00:06:32,420 --> 00:06:33,900 scripting attack, which I guess kind of by 112 00:06:33,900 --> 00:06:37,720 name it implies what it is. So you store 113 00:06:37,720 --> 00:06:39,960 your malicious code on the server-side, so in 114 00:06:39,960 --> 00:06:42,200 a database. And then when someone comes and 115 00:06:42,200 --> 00:06:44,340 views maybe your blog, every time someone 116 00:06:44,340 --> 00:06:46,640 comes and views that, it'll execute the code. 117 00:06:46,800 --> 00:06:49,820 And we'll look at the cross-site scripting 118 00:06:49,820 --> 00:06:51,640 worms later, which are essentially stored 119 00:06:51,640 --> 00:06:52,720 cross-site scripting attacks. 120 00:06:54,080 --> 00:06:56,700 And then finally we have DOM-based cross-site 121 00:06:56,700 --> 00:06:59,640 scripting attack. And again, this is occurring 122 00:06:59,640 --> 00:07:02,220 on the client side. And the example we've 123 00:07:02,220 --> 00:07:04,300 got there is if we've got a URL for 124 00:07:04,300 --> 00:07:06,520 example site dot com, and we've got a name 125 00:07:06,520 --> 00:07:09,260 equals value. Now, if, if, if the name 126 00:07:09,260 --> 00:07:11,560 has, I know, David in there, then the bit 127 00:07:11,560 --> 00:07:14,300 of code underneath that URL there is gonna 128 00:07:14,300 --> 00:07:15,940 pull that out and write it into the page. 129 00:07:16,080 --> 00:07:18,040 So the website might say, hello, David. 130 00:07:18,640 --> 00:07:21,620 But if we don't validate that name, value, then 131 00:07:21,620 --> 00:07:22,340 if we don't validate that value before we pull 132 00:07:22,340 --> 00:07:24,360 it into the page and inject it into the 133 00:07:24,360 --> 00:07:27,080 page's DOM, then we can open up to DOM-based 134 00:07:27,080 --> 00:07:28,080 cross-site scripting attacks. 135 00:07:30,060 --> 00:07:32,220 So how can this get worse in Web 2.0? Well, 136 00:07:32,780 --> 00:07:35,340 we just mentioned DOM-based cross-site scripting attacks. 137 00:07:35,600 --> 00:07:39,260 And the DOM manipulation to give kind of a 138 00:07:39,260 --> 00:07:43,240 dynamic interactive feel to Web 2.0 applications is 139 00:07:43,240 --> 00:07:45,920 kind of becoming more and more vital all the 140 00:07:45,920 --> 00:07:48,900 time. So if we think, when we make these 141 00:07:48,900 --> 00:07:51,120 updates to the DOM, if we're pulling in data, 142 00:07:51,620 --> 00:07:53,980 from external sources and injecting it straight 143 00:07:53,980 --> 00:07:56,240 into the DOM, then we could be opening ourselves 144 00:07:56,240 --> 00:07:58,600 up to, to security issues there. And we're gonna 145 00:07:58,600 --> 00:08:00,580 look at an example in a second of that. 146 00:08:01,060 --> 00:08:04,820 We have user-controlled data in more places. You 147 00:08:04,820 --> 00:08:07,480 know, the, the Web experience for a user anymore 148 00:08:07,480 --> 00:08:10,260 isn't just coming along and putting data into a 149 00:08:10,260 --> 00:08:13,620 search field or form fields. The websites as a 150 00:08:13,620 --> 00:08:17,640 whole, things like Facebook, for example, is pretty 151 00:08:17,640 --> 00:08:21,280 much built from user-supplied data. So from a, a 152 00:08:21,280 --> 00:08:23,900 security point of view, validating all that data and 153 00:08:23,900 --> 00:08:25,760 making sure you don't get caught out with security 154 00:08:25,760 --> 00:08:27,960 issues is, is, is more difficult. 155 00:08:28,720 --> 00:08:32,520 We also have now self-propagating cross-site scripting attack 156 00:08:32,520 --> 00:08:34,520 codes. So the cross-site scripting worms that I was 157 00:08:34,520 --> 00:08:36,740 talking about, we've got a section later on, on 158 00:08:36,740 --> 00:08:39,300 that. But really, they're stored cross-site scripting attacks. 159 00:08:39,460 --> 00:08:42,700 And we'll look at, again, an example later on. And 160 00:08:42,700 --> 00:08:45,320 really kind of tying back to that first point 161 00:08:45,320 --> 00:08:47,680 now, where we bring in data from data streams 162 00:08:47,680 --> 00:08:51,260 like JSON or XML. I think, you know, there's, there's 163 00:08:51,260 --> 00:08:53,440 a, you have to assume that they could be 164 00:08:53,440 --> 00:08:55,360 malicious, but I would say a lot of people 165 00:08:55,360 --> 00:08:57,460 probably don't. So if you pull in that data 166 00:08:57,460 --> 00:08:59,300 and inject it straight into the DOM, then, you 167 00:08:59,300 --> 00:09:00,700 know, your users can be exploited. 168 00:09:01,480 --> 00:09:03,420 So, you know, just to make some of those 169 00:09:03,420 --> 00:09:06,860 points a little bit clearer, because we have a, 170 00:09:06,860 --> 00:09:08,980 a very dynamic DOM in a lot of these 171 00:09:08,980 --> 00:09:12,360 applications, we'll use things like document.write or an 172 00:09:12,360 --> 00:09:15,340 eval statement to pull in data and inject it 173 00:09:15,340 --> 00:09:18,720 into the DOM. But the data you pull in 174 00:09:19,160 --> 00:09:21,240 to your eval or your document.write, you're not 175 00:09:21,240 --> 00:09:23,260 right. If you don't validate that before you use 176 00:09:23,260 --> 00:09:25,300 it, then you could be injecting the tag code 177 00:09:25,300 --> 00:09:26,340 into the user's DOM. 178 00:09:27,160 --> 00:09:29,760 So in the example we've got here, kind of the 179 00:09:29,760 --> 00:09:32,980 top half of the screen, we're making an XML HTTP 180 00:09:32,980 --> 00:09:35,840 request. So we're just making a request for data. 181 00:09:36,100 --> 00:09:38,360 And near the bottom is just the bit of code 182 00:09:38,360 --> 00:09:40,660 that's actually getting that data for us. So it's 183 00:09:40,660 --> 00:09:43,120 going through a proxy, so we're going to an 184 00:09:43,120 --> 00:09:46,160 off-domain location to grab that information. And 185 00:09:46,160 --> 00:09:49,620 essentially, there are, that's bits of code missing 186 00:09:49,620 --> 00:09:51,100 out of there for me to try and fit it on the screen. 187 00:09:51,240 --> 00:09:53,240 But essentially, you can see near the bottom we 188 00:09:53,240 --> 00:09:55,540 have an eval statement, and that's where we're passing 189 00:09:55,540 --> 00:10:00,560 that externally grabbed data into. So that'll execute that 190 00:10:00,560 --> 00:10:02,920 for us. So if you don't validate that before you 191 00:10:02,920 --> 00:10:05,100 use it, like we armed here, then you open 192 00:10:05,100 --> 00:10:06,160 yourselves up to an attack. 193 00:10:08,060 --> 00:10:10,920 So the next vulnerability is, is cross-site request forgery. 194 00:10:11,580 --> 00:10:14,160 And I didn't get a chance to come into the 195 00:10:14,160 --> 00:10:16,560 talk previously, but I guess anyone who was in 196 00:10:16,560 --> 00:10:18,780 the cross-site request forgery track already knows how 197 00:10:18,780 --> 00:10:20,400 bad this is and how bad it can get. 198 00:10:20,400 --> 00:10:23,620 So really, what I'm talking about here is, again, it's, 199 00:10:23,620 --> 00:10:25,900 it's not new, but it has the potential to be 200 00:10:25,900 --> 00:10:28,640 worse. And really, what you're doing with the cross-site 201 00:10:28,640 --> 00:10:32,420 request forgery attack is, is instead of executing malicious 202 00:10:33,060 --> 00:10:36,100 code on the client side, like we have in cross-site 203 00:10:36,100 --> 00:10:40,080 scripting, you're making a request, forcing a request to 204 00:10:40,080 --> 00:10:42,320 be made on behalf of that user without them knowing 205 00:10:42,320 --> 00:10:45,100 about it. So kind of just to reiterate that, it's 206 00:10:45,100 --> 00:10:48,740 important to remember that cross-site scripting's not cross-site 207 00:10:48,740 --> 00:10:50,380 request forgery. They are two separate attacks. 208 00:10:50,400 --> 00:10:54,840 So I've got a real simple example there, just in 209 00:10:55,260 --> 00:10:57,700 case anyone didn't make the last talk or, or not 210 00:10:57,700 --> 00:10:59,540 quite sure what cross-site request forgery is. 211 00:10:59,960 --> 00:11:03,220 We have a, a website here called NinjaRental.com. 212 00:11:03,600 --> 00:11:05,740 So you come along, you put your username and password 213 00:11:05,740 --> 00:11:08,560 and you hit submit, the request is sent to the 214 00:11:08,560 --> 00:11:11,040 server, the server authenticates you and sends the session 215 00:11:11,040 --> 00:11:11,700 ID back. 216 00:11:13,140 --> 00:11:16,280 So when you then, when that user's using the Ninja 217 00:11:16,280 --> 00:11:19,860 Rental site and he wants to rent a Ninja, he wants 218 00:11:19,860 --> 00:11:24,660 wants to just rent the regular Ninja for £100. He doesn't want to hire Chuck Norris. I probably 219 00:11:24,660 --> 00:11:29,040 wouldn't either. He's probably a little bit volatile for my liking. But the guy chooses 220 00:11:29,040 --> 00:11:35,420 the regular Ninja for £100, hits submit, sends that request to the server. The browser 221 00:11:35,420 --> 00:11:39,680 sees that, oh yeah, I've already got a session value for that, so he doesn't have to re-authenticate. 222 00:11:39,940 --> 00:11:44,900 The browser just sends that value along with the request. His account is debited in the 223 00:11:44,900 --> 00:11:51,400 back end, and then he gets a Ninja. What if, whilst he's still authenticated to that 224 00:11:51,400 --> 00:11:57,400 site, I get him to come along to my dodgy site dot com, and whilst we might be laughing 225 00:11:57,400 --> 00:12:00,860 at Agent Smith there to start off with, I think ultimately he's going to have the last 226 00:12:00,860 --> 00:12:06,640 laugh here. Because whilst you might think we can't make this request from this other 227 00:12:06,640 --> 00:12:12,580 site, we can use some tags like an image source tag, or an iframe source, or a script source 228 00:12:12,580 --> 00:12:14,840 tag to bypass that. 229 00:12:14,840 --> 00:12:19,680 A protection mechanism called the same origin policy, which should have prevented this attack 230 00:12:19,680 --> 00:12:25,580 happening, but by design those three tags allow that attack to happen. So when the user 231 00:12:25,580 --> 00:12:31,020 comes on this site, the funny pictures of Agent Smith load up. But in the background, 232 00:12:31,140 --> 00:12:36,160 the browser sees that it's got to make this request to NinjaRental.com as well. And you 233 00:12:36,160 --> 00:12:40,060 can see basically what it's doing is it's making a request to hire that Chuck Norris 234 00:12:40,060 --> 00:12:44,560 Ninja. So he's now going to have a £1,000 debited from his account without 235 00:12:44,560 --> 00:12:49,400 him ever actually sending that request. And again, the browser being helpful just sees 236 00:12:49,400 --> 00:12:53,260 that request being made in the background, sees you've got a session value for it, and 237 00:12:53,260 --> 00:12:55,980 sends that along and the, the request is made. 238 00:12:56,300 --> 00:13:01,520 So some people look at those examples and say, well, that's probably a bit too simple 239 00:13:01,520 --> 00:13:05,940 to work in the real world. We're going to take a look at an example in a minute where 240 00:13:06,280 --> 00:13:14,420 an attack almost the same as that was being exploited against Gmail for about 18 months 241 00:13:14,420 --> 00:13:15,560 I think before it was fixed. 242 00:13:17,100 --> 00:13:24,000 So what can make this worse in Web 2.0? Well, we can do attacks using XML and JSON. I'm going 243 00:13:24,000 --> 00:13:29,160 to look at a JSON-based cross-site request forgery attack in a minute. They can be a 244 00:13:29,160 --> 00:13:35,740 little bit tricky to do, but they're certainly possible. And one of the, the biggest issues 245 00:13:35,740 --> 00:13:40,940 with Web 2.0 is that, that cross-domain access is, is essential. You know, when we look at 246 00:13:40,940 --> 00:13:44,400 things like mash-up sites, they are essentially a cross-site attack. They are essentially a 247 00:13:44,400 --> 00:13:47,840 cross-site script and attack in the way that they're built, and they have to allow that 248 00:13:47,840 --> 00:13:48,660 cross-domain access. 249 00:13:49,360 --> 00:13:53,460 I think, talking about the mash-ups, I think Douglas Crockford once said that they, that 250 00:13:53,460 --> 00:13:58,900 they are kind of built as a cross-site script and attack because everything is, is cross-domain 251 00:13:58,900 --> 00:14:03,020 requests. And then really, like I mentioned before, same-origin policy isn't going to 252 00:14:03,020 --> 00:14:08,440 protect you. Whether we, we're still relying on same-origin policy or not, you know, we're 253 00:14:08,440 --> 00:14:14,380 going to see less and less protection from that going forward. So things like, the access, 254 00:14:14,400 --> 00:14:19,960 XML, HTTP requests, and, and even JSON data should only be called from the same domain. 255 00:14:20,180 --> 00:14:23,800 But again, we're going to look at in a second how you can get around that as well. 256 00:14:24,480 --> 00:14:30,960 So firstly, a very simple real-world example of a cross-site request fordry attack against 257 00:14:30,960 --> 00:14:36,760 Gmail that essentially brute forced a password reset against your account. So again, it was 258 00:14:36,760 --> 00:14:41,940 using the image source and the iframe source tag. So again, we're starting to see similarities 259 00:14:41,940 --> 00:14:43,240 to the example earlier. 260 00:14:44,400 --> 00:14:49,920 So, what the, the researcher found was that he could make these requests directly to reset 261 00:14:49,920 --> 00:14:56,080 the password with Google. So it has to provide an old password, so your current password, 262 00:14:56,240 --> 00:14:59,160 and then the password he wants to reset your account to. 263 00:14:59,380 --> 00:15:07,160 Now, normally, when you do the password reset with Gmail, you have to enter a capture. But 264 00:15:07,160 --> 00:15:14,240 by making this request directly, he could bypass the capture system. So he could brute 265 00:15:14,240 --> 00:15:16,960 force those values and try and reset your password for you. 266 00:15:17,380 --> 00:15:22,460 As I said, I think it, it took around 18 months, I think, from, from this guy first reporting 267 00:15:22,460 --> 00:15:28,640 it to when, to when it actually got fixed. And then the next kind of JSON-based attack 268 00:15:28,640 --> 00:15:32,500 I'm going to look at is also against Google. I'm not trying to beat up on Google here. 269 00:15:32,840 --> 00:15:37,220 Just like later on, I'm not going to try and beat up on Facebook. But they've got the best 270 00:15:37,220 --> 00:15:43,020 examples of these attacks so far, in my opinion. So normally, as I said, the XML, HTTP request, 271 00:15:43,820 --> 00:15:44,220 should be, should be, should be, should be, should be, should be, should be, should be, 272 00:15:44,240 --> 00:15:47,960 should only be able to pull in data from the same domain location. And the same for 273 00:15:47,960 --> 00:15:53,600 JSON. We shouldn't be able to request data from, from an off-domain location. But, you 274 00:15:53,600 --> 00:15:58,040 know, that's, that's not very Web 2.0 friendly. We mentioned before that we have to allow 275 00:15:58,040 --> 00:15:59,120 that cross-domain access. 276 00:15:59,540 --> 00:16:05,860 So we have a thing called JSON callbacks. And what a JSON callback allows you to do 277 00:16:05,860 --> 00:16:12,240 is to wrap the JSON data within a JavaScript function. So you can make that cross-domain 278 00:16:12,240 --> 00:16:12,540 request. 279 00:16:12,540 --> 00:16:16,440 Or grab that data, the JSON data, from a separate domain. 280 00:16:17,040 --> 00:16:22,440 So what a researcher found out was that he could use this to his advantage and steal 281 00:16:22,440 --> 00:16:26,680 your Google contacts. Unfortunately, he only used it as a proof of concept. So he didn't 282 00:16:26,680 --> 00:16:30,100 really steal your contacts. But, obviously, other people could do. 283 00:16:30,860 --> 00:16:35,540 So really, at the top of the screen there, we have the JavaScript function called Google. 284 00:16:35,720 --> 00:16:40,220 And we're waiting for the JSON data to be, to be wrapped in there, essentially. And when 285 00:16:40,220 --> 00:16:42,400 he receives it, he's just going to do a document. 286 00:16:42,400 --> 00:16:46,720 Write out your contact information to the page there. 287 00:16:47,300 --> 00:16:51,900 So at the bottom, we can see that there's also a URL to Google Docs. 288 00:16:51,960 --> 00:16:56,820 So normally what this URL would allow you to do is, one, when you're using Google Documents, 289 00:16:56,880 --> 00:16:59,160 you should be able to view your contacts whilst you're doing it. 290 00:16:59,380 --> 00:17:03,480 But the researcher found out if he, if he put the callback parameter on the end of the 291 00:17:03,480 --> 00:17:08,880 URL, wrap that within a JavaScript function, whenever you come to his page, that code would 292 00:17:08,880 --> 00:17:09,200 execute. 293 00:17:09,420 --> 00:17:10,560 Grab your contacts. 294 00:17:11,100 --> 00:17:11,820 And then. 295 00:17:12,400 --> 00:17:13,920 In this case, he'd just write it to the page. 296 00:17:14,060 --> 00:17:16,540 But, you know, he could have sent that anywhere he wanted. 297 00:17:18,560 --> 00:17:22,300 So SQL injection, again, not a new vulnerability. 298 00:17:22,460 --> 00:17:23,840 It's been around for a long time. 299 00:17:25,420 --> 00:17:32,800 And what we're seeing now is probably a different way of exploiting SQL injection, or a different 300 00:17:32,800 --> 00:17:35,600 motive for the attack in particular. 301 00:17:35,780 --> 00:17:38,740 So again, it's not new, but it's potentially worse. 302 00:17:39,520 --> 00:17:42,320 And really, what does SQL injection take? 303 00:17:42,320 --> 00:17:46,060 Well, what the attack is, it allows an attacker to inject his own bit of SQL into your backend 304 00:17:46,060 --> 00:17:46,840 SQL query. 305 00:17:47,160 --> 00:17:51,580 So we have a, a really simple example here where we're just gonna do, we're gonna take 306 00:17:51,580 --> 00:17:56,920 in a username from the user, and we'll do a select star from users where the name equals 307 00:17:56,920 --> 00:17:58,740 the username that the guy's provided. 308 00:17:59,160 --> 00:18:04,200 So if he provides, you know, a 1 or 1 equals 1, you know, the example that probably everyone's 309 00:18:04,200 --> 00:18:08,020 familiar with, then that query will become, you know, give me all the usernames where 310 00:18:08,020 --> 00:18:09,520 it's 1 or 1 equals 1. 311 00:18:09,640 --> 00:18:12,060 So give me all the names where it's equal to true. 312 00:18:12,060 --> 00:18:17,320 And again, this is a real simple example, but we're gonna look at a real world exploit 313 00:18:17,320 --> 00:18:20,700 in a minute which wasn't too much more complicated than this. 314 00:18:22,240 --> 00:18:26,880 So again, that was a simple example, but SQL injection's been used to steal large 315 00:18:26,880 --> 00:18:31,280 amounts of data, generally cause chaos on the internet through different, different 316 00:18:31,280 --> 00:18:31,560 means. 317 00:18:31,700 --> 00:18:36,500 So card systems, they lost 40 million credit card numbers through a SQL injection attack. 318 00:18:37,100 --> 00:18:42,040 We've seen automated SQL injection attacks compromise tens of thousands of millions of 319 00:18:42,060 --> 00:18:45,940 machines by exploiting vulnerabilities on the desktop. 320 00:18:46,140 --> 00:18:50,780 We're gonna look at one of these attacks that was, it's only about a week and a half old 321 00:18:50,780 --> 00:18:51,980 in a minute as well. 322 00:18:53,660 --> 00:18:58,120 And when I, when I try and give people a measurement of how many of these vulnerabilities 323 00:18:58,120 --> 00:19:02,700 we're seeing every year, I tend to use the amount of CVE numbers issued. 324 00:19:02,920 --> 00:19:08,160 And every different vendor will give you a different statistic on how many SQL injection 325 00:19:08,160 --> 00:19:10,000 attacks occur every year and so on. 326 00:19:10,440 --> 00:19:11,540 But for me. 327 00:19:11,540 --> 00:19:14,380 I find the CVE numbers quite useful. 328 00:19:15,060 --> 00:19:17,760 What's also useful is there is a great interface. 329 00:19:17,960 --> 00:19:22,180 So if you just do a Google search for CVE statistics, there's a great way to search 330 00:19:22,180 --> 00:19:22,780 for these yourself. 331 00:19:23,020 --> 00:19:31,040 But really the point is that of the CVE numbers issued in 2008 and 2009, 20% of all those 332 00:19:31,040 --> 00:19:33,540 vulnerabilities were SQL injection attacks. 333 00:19:34,200 --> 00:19:41,020 And kind of following on from that a bit, in 2008 and 2009 so far, cross-site scripting 334 00:19:41,020 --> 00:19:45,380 and SQL injection have accounted for roughly 33% of those vulnerabilities. 335 00:19:46,160 --> 00:19:52,240 Back in 2006, they accounted for less than 1% of all of the CVE numbers issued. 336 00:19:52,500 --> 00:19:56,340 So you can see that there's a definite switch in focus from the attackers. 337 00:19:57,380 --> 00:20:03,120 And from my point of view, SQL injection is the inspiration for my favorite XKCD comic. 338 00:20:03,340 --> 00:20:07,900 So I don't know if everyone might have seen this before, but really what's going on here 339 00:20:07,900 --> 00:20:10,300 is the mom receives a phone call from the school. 340 00:20:10,800 --> 00:20:12,180 They're having some computer trouble. 341 00:20:12,660 --> 00:20:15,600 So the mom says, oh, dear, did my son break something? 342 00:20:15,860 --> 00:20:17,120 They say, well, in a way. 343 00:20:17,240 --> 00:20:21,120 And they say, did you really name your son Robert, you know, drop table students? 344 00:20:23,100 --> 00:20:25,420 So she said, yeah, that's little Bobby Tables. 345 00:20:26,320 --> 00:20:31,040 And if you go to Facebook, the Bobby Tables account is also mine as well. 346 00:20:31,080 --> 00:20:37,060 I don't know whether that says a lot about me or not, but really the mom says, well, 347 00:20:37,140 --> 00:20:38,280 you know, that's your fault. 348 00:20:38,320 --> 00:20:40,200 Make sure you sanitize your database input. 349 00:20:40,200 --> 00:20:44,300 And whilst it's only a simple comic, it actually makes a very good point. 350 00:20:44,460 --> 00:20:49,160 Before you use any externally supplied data or any data in your SQL queries, make sure 351 00:20:49,160 --> 00:20:50,280 you validate it first. 352 00:20:51,580 --> 00:20:58,880 So in terms of Web 2.0, SQL injection, I think, for the time being, will still continue 353 00:20:58,880 --> 00:21:04,540 to be used for data theft, bypassing authentication systems, you know, dropping tables and someone 354 00:21:04,540 --> 00:21:06,880 like Bobby Tables' mom has just done. 355 00:21:07,120 --> 00:21:10,060 But what we're also seeing is if you think of things like Flash. 356 00:21:10,200 --> 00:21:15,860 And then kind of JavaScript as technologies that users have to have enabled nowadays to 357 00:21:15,860 --> 00:21:20,080 go and use these kind of Web 2.0 sites, well, the attackers know that just as much as we 358 00:21:20,080 --> 00:21:20,460 know that. 359 00:21:20,660 --> 00:21:27,220 So what they're starting to do is exploit the fact that people will need Flash or will 360 00:21:27,220 --> 00:21:30,380 have Flash and JavaScript enabled when they come to these sites. 361 00:21:30,500 --> 00:21:34,040 I mean, it's okay as security guys telling people you should use NoScript. 362 00:21:34,220 --> 00:21:39,320 But most of the sites the average user use nowadays will be completely broken if they 363 00:21:39,320 --> 00:21:40,180 go there with NoScript. 364 00:21:40,200 --> 00:21:40,780 NoScript turned on. 365 00:21:41,080 --> 00:21:49,100 So we're seeing SQL injection vulnerabilities not being used to steal data, not directly, 366 00:21:49,360 --> 00:21:55,440 but to inject malicious Flash files into sites that then when a user comes to the site, views 367 00:21:55,440 --> 00:21:58,620 the Flash video, it exploits the floor in the Adobe Flash player. 368 00:21:58,840 --> 00:22:04,620 We're also seeing people injecting malware serving JavaScript as well. 369 00:22:04,680 --> 00:22:09,280 And we'll look at an example in a minute from about a week and a half ago of an automated 370 00:22:09,280 --> 00:22:09,780 attack. 371 00:22:09,780 --> 00:22:12,460 Trying to inject this malware serving JavaScript. 372 00:22:14,120 --> 00:22:19,440 And it doesn't kind of matter how you're transmitting your data around. 373 00:22:19,600 --> 00:22:24,900 As long as you take externally supplied data and put it into your SQL query in the backend, 374 00:22:25,140 --> 00:22:29,600 it doesn't really matter whether you're doing that through JSON, XML, SOAP, whatever you 375 00:22:29,600 --> 00:22:30,100 want to use. 376 00:22:31,420 --> 00:22:38,400 So firstly, a simple example, a recent example of an authentication bypass SQL injection 377 00:22:38,400 --> 00:22:38,860 attack. 378 00:22:39,820 --> 00:22:44,760 So what this guy found was that in this server called Alumni Server, it would take in two 379 00:22:44,760 --> 00:22:46,080 values from the user. 380 00:22:46,180 --> 00:22:51,100 Take an email address and a password value, and then use them directly in a SQL query 381 00:22:51,100 --> 00:22:52,300 without doing any validation. 382 00:22:53,180 --> 00:22:58,940 So what he did is he put his email address in there, single quote parenthesis, or one 383 00:22:58,940 --> 00:22:59,500 equals one. 384 00:22:59,680 --> 00:23:05,000 So so far he's saying pick an email address where it's equal to true. 385 00:23:05,420 --> 00:23:09,760 And then the slash star in MySQL actually says, essentially, I'm going to do this. 386 00:23:09,780 --> 00:23:10,760 Essentially ignore the rest of that. 387 00:23:10,880 --> 00:23:12,540 So he doesn't have to provide a password value. 388 00:23:12,820 --> 00:23:17,940 So he's just put, essentially, any email address or one equals one, ignore the rest 389 00:23:17,940 --> 00:23:20,620 of it, and he's bypassed the authentication system. 390 00:23:20,980 --> 00:23:25,720 So like I said, even though the kind of one equals one example, probably people get fed 391 00:23:25,720 --> 00:23:30,380 up of seeing that, sometimes it is that easy in the real world. 392 00:23:31,760 --> 00:23:33,320 So the very simple attack there. 393 00:23:33,580 --> 00:23:37,700 Now this one, I'm not going to try and step through all the white SQL stuff here at the 394 00:23:37,700 --> 00:23:37,980 moment. 395 00:23:38,080 --> 00:23:38,880 There's a lot of it there. 396 00:23:39,780 --> 00:23:43,340 Obviously this was from, I think it was about a week and a half, two weeks ago. 397 00:23:43,580 --> 00:23:48,700 And the bit in orange on the screen there is really the important thing to look at here. 398 00:23:48,820 --> 00:23:52,880 And what this attack was doing, it was automatically trying to find SQL injection vulnerabilities 399 00:23:52,880 --> 00:23:56,640 in websites, inject the script tags. 400 00:23:56,720 --> 00:24:02,140 When anyone came along, viewed the site, it would basically make a request to execute 401 00:24:02,140 --> 00:24:03,200 this JavaScript file. 402 00:24:03,420 --> 00:24:08,820 And then try and exploit the Office web component's vulnerability, which I think even now might 403 00:24:08,820 --> 00:24:09,640 still be on patch. 404 00:24:09,780 --> 00:24:15,960 And at the time of me writing this presentation, the file contained two URLs. 405 00:24:16,320 --> 00:24:26,340 And the code it tried to push down was only being picked up by 15 of the 41 virus scanners 406 00:24:26,340 --> 00:24:27,140 on VirusTotal. 407 00:24:27,220 --> 00:24:29,160 And that was on the 16th of July. 408 00:24:29,840 --> 00:24:37,280 So you can see that attackers know that people have to have the ability to execute JavaScript 409 00:24:37,280 --> 00:24:38,220 when they come to pages. 410 00:24:38,320 --> 00:24:39,760 So they try and exploit that. 411 00:24:39,760 --> 00:24:43,980 So next up is Cross-Site Script in Worms. 412 00:24:44,000 --> 00:24:47,780 We know that Cross-Site Script in itself isn't new to Web 2.0. 413 00:24:47,860 --> 00:24:51,720 And I guess there's an argument whether Cross-Site Script in Worms is or isn't. 414 00:24:51,740 --> 00:24:56,580 Because essentially, when Sammy exploited MySpace, it wasn't a Web 2.0 site. 415 00:24:56,800 --> 00:25:01,620 But he used Web 2.0 technologies like XML HTTP requests for the exploit. 416 00:25:01,960 --> 00:25:04,740 Now, like I said, I'm not going to step through the Sammy code today. 417 00:25:04,820 --> 00:25:08,560 But I would say I'm definitely going to have a read of it, because he did some quite clever 418 00:25:08,560 --> 00:25:09,640 things when he exploited. 419 00:25:09,760 --> 00:25:11,120 He exploited MySpace there. 420 00:25:11,500 --> 00:25:16,160 I do feel a little bit obliged to mention Sammy, because I think that it was probably 421 00:25:16,160 --> 00:25:21,840 the first big example of Cross-Site Script in attacks, let alone Cross-Site Script in 422 00:25:21,840 --> 00:25:22,880 Worms, in my opinion. 423 00:25:23,160 --> 00:25:25,560 So he did this four years ago. 424 00:25:25,680 --> 00:25:32,920 And he managed to exploit over a million profiles, or in fact, a million profiles in about 24 425 00:25:32,920 --> 00:25:33,400 hours. 426 00:25:33,740 --> 00:25:39,720 And even in 2009, Sammy is still a hero, firstly, because he's not really been eclipsed in 427 00:25:39,760 --> 00:25:41,240 terms of the amount of infections he's got. 428 00:25:41,440 --> 00:25:48,860 But if you do a Google search for, you know, a site, MySpace, and I think whatever line 429 00:25:48,860 --> 00:25:53,680 of text he injected, something like, and above all, Sammy is my hero, you'll still see reams 430 00:25:53,680 --> 00:25:56,060 and reams of profiles that still have that text. 431 00:25:56,180 --> 00:25:59,380 Not the JavaScript in there anymore, but that text in there. 432 00:25:59,520 --> 00:26:02,580 Most notably, actually, Hulk Hogan has got that. 433 00:26:02,620 --> 00:26:06,640 Now, I don't know whether I would go exploiting Hulk Hogan's MySpace page, but, you know, 434 00:26:06,660 --> 00:26:07,880 Sammy managed to do that. 435 00:26:08,720 --> 00:26:09,120 Okay. 436 00:26:09,760 --> 00:26:12,800 So I guess if I was sat in the crowd now, I'd be thinking, well, Sammy's old. 437 00:26:13,020 --> 00:26:14,440 Tell me about something new. 438 00:26:14,700 --> 00:26:18,880 So I managed to kind of find something a bit more recent. 439 00:26:19,100 --> 00:26:24,500 The Stork Daily, or I think it was also referred to as the Mikey Worm, that infected Twitter 440 00:26:24,500 --> 00:26:26,160 in April, Easter weekend. 441 00:26:26,700 --> 00:26:32,520 And really, the problem here was that on your Twitter profile, you can put your URL into 442 00:26:32,520 --> 00:26:33,000 the page. 443 00:26:33,220 --> 00:26:36,940 And they weren't validating that URL field correctly. 444 00:26:37,260 --> 00:26:39,740 So what this guy managed to figure out was he can put his Stork Daily in there. 445 00:26:39,740 --> 00:26:43,180 StorkDaily.com, URL in there, throw a script tag on the end. 446 00:26:43,560 --> 00:26:47,780 Whenever someone come and viewed that, the script would execute and so on and so on and 447 00:26:47,780 --> 00:26:48,540 affect their profile. 448 00:26:48,720 --> 00:26:53,280 So what we're going to do is step through some of the code, or the most important points 449 00:26:53,280 --> 00:26:54,840 in the code, at least, anyway, here. 450 00:26:55,900 --> 00:27:00,600 So firstly, what he did was to grab your authentication token. 451 00:27:00,800 --> 00:27:04,340 So at the top there, we've got a regular expression where he's just going to grab your authentication 452 00:27:04,780 --> 00:27:08,700 token, because he needs that to make two requests on your behalf, which he's going 453 00:27:08,700 --> 00:27:09,420 to do in a minute. 454 00:27:10,520 --> 00:27:13,660 In the middle there, as well, he had an array of tweets. 455 00:27:13,920 --> 00:27:15,780 So he wasn't going to use the same tweet for everyone. 456 00:27:15,860 --> 00:27:22,680 I don't know if that was to try and evade people picking up on us as an exploit or 457 00:27:22,680 --> 00:27:23,320 something like that. 458 00:27:23,440 --> 00:27:26,840 But basically, what he would do is he would pull one of the tweets out of that array, 459 00:27:27,020 --> 00:27:30,760 and then use that to update your page with one of the posts in a second. 460 00:27:31,100 --> 00:27:35,280 And then at the bottom there, he's got his StorkDaily.com URL with that script source 461 00:27:35,280 --> 00:27:39,040 on the end, which again, he's going to use to inject into your profile in a minute. 462 00:27:39,140 --> 00:27:39,620 All right. 463 00:27:39,740 --> 00:27:41,200 So like I said, he makes two requests. 464 00:27:41,540 --> 00:27:46,120 Firstly, he updates your status with one of those tweets out of his array. 465 00:27:46,320 --> 00:27:48,940 So he passes along the authentication token that he grabbed. 466 00:27:49,100 --> 00:27:51,340 He takes one of those tweets, updates your profile. 467 00:27:51,820 --> 00:27:58,300 And then secondly there, he makes a second post to change your account settings to include 468 00:27:58,300 --> 00:27:59,160 his attack code. 469 00:27:59,400 --> 00:28:01,680 So again, he's passing the authentication token. 470 00:28:01,900 --> 00:28:03,500 He injects that code into your page. 471 00:28:03,560 --> 00:28:07,700 Anyone comes along, this will all execute on their page, and so on and so on. 472 00:28:07,840 --> 00:28:09,720 I think he got something out of that. 473 00:28:09,740 --> 00:28:13,180 It's been like 17,000 infections with this StorkDaily worm. 474 00:28:13,280 --> 00:28:15,460 They fixed it, and he did another worm the day after. 475 00:28:15,680 --> 00:28:18,060 I think that was the Mikey worm. 476 00:28:18,220 --> 00:28:20,140 I think he exploited a different floor. 477 00:28:20,320 --> 00:28:23,500 Pretty much the same thing in Twitter two days in a row. 478 00:28:24,780 --> 00:28:27,420 So just two more extra points there as well. 479 00:28:27,500 --> 00:28:31,420 He needed to have your screen name to make a post on your behalf. 480 00:28:31,700 --> 00:28:35,600 So again, he's got another regular expression there where he pulls your screen name out 481 00:28:35,600 --> 00:28:38,920 of the meta content field so he can make those updates on your behalf. 482 00:28:39,100 --> 00:28:39,720 And then the next thing he does is he puts your screen name on the post. 483 00:28:39,720 --> 00:28:41,700 And lastly, at the bottom there, he takes your username and cookie 484 00:28:41,700 --> 00:28:44,040 and sends it off to another domain of his. 485 00:28:44,420 --> 00:28:46,980 Why not? If you can do, take everything you can get. 486 00:28:48,840 --> 00:28:50,760 That's not my professional opinion, of course. 487 00:28:52,180 --> 00:28:54,840 So how will this get worse, or how can this get worse? 488 00:28:55,080 --> 00:28:57,980 Well, some of the worms that we've seen so far 489 00:28:58,700 --> 00:29:01,260 rely on kind of some quirks in browser behavior. 490 00:29:01,520 --> 00:29:04,860 So first, if you could get a worm that's fully supported by all browsers, 491 00:29:05,060 --> 00:29:07,620 I don't know how easy or hard that is 492 00:29:07,620 --> 00:29:10,080 because a lot of websites aren't supported by all browsers, 493 00:29:10,240 --> 00:29:13,740 but if you can get your worm code to be fully supported across all browsers 494 00:29:13,740 --> 00:29:18,240 and build a worm that is kind of site or floor independent, 495 00:29:18,760 --> 00:29:20,920 I mean, you've seen the Stalk Daily code there, 496 00:29:21,000 --> 00:29:22,640 and if anyone's seen Sammy's code, 497 00:29:22,960 --> 00:29:25,480 you'll know that they were written very specifically 498 00:29:25,480 --> 00:29:27,740 for a specific floor and a specific site. 499 00:29:28,320 --> 00:29:32,180 If you could find a way of writing a kind of universal 500 00:29:32,180 --> 00:29:34,380 or generic cross-site scripting worm, 501 00:29:34,540 --> 00:29:37,360 then you could have whatever you want 502 00:29:37,360 --> 00:29:39,580 and call it an intelligent hybrid super worm. 503 00:29:40,600 --> 00:29:43,440 Now, PDP and Billy Hoffman have done some great research on this. 504 00:29:43,500 --> 00:29:46,600 I'd recommend, if you want to learn more about this specific issue, 505 00:29:46,660 --> 00:29:47,400 take a look at it. 506 00:29:47,480 --> 00:29:51,820 But really what they're proposing is if you can build this kind of generic worm code 507 00:29:51,820 --> 00:29:54,660 that can go to sites like XSS.com, 508 00:29:54,820 --> 00:29:58,380 and I think there's an area on Arsnake's forum as well 509 00:29:58,380 --> 00:30:00,360 that talks about new cross-site scripting attacks, 510 00:30:01,120 --> 00:30:03,060 but mainly XSS.com. 511 00:30:03,080 --> 00:30:05,620 If you go there, it not only tells you the site that was exploited, 512 00:30:05,700 --> 00:30:06,540 but I think, you know, 513 00:30:06,540 --> 00:30:08,120 exactly where the floor is and so on. 514 00:30:08,260 --> 00:30:10,320 If you could go to that site, pick the top 50 off, 515 00:30:10,380 --> 00:30:12,120 and go and automatically exploit all of those 516 00:30:12,120 --> 00:30:15,340 with a worm similar to Sammy or StorkDaily, 517 00:30:15,500 --> 00:30:19,400 then you could be talking to millions, millions of people infected, 518 00:30:19,520 --> 00:30:21,640 depending on who you're exploiting. 519 00:30:22,640 --> 00:30:26,640 And then, lastly, one of the things that I don't think we've seen on a wide scale yet 520 00:30:26,640 --> 00:30:28,820 is using cross-site scripting worm infections 521 00:30:28,820 --> 00:30:31,380 for distributed denial-of-service attacks. 522 00:30:32,840 --> 00:30:35,800 If you think Sammy essentially had... 523 00:30:36,540 --> 00:30:41,120 a million-plus browsers under his control at one point or another, 524 00:30:41,360 --> 00:30:43,340 now, what if he would have used every one of those 525 00:30:43,340 --> 00:30:46,100 to make a hundred or a thousand requests to your website? 526 00:30:46,640 --> 00:30:49,280 You're talking the kind of traffic that not many websites 527 00:30:49,280 --> 00:30:51,460 would be able to handle, you know, hundreds of millions of requests. 528 00:30:53,120 --> 00:30:55,320 So we've not really seen that yet, 529 00:30:55,860 --> 00:30:58,240 but it's something that is possible. 530 00:30:58,420 --> 00:31:01,880 If you've got a big enough amount of people infected, 531 00:31:02,100 --> 00:31:04,200 then people might use it in the same way 532 00:31:04,200 --> 00:31:06,240 as they would use a traditional kind of botnet. 533 00:31:07,840 --> 00:31:11,240 So the next thing I want to quickly look at is feed injection. 534 00:31:11,620 --> 00:31:15,060 So, like I said at the start, with Web 2.0, 535 00:31:15,160 --> 00:31:17,780 we don't want people to have to come back to our site 536 00:31:17,780 --> 00:31:20,780 every half an hour to see if we've made an update to our block. 537 00:31:20,980 --> 00:31:23,800 We want them to be able to pull that down automatically 538 00:31:23,800 --> 00:31:25,800 with things like RSS and Atom 539 00:31:25,800 --> 00:31:28,160 and using readers to pull that down. 540 00:31:28,480 --> 00:31:32,520 Now, the problem is, again, kind of like with any other of these problems, 541 00:31:32,720 --> 00:31:36,520 if you pull that data down and use it without validating it, 542 00:31:36,540 --> 00:31:38,420 then you open yourself up to attack. 543 00:31:39,080 --> 00:31:43,460 So we kind of have two kind of main differences between readers, 544 00:31:43,600 --> 00:31:46,560 ones that are either web browser-based or web-based 545 00:31:46,560 --> 00:31:48,420 or ones that are on the desktop. 546 00:31:48,680 --> 00:31:51,220 And there are kind of clear differences 547 00:31:51,220 --> 00:31:53,360 between the security issues between the two of them. 548 00:31:53,740 --> 00:31:56,360 Well, when you're in the browser, you're a little bit limited 549 00:31:56,360 --> 00:31:58,860 to the kind of damage you can do to the user. 550 00:31:59,120 --> 00:32:00,940 You know, things like cross-site scripting, 551 00:32:01,000 --> 00:32:03,480 cross-site request forgery, you know, 552 00:32:03,480 --> 00:32:06,420 they're possible through remote zone risks, as I call them. 553 00:32:06,540 --> 00:32:08,940 So the remote zone readers, whilst you're in the web browser, 554 00:32:08,980 --> 00:32:12,320 you can, you know, cross-site script the user and so on here. 555 00:32:13,440 --> 00:32:16,120 But you're kind of limited to that context. 556 00:32:16,320 --> 00:32:18,420 And we'll look at a local zone reader in a second 557 00:32:18,420 --> 00:32:20,300 of a real-world vulnerability there. 558 00:32:20,400 --> 00:32:25,580 But in the remote zone, if you just pulled in this RSS story 559 00:32:25,580 --> 00:32:29,320 and put it into the reader without doing any validation, 560 00:32:29,600 --> 00:32:30,620 then that code could execute. 561 00:32:30,820 --> 00:32:33,220 And in this example here, it's just stealing their cookie 562 00:32:33,220 --> 00:32:35,360 and sending it to my cookiemonster.cgi. 563 00:32:35,800 --> 00:32:36,200 Again, 564 00:32:36,540 --> 00:32:39,100 it just comes back to input validation, essentially. 565 00:32:39,400 --> 00:32:40,880 Validate that before you use it. 566 00:32:41,580 --> 00:32:43,720 And that's one of the things we'll look at later on 567 00:32:43,720 --> 00:32:45,580 is fixing security vulnerabilities 568 00:32:45,580 --> 00:32:48,180 doesn't have to be particularly complex, in my opinion. 569 00:32:48,380 --> 00:32:51,140 And we'll look at what I mean on that a little bit later on. 570 00:32:51,780 --> 00:32:53,540 So the local zone risks, 571 00:32:53,640 --> 00:32:56,560 this is where we have kind of a reader installed on the desktop. 572 00:32:57,320 --> 00:32:59,280 And what that can give an attacker 573 00:32:59,280 --> 00:33:02,560 is access to read and write content from the file system. 574 00:33:02,840 --> 00:33:05,240 You'll be able to use things like ActiveX components 575 00:33:05,700 --> 00:33:06,280 to do... 576 00:33:06,280 --> 00:33:07,720 a lot of different interesting things. 577 00:33:07,880 --> 00:33:10,080 And we'll again see a vulnerability in a second 578 00:33:10,080 --> 00:33:13,600 where someone was able to execute any Perl code he wanted 579 00:33:14,240 --> 00:33:15,580 on your computer 580 00:33:15,580 --> 00:33:17,580 just through injecting a malicious feed. 581 00:33:19,340 --> 00:33:20,920 Basically, with these local zone readers, 582 00:33:21,020 --> 00:33:23,100 what a lot of them do is they pull down the feed, 583 00:33:23,180 --> 00:33:25,100 write it to a HTML file locally, 584 00:33:25,240 --> 00:33:27,400 and when you want to view that feed, 585 00:33:27,560 --> 00:33:29,100 you click on it, it takes it out, 586 00:33:29,140 --> 00:33:30,980 puts it in the browser, away you go. 587 00:33:32,000 --> 00:33:33,900 And when you're using those readers, 588 00:33:33,940 --> 00:33:35,140 you're in the local context. 589 00:33:35,200 --> 00:33:36,260 So if a vulnerability exists, 590 00:33:36,280 --> 00:33:39,240 then you can read and potentially write from the file system. 591 00:33:39,860 --> 00:33:41,460 So an example here is 592 00:33:41,460 --> 00:33:43,840 if I injected that into a feed 593 00:33:43,840 --> 00:33:46,500 and you came along in your local reader 594 00:33:46,500 --> 00:33:47,380 and tried to view it, 595 00:33:47,460 --> 00:33:48,900 then what it's essentially doing 596 00:33:48,900 --> 00:33:51,220 is it's grabbing a file called secrets.txt 597 00:33:51,220 --> 00:33:53,180 using one of those ActiveX components 598 00:33:53,180 --> 00:33:55,720 to allow me to take that data out 599 00:33:55,720 --> 00:33:57,760 to my file monster.cgi. 600 00:33:58,100 --> 00:33:59,780 Now obviously when a user clicks on this, 601 00:33:59,820 --> 00:34:01,300 you'll get an ActiveX pop-up saying, 602 00:34:01,380 --> 00:34:02,220 do you want to allow this? 603 00:34:02,940 --> 00:34:04,060 Nine times out of ten, 604 00:34:04,140 --> 00:34:05,760 the user just thinks it's asking, 605 00:34:05,760 --> 00:34:07,200 do you want me to go to that website 606 00:34:07,200 --> 00:34:08,500 for you to get your news? 607 00:34:08,680 --> 00:34:09,480 They'll click yes, 608 00:34:09,620 --> 00:34:11,540 and you can steal secrets.txt. 609 00:34:13,120 --> 00:34:15,380 So a real-world vulnerability here 610 00:34:15,380 --> 00:34:16,780 in a local zone reader 611 00:34:17,980 --> 00:34:18,860 called Yasser. 612 00:34:19,040 --> 00:34:22,560 Basically, part of this application 613 00:34:22,560 --> 00:34:24,040 was a thing called GUI.pm. 614 00:34:24,380 --> 00:34:27,640 Now when this presentation goes up online, 615 00:34:27,820 --> 00:34:30,020 I've got all the code for GUI.pm in the notes 616 00:34:30,020 --> 00:34:31,780 if you want to step through it 617 00:34:31,780 --> 00:34:33,180 and see the vulnerability for yourselves. 618 00:34:33,340 --> 00:34:34,380 But basically what that did 619 00:34:34,380 --> 00:34:35,740 was it took in the URL, 620 00:34:35,740 --> 00:34:37,720 and when you wanted to view it, 621 00:34:37,780 --> 00:34:39,120 it put it into an exec statement 622 00:34:39,120 --> 00:34:40,240 and launched the browser 623 00:34:40,240 --> 00:34:42,380 without doing any validation on the URL. 624 00:34:42,840 --> 00:34:44,540 So what the researcher figured out 625 00:34:44,540 --> 00:34:46,320 was that fine, well I'll exploit that then. 626 00:34:46,500 --> 00:34:48,120 So he was passing in the link, 627 00:34:48,260 --> 00:34:50,060 putting a semicolon at the end, 628 00:34:50,180 --> 00:34:51,680 and doing a perl minus e, 629 00:34:51,820 --> 00:34:54,720 and well, whatever he wanted at the end there really. 630 00:34:55,680 --> 00:34:58,740 So again, there's nothing really complicated 631 00:34:58,740 --> 00:35:00,400 about that attack. 632 00:35:01,540 --> 00:35:02,840 But again, it just shows 633 00:35:02,840 --> 00:35:04,640 lack of validation, for example, 634 00:35:04,740 --> 00:35:05,720 allows him to do that. 635 00:35:05,720 --> 00:35:07,440 He can do, essentially, whatever he wanted to 636 00:35:07,440 --> 00:35:08,580 with that perl on the system. 637 00:35:09,320 --> 00:35:12,040 So how can these attacks get worse? 638 00:35:12,760 --> 00:35:15,920 Well, I think if you could find a vulnerability 639 00:35:15,920 --> 00:35:18,720 in a widely used site and a widely used reader, 640 00:35:18,860 --> 00:35:22,040 so I know something like the BBC news site 641 00:35:22,480 --> 00:35:23,600 and a popular reader. 642 00:35:23,820 --> 00:35:26,500 I'm not really up on what's popular in RSS readers, 643 00:35:26,600 --> 00:35:28,160 but Google Reader, for example. 644 00:35:28,440 --> 00:35:30,260 If you could find an exploit in both of those, 645 00:35:30,300 --> 00:35:33,220 you could inject malicious code into the BBC site, 646 00:35:33,380 --> 00:35:34,740 which then exploits the floor 647 00:35:34,740 --> 00:35:36,240 and all the Google Reader users. 648 00:35:36,920 --> 00:35:38,140 Then obviously you could have 649 00:35:38,140 --> 00:35:39,860 wide-scale exploitation of users. 650 00:35:41,300 --> 00:35:45,240 And whilst you're down on the client side in particular, 651 00:35:45,480 --> 00:35:47,760 you can do a lot of things like data theft, 652 00:35:48,060 --> 00:35:49,820 port scanning, and so on. 653 00:35:50,800 --> 00:35:52,260 If you can find the vulnerability, 654 00:35:52,320 --> 00:35:54,900 as you saw with the YASA vulnerability there, 655 00:35:54,940 --> 00:35:56,280 you're only, in that case, 656 00:35:56,320 --> 00:35:58,700 limited by your perl skills, really. 657 00:36:00,540 --> 00:36:02,260 So mashup and widgets, 658 00:36:02,480 --> 00:36:04,260 and kind of where I say widgets here, 659 00:36:04,260 --> 00:36:07,540 that means anything that could be regarded as a widget. 660 00:36:07,680 --> 00:36:08,820 You know, Facebook applications, 661 00:36:09,760 --> 00:36:11,540 things you put on NetVibe sites, 662 00:36:12,000 --> 00:36:14,080 Page Flakes, all of those types of things. 663 00:36:14,200 --> 00:36:16,960 I couldn't find a common term for it, 664 00:36:17,020 --> 00:36:18,400 so I just called it a widget for now. 665 00:36:18,560 --> 00:36:21,020 So really, kind of mashups, 666 00:36:21,080 --> 00:36:22,860 mashup sites and widget sites, 667 00:36:22,980 --> 00:36:27,420 I guess are kind of a good example of Web 2.0 sites. 668 00:36:27,540 --> 00:36:30,980 So a mashup site will pull in data from different sources 669 00:36:30,980 --> 00:36:32,800 to give you one single output. 670 00:36:33,020 --> 00:36:34,080 And a widget site, 671 00:36:34,080 --> 00:36:37,020 is essentially a blank canvas site for a user. 672 00:36:37,100 --> 00:36:39,040 They can come along, use something like iGoogle, 673 00:36:39,120 --> 00:36:41,600 and build the web page that they want to see 674 00:36:41,600 --> 00:36:42,840 first thing every morning. 675 00:36:43,160 --> 00:36:45,000 So we'll look at two examples in a second, 676 00:36:45,080 --> 00:36:48,620 but I found this site for a mashup 677 00:36:48,620 --> 00:36:50,060 that I thought was actually quite interesting. 678 00:36:51,000 --> 00:36:54,220 What this site does is it takes in news feeds, 679 00:36:55,660 --> 00:36:57,140 I don't know where they get them from, 680 00:36:57,180 --> 00:36:58,420 but Reuters in this case, 681 00:36:58,540 --> 00:36:59,980 and it's looking there and it's saying, 682 00:37:00,040 --> 00:37:01,360 that story is coming from London, 683 00:37:01,480 --> 00:37:03,620 so I'll take you to London on Google Maps. 684 00:37:04,520 --> 00:37:05,400 Simple example, 685 00:37:05,680 --> 00:37:09,460 but we see a lot of similar types of sites that are out there, 686 00:37:09,520 --> 00:37:11,740 where they take something and show it to you on a Google Map. 687 00:37:13,320 --> 00:37:15,560 The problem is, and like I said, 688 00:37:15,640 --> 00:37:18,000 Douglas Crockford said that a mashup is essentially 689 00:37:18,000 --> 00:37:19,840 a self-inflicted cross-site scripting attack, 690 00:37:20,120 --> 00:37:22,520 but we're pulling multiple inputs 691 00:37:23,140 --> 00:37:25,420 and giving it to you in one output as a user. 692 00:37:25,680 --> 00:37:29,020 Now, we're pulling that data from multiple sources, 693 00:37:29,220 --> 00:37:31,060 and again, if you don't validate that 694 00:37:31,060 --> 00:37:33,620 and just push it straight out there into one place for the user, 695 00:37:34,080 --> 00:37:35,480 then you can exploit the user. 696 00:37:36,820 --> 00:37:40,000 If you think of maybe a similar example 697 00:37:40,000 --> 00:37:41,020 to the one we just looked at, 698 00:37:41,080 --> 00:37:43,200 maybe a photo website where you take your photos 699 00:37:43,200 --> 00:37:44,840 and you put a location tag in there 700 00:37:44,840 --> 00:37:45,900 saying where you took the picture. 701 00:37:46,600 --> 00:37:47,600 Now, if someone comes along 702 00:37:47,600 --> 00:37:50,840 and he wants to map your photos to Google Maps, 703 00:37:52,440 --> 00:37:55,800 then you might have to provide your photo site 704 00:37:55,800 --> 00:37:57,280 logon details to him. 705 00:37:57,700 --> 00:37:59,460 Now, normally if you go to your photo site, 706 00:37:59,540 --> 00:38:01,240 it's probably SSLed and so on, 707 00:38:01,240 --> 00:38:03,040 and you're comfortable with the fact 708 00:38:03,040 --> 00:38:04,060 that your credentials are posted, and so on, and so forth. 709 00:38:04,060 --> 00:38:05,160 It's probably protected in transit. 710 00:38:05,520 --> 00:38:07,580 But how do you know that the mashup site, 711 00:38:07,820 --> 00:38:09,380 that essentially that man in the middle, 712 00:38:09,480 --> 00:38:11,680 how is he handling that data for you? 713 00:38:11,800 --> 00:38:13,820 Is he taking a copy of it from himself? 714 00:38:14,100 --> 00:38:16,900 Is he just sending over HTTP instead of SSL? 715 00:38:17,540 --> 00:38:20,240 And I guess, whilst I'm speaking at DEF CON, 716 00:38:20,360 --> 00:38:21,140 probably everyone's thinking, 717 00:38:21,180 --> 00:38:22,660 well, SSL is not that great either. 718 00:38:22,800 --> 00:38:25,720 But the point is, if he's not protecting it in transit, 719 00:38:26,320 --> 00:38:28,460 then you can lose that data. 720 00:38:29,780 --> 00:38:33,180 And mashups, by default, by their design, 721 00:38:33,180 --> 00:38:34,600 they have to have that cross-domain access. 722 00:38:34,820 --> 00:38:38,080 So again, if we were still relying on same-origin policy, 723 00:38:38,240 --> 00:38:41,300 it's kind of goodbye to those types of protections anyway now. 724 00:38:42,180 --> 00:38:44,640 And then ultimately, the mashup site is the middleman. 725 00:38:44,660 --> 00:38:48,020 And you have to decide, do you trust the mashup site itself? 726 00:38:48,520 --> 00:38:51,240 On the example before, I probably trust Reuters. 727 00:38:51,420 --> 00:38:52,800 I probably trust Google Maps. 728 00:38:53,260 --> 00:38:56,060 But the output I'm getting is, strictly speaking, 729 00:38:56,100 --> 00:38:57,260 not from either of those. 730 00:38:57,420 --> 00:39:00,260 It's coming from the mashup middleman site itself. 731 00:39:00,740 --> 00:39:03,020 So there's the potential. 732 00:39:04,340 --> 00:39:07,000 Maybe if you have a housing site, for example, 733 00:39:07,100 --> 00:39:09,100 and people come and look at that, look it on Google Maps, 734 00:39:09,280 --> 00:39:13,200 and say, oh, I want to go to an area with a lower area of crime. 735 00:39:13,720 --> 00:39:17,780 Now, how do you know that the mashup site, the middleman there, 736 00:39:17,880 --> 00:39:19,900 isn't trying to sell you his house, 737 00:39:20,020 --> 00:39:22,600 is editing that data on the way through to you, 738 00:39:22,640 --> 00:39:25,320 and saying, yeah, my area is in the lowest crime area. 739 00:39:25,960 --> 00:39:28,680 Buy my house from me for an inflated price. 740 00:39:29,040 --> 00:39:30,800 And it really comes back to, again, 741 00:39:30,880 --> 00:39:32,940 you might trust the individual sources 742 00:39:32,940 --> 00:39:34,800 of data, but you're not getting it from those. 743 00:39:35,100 --> 00:39:37,280 You're getting your output from that middleman. 744 00:39:38,220 --> 00:39:41,640 From a widget point of view, I've used iGoogle here, 745 00:39:41,760 --> 00:39:43,700 but you can see it's essentially a way 746 00:39:43,700 --> 00:39:47,920 of pulling different little applications, or bits of code, 747 00:39:48,060 --> 00:39:50,000 or however you want to call it, to give you 748 00:39:50,000 --> 00:39:51,420 that customized kind of page. 749 00:39:51,560 --> 00:39:56,080 So giving you access to your emails, stock prices, news, 750 00:39:56,700 --> 00:39:58,500 calendaring, and so on, on a single page. 751 00:40:00,260 --> 00:40:02,560 So again, it's really just multiple applications. 752 00:40:02,940 --> 00:40:03,860 Like I said, different components. 753 00:40:04,140 --> 00:40:07,180 The problem can come, though, is if you have a shared DOM model 754 00:40:07,640 --> 00:40:08,880 between all of those widgets. 755 00:40:09,140 --> 00:40:11,960 So if I have my Security Ninja widget up here, 756 00:40:12,060 --> 00:40:16,080 and you've got your stock price and your email widget down here, 757 00:40:16,160 --> 00:40:18,900 and we're in the same DOM, then my widget 758 00:40:18,900 --> 00:40:20,900 can potentially read your emails, 759 00:40:21,000 --> 00:40:23,380 or make stock trades on your behalf. 760 00:40:23,720 --> 00:40:26,320 Because whilst they're all within that same DOM, 761 00:40:26,480 --> 00:40:30,240 I can also access any of the document dot whatever elements 762 00:40:30,240 --> 00:40:31,720 from my Security Ninja widget. 763 00:40:31,900 --> 00:40:32,920 So if you're cooking. 764 00:40:32,940 --> 00:40:35,640 If you're using a key, or even doing things like key login, 765 00:40:36,320 --> 00:40:39,360 stealing data, as I said, from your Gmail widget. 766 00:40:40,020 --> 00:40:42,540 And I think more importantly, more important 767 00:40:42,540 --> 00:40:46,100 than that previous point, is that these widgets are 768 00:40:46,100 --> 00:40:48,120 developed, or can be developed and uploaded 769 00:40:48,120 --> 00:40:49,220 by literally anyone. 770 00:40:49,820 --> 00:40:52,580 And anyone could include malicious users. 771 00:40:52,940 --> 00:40:54,960 Now there's not a sign on iGoogle saying, 772 00:40:55,060 --> 00:40:57,020 yeah, this is a malicious widget, don't install it. 773 00:40:57,580 --> 00:40:59,180 That's down to you as an end user. 774 00:40:59,580 --> 00:41:02,140 And I've got an example of a Facebook, 775 00:41:02,140 --> 00:41:04,220 an application I want to look at in a minute. 776 00:41:04,360 --> 00:41:07,240 But what Facebook's saying, their terms and conditions, 777 00:41:07,360 --> 00:41:09,760 is basically, we're not going to review any of that. 778 00:41:09,820 --> 00:41:12,240 If there are security problems with any of these applications, 779 00:41:12,780 --> 00:41:15,380 it's down to the users themselves to report that to us. 780 00:41:16,660 --> 00:41:19,520 So again, you install these very much at your own risk. 781 00:41:20,200 --> 00:41:22,580 So in, in Facebook, there was an application called 782 00:41:22,580 --> 00:41:23,900 the Secret Crush application. 783 00:41:24,560 --> 00:41:26,600 And basically, you've got a message pop up saying, 784 00:41:26,640 --> 00:41:28,020 someone's got a secret crush on you. 785 00:41:28,120 --> 00:41:29,880 Do you want to go and find out who it is? 786 00:41:29,980 --> 00:41:32,120 If you want to go and find out who it is, click it, 787 00:41:32,120 --> 00:41:32,220 click here. 788 00:41:33,160 --> 00:41:36,300 Oh, surprisingly, you have to install this application as well to find that out. 789 00:41:36,440 --> 00:41:39,100 You install it, and then an iframe pops up afterwards. 790 00:41:39,560 --> 00:41:43,200 Now what, this iframe wasn't pushing malicious data directly itself. 791 00:41:43,560 --> 00:41:46,380 Basically what it was saying, well now you've got your Facebook application, 792 00:41:46,580 --> 00:41:48,960 do you want to install this other thing from us as well on your desktop? 793 00:41:49,860 --> 00:41:53,700 And the iframe was being served up by a company called Zango, 794 00:41:53,940 --> 00:41:55,920 who are quite a well-known spyware company. 795 00:41:56,100 --> 00:41:58,940 So if you install that on your desktop, you've got spyware down there. 796 00:41:59,080 --> 00:42:01,520 So really, like I said, it prompts you to install spyware. 797 00:42:02,120 --> 00:42:05,060 They managed to get that on 4% of all the Facebook profiles, 798 00:42:05,140 --> 00:42:07,220 so 4% of 250 million users. 799 00:42:08,260 --> 00:42:11,340 And probably at the end of the day, none of those users really loved you. 800 00:42:11,460 --> 00:42:12,860 Only Zango probably did. 801 00:42:12,980 --> 00:42:15,080 That's not really a good place to be. 802 00:42:16,280 --> 00:42:18,160 I'm going to have to fly through these last few now, 803 00:42:18,260 --> 00:42:20,180 but next up, information leakage. 804 00:42:20,340 --> 00:42:23,720 Really what we're talking about here is if your application crashes 805 00:42:23,720 --> 00:42:25,580 or someone does a SQL injection attack, 806 00:42:25,780 --> 00:42:28,420 you don't spit out internal information back to the user. 807 00:42:28,620 --> 00:42:31,140 So a simple example here, we've got a URL, 808 00:42:32,120 --> 00:42:33,880 and user columns equals two on the end, 809 00:42:33,980 --> 00:42:35,700 trying to do a bit of SQL injection attack. 810 00:42:35,960 --> 00:42:37,460 We don't handle the error properly. 811 00:42:37,620 --> 00:42:41,280 It spits out this internal SQL error message back to me. 812 00:42:41,720 --> 00:42:43,500 So yeah, real simple example there. 813 00:42:44,760 --> 00:42:46,820 What can make this worse in Web 2.0? 814 00:42:46,940 --> 00:42:49,800 Well, we have the idea of publishing things like WSDL files. 815 00:42:50,160 --> 00:42:52,440 And what a WSDL file is, is it essentially defines 816 00:42:52,440 --> 00:42:54,600 how and where you can access web services. 817 00:42:55,520 --> 00:42:57,560 There's a lot of information in there that makes it easy 818 00:42:57,560 --> 00:42:59,280 to people to come and use your web service. 819 00:42:59,520 --> 00:43:01,560 It also makes life easier when I want to come 820 00:43:01,560 --> 00:43:03,000 and hack your web service as well. 821 00:43:03,960 --> 00:43:06,820 We're also doing a lot of business logic, validation, 822 00:43:07,080 --> 00:43:09,280 storage of data down on the client side as well. 823 00:43:09,460 --> 00:43:11,780 And again, we're going to look at two quick examples here. 824 00:43:12,700 --> 00:43:15,360 So my Google hacking skills, not really fantastic. 825 00:43:15,600 --> 00:43:18,100 I don't think I'm going to replace Johnny I hack stuff yet. 826 00:43:18,240 --> 00:43:20,480 But we're doing a file type WSDL search. 827 00:43:20,640 --> 00:43:22,560 You can just go and look at these WSDL files, 828 00:43:22,660 --> 00:43:24,300 and you can see people straight away here saying, 829 00:43:24,340 --> 00:43:26,040 yeah, here's the technology I use in the back end 830 00:43:26,040 --> 00:43:27,060 to create these files. 831 00:43:28,080 --> 00:43:30,040 Not going to bring the house down by themselves, 832 00:43:30,160 --> 00:43:31,440 but if I'm trying to finger 833 00:43:31,440 --> 00:43:33,480 print your infrastructure and find out what you're doing, 834 00:43:33,640 --> 00:43:34,940 it's a little bit of a help there. 835 00:43:35,140 --> 00:43:37,960 And this one here also made me laugh a bit as well. 836 00:43:38,780 --> 00:43:40,440 Now I don't have to try and figure out 837 00:43:40,440 --> 00:43:42,280 how you're validating my data, because you're 838 00:43:42,280 --> 00:43:43,000 telling me up front. 839 00:43:43,260 --> 00:43:44,980 So you're telling me I'm going to take your email address. 840 00:43:45,120 --> 00:43:48,540 This is the amount of character space you've got to play with, 841 00:43:48,620 --> 00:43:51,640 and here's the pattern I'm going to match that against as well. 842 00:43:51,740 --> 00:43:53,780 So I don't have to bang my head around the keyboard. 843 00:43:54,280 --> 00:43:56,120 I can just go and grab your WSDL file 844 00:43:56,120 --> 00:43:57,100 and find that out for myself. 845 00:43:58,800 --> 00:43:59,880 Another quick one here. 846 00:44:00,220 --> 00:44:01,420 If we're doing validation, we're 847 00:44:01,440 --> 00:44:02,420 going to do validation of data on the client side, 848 00:44:02,460 --> 00:44:04,620 always back it up server side, and never 849 00:44:04,620 --> 00:44:07,520 assume if you're storing sensitive data on the client 850 00:44:07,520 --> 00:44:08,920 side that it's going to be safe. 851 00:44:09,200 --> 00:44:12,460 So the Macworld conference found that out the hard way in 2007. 852 00:44:13,080 --> 00:44:15,600 Basically, in the client side JavaScript, 853 00:44:15,800 --> 00:44:17,500 they had an array of hashes. 854 00:44:17,760 --> 00:44:19,540 And what was happening here is when 855 00:44:19,540 --> 00:44:22,120 you went to buy a pass for the conference, 856 00:44:22,360 --> 00:44:24,120 there was a special codes field. 857 00:44:24,340 --> 00:44:26,320 When you put anything in that special codes field, 858 00:44:26,440 --> 00:44:27,860 it checked it against these values. 859 00:44:28,140 --> 00:44:30,340 So the researcher looked at it and thought, well, OK, 860 00:44:30,340 --> 00:44:32,320 let me see if I can brute force one of those values. 861 00:44:32,540 --> 00:44:34,780 And he brute forced one of them in like 10 seconds 862 00:44:34,780 --> 00:44:37,340 and got a $2,000 platinum pass to the conference. 863 00:44:38,720 --> 00:44:40,540 When there's money involved, that kind of money, 864 00:44:40,660 --> 00:44:42,120 don't do silly things like that. 865 00:44:42,300 --> 00:44:44,320 I think they got caught out the following year, again, 866 00:44:44,320 --> 00:44:46,580 by the same research with something very similar as well. 867 00:44:47,600 --> 00:44:49,300 So yeah, it's not a good idea. 868 00:44:50,060 --> 00:44:53,340 Authentication and authorization flaws, really making sure 869 00:44:53,340 --> 00:44:55,480 that whoever's using our application is who they say 870 00:44:55,480 --> 00:44:57,700 they are and not accessing things they shouldn't do. 871 00:44:58,420 --> 00:45:00,320 So with authentication, that's a good thing. 872 00:45:00,320 --> 00:45:02,480 And authorization, we're looking at things like making 873 00:45:02,480 --> 00:45:05,260 sure that passwords have maximum age, reasonable lengths. 874 00:45:05,960 --> 00:45:07,820 If we use things like capture systems, 875 00:45:08,100 --> 00:45:09,780 make sure it's not just there to look pretty, 876 00:45:09,860 --> 00:45:11,560 that it's actually a useful capture system. 877 00:45:12,080 --> 00:45:14,980 I was using a website back home before I came out 878 00:45:14,980 --> 00:45:17,740 the other day, and they had four numbers in the capture. 879 00:45:17,900 --> 00:45:20,920 And they had two little red lines, one above the numbers 880 00:45:20,920 --> 00:45:22,000 and one underneath the number. 881 00:45:22,140 --> 00:45:24,140 It's not really obscuring the capture at all. 882 00:45:24,200 --> 00:45:25,540 So if you're going to use it, make 883 00:45:25,540 --> 00:45:26,660 sure you use a decent one. 884 00:45:26,860 --> 00:45:29,620 It's not easy to get right at Microsoft, Google, Yahoo. 885 00:45:30,320 --> 00:45:31,540 There's a bunch of those capture systems out there that 886 00:45:31,540 --> 00:45:32,120 have been broken. 887 00:45:32,680 --> 00:45:34,380 So if you're going to put that out there, make sure it 888 00:45:34,380 --> 00:45:35,500 actually does something for you. 889 00:45:36,240 --> 00:45:38,460 From a session management point of view, make sure your 890 00:45:38,460 --> 00:45:41,680 IDs have sufficient entropy, so every character is random 891 00:45:41,680 --> 00:45:44,400 enough, don't have predictable session IDs, don't 892 00:45:44,400 --> 00:45:46,040 reuse session IDs, and so on. 893 00:45:47,000 --> 00:45:50,000 A flaw I found in Facebook earlier this year, which 894 00:45:50,000 --> 00:45:54,020 allowed me to bypass the prevention, the security 895 00:45:54,020 --> 00:45:58,220 mechanism, so they had on accessing people's picture 896 00:45:59,500 --> 00:45:59,940 albums. 897 00:46:00,540 --> 00:46:04,160 So what they found out is they had a very predictable URL to 898 00:46:04,160 --> 00:46:05,600 access photo albums. 899 00:46:05,740 --> 00:46:07,320 So the URL just had three parameters. 900 00:46:07,680 --> 00:46:12,400 It had an album ID, a user ID, and an L equals value. 901 00:46:12,580 --> 00:46:16,140 And the L equals value is the only unique value in some 902 00:46:16,140 --> 00:46:16,620 instances. 903 00:46:16,900 --> 00:46:20,920 So everyone's profile picture's album always had an album ID of 904 00:46:20,920 --> 00:46:21,440 minus three. 905 00:46:21,540 --> 00:46:22,940 So I don't have to guess that. 906 00:46:23,240 --> 00:46:26,400 The user ID value, I don't have to be your friend or anything to 907 00:46:26,400 --> 00:46:26,760 get that. 908 00:46:26,880 --> 00:46:30,140 And just do a search for you in Facebook, hover my mouse 909 00:46:30,140 --> 00:46:34,080 over the add friend link, and I can just see your user ID. 910 00:46:34,200 --> 00:46:35,000 So I'll pop that in there. 911 00:46:35,080 --> 00:46:37,000 So again, I don't have to try and brute force that. 912 00:46:37,200 --> 00:46:39,380 So I just needed to brute force the L equals value. 913 00:46:39,660 --> 00:46:42,480 They used five characters, A to F, zero to nine. 914 00:46:42,860 --> 00:46:45,660 It didn't take the Burp Suite very long to brute force those 915 00:46:45,660 --> 00:46:46,140 for me. 916 00:46:48,120 --> 00:46:50,640 If you go to my blog, you'll see that they did fix it, but 917 00:46:50,640 --> 00:46:51,520 they fixed it very badly. 918 00:46:51,640 --> 00:46:54,140 So the example I'm going to show you in the Burp Suite now 919 00:46:54,140 --> 00:46:54,920 would still apply. 920 00:46:55,060 --> 00:46:56,320 It would just take a little bit longer. 921 00:46:56,580 --> 00:46:59,540 So really what I did is I loaded the URL up into Burp Suite. 922 00:47:00,140 --> 00:47:01,620 Sorry, the pictures are a little bit fuzzy. 923 00:47:01,800 --> 00:47:04,220 But like I said, if you go to my blog, there's a full write 924 00:47:04,220 --> 00:47:05,700 upon on the Facebook issue there. 925 00:47:06,940 --> 00:47:09,600 The two red values is basically I'm saying brute force those 926 00:47:09,600 --> 00:47:09,880 two. 927 00:47:10,060 --> 00:47:10,740 It went away. 928 00:47:10,760 --> 00:47:11,480 Brute force them. 929 00:47:11,680 --> 00:47:13,720 Found a genuine URL for me. 930 00:47:14,300 --> 00:47:16,720 I threw that into the browser, and I could access Bobby 931 00:47:16,720 --> 00:47:17,460 Table's photos. 932 00:47:17,780 --> 00:47:18,500 I'm not logged in. 933 00:47:18,560 --> 00:47:20,540 I'm not his friend, anything like that. 934 00:47:20,780 --> 00:47:24,280 So again, it worked for different albums and so on as 935 00:47:24,280 --> 00:47:26,620 well, but you had to brute force the album ID value and 936 00:47:26,620 --> 00:47:27,220 so on. 937 00:47:27,420 --> 00:47:30,000 But as I said, if you go to my blog, search for Facebook, 938 00:47:30,000 --> 00:47:30,960 it'll be all up there. 939 00:47:31,400 --> 00:47:33,180 What makes it worse in Web 2.0? 940 00:47:33,360 --> 00:47:38,060 If we use capture systems that don't provide actually any 941 00:47:38,720 --> 00:47:41,840 increase in security, then they might as well not be there. 942 00:47:42,400 --> 00:47:45,280 More access points in Web 2.0 makes it more difficult to 943 00:47:45,700 --> 00:47:47,020 identify weaknesses. 944 00:47:47,620 --> 00:47:50,200 Using things like single sign-on, your Google account, 945 00:47:50,480 --> 00:47:52,480 one username and password for loads of sites. 946 00:47:52,720 --> 00:47:54,720 Its selling point is also its biggest security 947 00:47:54,720 --> 00:47:55,680 issue in my eyes. 948 00:47:56,180 --> 00:47:59,180 And then the growth in some of those other attacks, so 949 00:47:59,180 --> 00:48:00,480 cross-site scripting, for example. 950 00:48:00,640 --> 00:48:03,820 You might have the most random, longest, strongest session ID 951 00:48:03,820 --> 00:48:04,340 in the world. 952 00:48:04,520 --> 00:48:07,100 If you've got a cross-site scripting vulnerability, they 953 00:48:07,100 --> 00:48:09,200 can just grab that anyway, and it doesn't really matter. 954 00:48:10,840 --> 00:48:14,140 Running out of time here, guys, but insecure storage and 955 00:48:14,140 --> 00:48:18,300 communications of data, really not encrypting data when you're 956 00:48:18,300 --> 00:48:20,720 storing it or transmitting it, using weak protection 957 00:48:20,720 --> 00:48:22,520 mechanisms and so on. 958 00:48:22,580 --> 00:48:24,380 Those types of things are what I'm talking about here. 959 00:48:24,700 --> 00:48:26,520 What makes this worse in Web 2.0? 960 00:48:26,640 --> 00:48:28,160 More data in more places. 961 00:48:28,540 --> 00:48:29,160 It's including a lot of data. 962 00:48:29,160 --> 00:48:29,800 It's including the client side. 963 00:48:30,020 --> 00:48:32,180 We saw that with the Macworld vulnerability before. 964 00:48:32,420 --> 00:48:37,920 If you can't be confident about securing it, don't put it in that location is pretty much 965 00:48:37,920 --> 00:48:38,340 the answer. 966 00:48:38,740 --> 00:48:43,880 And when you mix secure and insecure content on a single page, the insecure content can 967 00:48:43,880 --> 00:48:46,860 undermine the secure content's security. 968 00:48:47,420 --> 00:48:51,220 There's a talk by Sam Bowne and I think Robert Hanson as well at 3 o'clock today. 969 00:48:51,460 --> 00:48:54,240 I think that's what they're talking about, so go along and look at that. 970 00:48:55,000 --> 00:48:58,120 What makes my job harder with Web 2.0? 971 00:48:58,180 --> 00:48:59,000 More code. 972 00:48:59,000 --> 00:49:01,720 And the applications are largely more complex. 973 00:49:01,960 --> 00:49:04,820 It has to be generally more than one language as well. 974 00:49:04,840 --> 00:49:07,240 So people are using the best language for the job. 975 00:49:07,340 --> 00:49:11,080 So JavaScript down on the client side, PHP or whatever on the server side. 976 00:49:12,440 --> 00:49:15,840 Just little differences between languages, even right down to if you look at your regular 977 00:49:15,840 --> 00:49:17,920 expressions you use for input and output validation. 978 00:49:18,360 --> 00:49:22,260 Different languages have slightly different formats or syntaxes for their regular expressions. 979 00:49:22,620 --> 00:49:25,780 So it's more of just getting all those little bits right between different languages. 980 00:49:26,040 --> 00:49:28,800 The dynamic nature of the pages themselves. 981 00:49:28,800 --> 00:49:35,220 In Web 2.0, a single page could have many different representations of that page because 982 00:49:35,220 --> 00:49:38,800 we create them dynamically with things like manipulation of the DOM. 983 00:49:39,400 --> 00:49:44,120 It's difficult to make sure that you've tested every type of page A, for example. 984 00:49:44,520 --> 00:49:48,320 And then the increased amount of input points makes it more difficult to make sure you're 985 00:49:48,320 --> 00:49:50,580 validating every input that comes in. 986 00:49:50,900 --> 00:49:52,400 How can you prevent these vulnerabilities? 987 00:49:53,020 --> 00:49:58,620 One of the approaches that I take, and if you want more in-depth information on these 988 00:49:58,620 --> 00:50:02,580 principles, if you go to my blog, I spoke about them at Security B-Sides on Thursday, 989 00:50:02,700 --> 00:50:04,380 so there's a whole PowerPoint up there for that. 990 00:50:04,780 --> 00:50:09,160 But really, the idea that I try and push is not to try and prevent specific vulnerabilities, 991 00:50:09,340 --> 00:50:13,400 but just develop securely and prevention of loads of vulnerabilities that will come 992 00:50:13,400 --> 00:50:13,860 out of that. 993 00:50:14,060 --> 00:50:19,240 So what I mean by that is the secure development principles, input and output validation, make 994 00:50:19,240 --> 00:50:23,740 sure you've got error handling, strong authentication and authorization, session management, secure 995 00:50:23,740 --> 00:50:27,580 communications, secure storage, and secure resource access. 996 00:50:27,840 --> 00:50:28,600 As I said, if you've got a lot of data, you've got a lot of information. 997 00:50:28,620 --> 00:50:31,640 If you go and grab that other presentation, there's a lot more information on these. 998 00:50:31,920 --> 00:50:37,500 And then just visually here, to finish off, secure development doesn't happen by accident. 999 00:50:37,760 --> 00:50:41,360 You need to plan it right at the start, have it in your requirements and design documents, 1000 00:50:41,520 --> 00:50:44,720 do things like threat modeling, educate your developers. 1001 00:50:44,780 --> 00:50:47,040 Don't just assume that you're going to be able to develop securely. 1002 00:50:47,700 --> 00:50:51,480 Educate them so they can build security into the code, make it part of the application's 1003 00:50:51,480 --> 00:50:51,760 DNA. 1004 00:50:52,200 --> 00:50:56,000 Think of it as you make it part of its DNA instead of trying to put a code around it 1005 00:50:56,000 --> 00:50:58,260 at the end, because it will fail if you try and do that. 1006 00:50:58,800 --> 00:51:02,420 So get someone independent from yourself to review the code, and then finally try and 1007 00:51:02,420 --> 00:51:04,280 hack it yourselves before it goes live. 1008 00:51:05,040 --> 00:51:06,260 So thank you very much.