Thank you very much everyone. It's nice to see everyone so excited straight away before I even said a word. But yeah, today I'm going to be talking about the security risks of Web 2.0. 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. 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. 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. 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. 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. 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. So my name is David Rook. I'm a security analyst for a company called Realex Payments in Ireland. 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. I have a couple of different websites. Security Ninja is my blog. I do a lot of work with OS, contributing, helping setting up conferences, speaking at conferences and so on for them. I'm the security advisor for the Irish Internet Association. We have a web development working group where we try and help small development companies in Ireland understand how to deliver development projects, and I help them understand security issues. I've also found a few security issues in Facebook, and we'll look at one of those later on as well. So kind of, like I said, I just wanted to say up front what this presentation is, and what it is. So it's not going to be a technical discussion about Web 2.0 technologies and architectures. It will be a discussion about vulnerabilities in Web 2.0 applications. There's no zero days, no new attacks, or so on here. But it's also not just a discussion about cross-site scripting and SQL injection. We're going to look at, like I said before, 10 different vulnerabilities today, and how you can prevent them in your own code. So kind of on the screen there is Tim O'Reilly's quite famous quote, I think, by now. But what Web 2.0 is. But instead of trying to run through that, I've just got this image here, which probably allows you to understand the types of websites we're talking about. So Facebook, Wikipedia, YouTube, those types of websites are the kind of sites we're talking about today. 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 to the sites essentially just becoming a framework. A framework that users come along and fill in. So things like social networking sites and YouTube. There's a desire to have a desktop look and feel to those web applications. There's also a feeling that kind of everything can go online now. So with things like Google Documents, you can do all your word processing, spreadsheets, et cetera, online. There's also things like iOS, which is a full operating system that you can use within your browser. There's the feeling to have kind of a syndication of content as well. So. So a user doesn't want to come back to your page ten times a day to see if you've made any updates. 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. And another key point, which I think will become a bigger problem in the next probably year or so, is the offline storage of data and state. So probably Google Gears would be the leader in this at the moment, where it will essentially create, update, and delete databases on your local. File system. So there's kind of no concept of on or offline working with that. And if HTML5 ever gets approved, then that will also be bringing that kind of functionality along as well, creating these databases, allowing the sites to create databases on your file system. It's not particularly something I feel comfortable with, but if you want to know more about the issues around that, come and grab me afterwards. I've got a presentation I did last year that I can show you on that. Kind of for time reasons, I'm not going to step through everything on here, apart from kind of just to point out the last two points at the bottom. Web 1.0 we had poor security, and in Web 2.0 we're kind of repeating the same issues. Really, you know, some of the key points off that, you know, from a user point of view, their web experience has changed from coming along and reading content to coming along and providing content. There are different technologies there, different security issues. So the vulnerabilities we're going to look at... at today, probably by name a lot of these will be familiar to people. The cross-site scripting, cross-site request forgery, SQL injection, authentication and authorization flaws. And I guess if I was sitting in the crowd now, I'd probably be thinking that they are the same as Web 1.0. Well, in name at least they're the same. But we're going to look at how they're exploited differently in Web 2.0 today. And we're going to look at three vulnerabilities which I think are kind of Web 2.0 specific. So cross-site scripting worms, feed injections, sorry, just on the cross-site scripting worms, I'm not going to step through Sammy like probably everyone else has the last four years. I've got a different cross-site scripting worm for us to look at today. And then some of the problems that can occur with mashup and widgets websites. So first up is cross-site scripting. I think by now everyone knows that it's not a new vulnerability, but it certainly has the potential to be worse in Web 2.0. And these flaws occur whenever an application takes externally supplied input and uses that as an output into the browser. And there are kind of three main types of cross-site scripting. So I've reflected cross-site scripting attack and what I've done on these three points is I've got just a line about the vulnerability and an example of a bit of attack code there. So reflected cross-site scripting attack occurs whenever the user supplied data is reflected back to the user in the browser immediately. So it's all on the client side. It's dynamically created on the client side. So if you're only relying on server-side protections, then it won't help you here. The second type is, is a stored cross-site scripting attack, which I guess kind of by name it implies what it is. So you store your malicious code on the server-side, so in a database. And then when someone comes and views maybe your blog, every time someone comes and views that, it'll execute the code. And we'll look at the cross-site scripting worms later, which are essentially stored cross-site scripting attacks. And then finally we have DOM-based cross-site scripting attack. And again, this is occurring on the client side. And the example we've got there is if we've got a URL for example site dot com, and we've got a name equals value. Now, if, if, if the name has, I know, David in there, then the bit of code underneath that URL there is gonna pull that out and write it into the page. So the website might say, hello, David. But if we don't validate that name, value, then if we don't validate that value before we pull it into the page and inject it into the page's DOM, then we can open up to DOM-based cross-site scripting attacks. So how can this get worse in Web 2.0? Well, we just mentioned DOM-based cross-site scripting attacks. And the DOM manipulation to give kind of a dynamic interactive feel to Web 2.0 applications is kind of becoming more and more vital all the time. So if we think, when we make these updates to the DOM, if we're pulling in data, from external sources and injecting it straight into the DOM, then we could be opening ourselves up to, to security issues there. And we're gonna look at an example in a second of that. We have user-controlled data in more places. You know, the, the Web experience for a user anymore isn't just coming along and putting data into a search field or form fields. The websites as a whole, things like Facebook, for example, is pretty much built from user-supplied data. So from a, a security point of view, validating all that data and making sure you don't get caught out with security issues is, is, is more difficult. We also have now self-propagating cross-site scripting attack codes. So the cross-site scripting worms that I was talking about, we've got a section later on, on that. But really, they're stored cross-site scripting attacks. And we'll look at, again, an example later on. And really kind of tying back to that first point now, where we bring in data from data streams like JSON or XML. I think, you know, there's, there's a, you have to assume that they could be malicious, but I would say a lot of people probably don't. So if you pull in that data and inject it straight into the DOM, then, you know, your users can be exploited. So, you know, just to make some of those points a little bit clearer, because we have a, a very dynamic DOM in a lot of these applications, we'll use things like document.write or an eval statement to pull in data and inject it into the DOM. But the data you pull in to your eval or your document.write, you're not right. If you don't validate that before you use it, then you could be injecting the tag code into the user's DOM. So in the example we've got here, kind of the top half of the screen, we're making an XML HTTP request. So we're just making a request for data. And near the bottom is just the bit of code that's actually getting that data for us. So it's going through a proxy, so we're going to an off-domain location to grab that information. And essentially, there are, that's bits of code missing out of there for me to try and fit it on the screen. But essentially, you can see near the bottom we have an eval statement, and that's where we're passing that externally grabbed data into. So that'll execute that for us. So if you don't validate that before you use it, like we armed here, then you open yourselves up to an attack. So the next vulnerability is, is cross-site request forgery. And I didn't get a chance to come into the talk previously, but I guess anyone who was in the cross-site request forgery track already knows how bad this is and how bad it can get. So really, what I'm talking about here is, again, it's, it's not new, but it has the potential to be worse. And really, what you're doing with the cross-site request forgery attack is, is instead of executing malicious code on the client side, like we have in cross-site scripting, you're making a request, forcing a request to be made on behalf of that user without them knowing about it. So kind of just to reiterate that, it's important to remember that cross-site scripting's not cross-site request forgery. They are two separate attacks. So I've got a real simple example there, just in case anyone didn't make the last talk or, or not quite sure what cross-site request forgery is. We have a, a website here called NinjaRental.com. So you come along, you put your username and password and you hit submit, the request is sent to the server, the server authenticates you and sends the session ID back. So when you then, when that user's using the Ninja Rental site and he wants to rent a Ninja, he wants wants to just rent the regular Ninja for £100. He doesn't want to hire Chuck Norris. I probably wouldn't either. He's probably a little bit volatile for my liking. But the guy chooses the regular Ninja for £100, hits submit, sends that request to the server. The browser sees that, oh yeah, I've already got a session value for that, so he doesn't have to re-authenticate. The browser just sends that value along with the request. His account is debited in the back end, and then he gets a Ninja. What if, whilst he's still authenticated to that site, I get him to come along to my dodgy site dot com, and whilst we might be laughing at Agent Smith there to start off with, I think ultimately he's going to have the last laugh here. Because whilst you might think we can't make this request from this other site, we can use some tags like an image source tag, or an iframe source, or a script source tag to bypass that. A protection mechanism called the same origin policy, which should have prevented this attack happening, but by design those three tags allow that attack to happen. So when the user comes on this site, the funny pictures of Agent Smith load up. But in the background, the browser sees that it's got to make this request to NinjaRental.com as well. And you can see basically what it's doing is it's making a request to hire that Chuck Norris Ninja. So he's now going to have a £1,000 debited from his account without him ever actually sending that request. And again, the browser being helpful just sees that request being made in the background, sees you've got a session value for it, and sends that along and the, the request is made. So some people look at those examples and say, well, that's probably a bit too simple to work in the real world. We're going to take a look at an example in a minute where an attack almost the same as that was being exploited against Gmail for about 18 months I think before it was fixed. So what can make this worse in Web 2.0? Well, we can do attacks using XML and JSON. I'm going to look at a JSON-based cross-site request forgery attack in a minute. They can be a little bit tricky to do, but they're certainly possible. And one of the, the biggest issues with Web 2.0 is that, that cross-domain access is, is essential. You know, when we look at things like mash-up sites, they are essentially a cross-site attack. They are essentially a cross-site script and attack in the way that they're built, and they have to allow that cross-domain access. I think, talking about the mash-ups, I think Douglas Crockford once said that they, that they are kind of built as a cross-site script and attack because everything is, is cross-domain requests. And then really, like I mentioned before, same-origin policy isn't going to protect you. Whether we, we're still relying on same-origin policy or not, you know, we're going to see less and less protection from that going forward. So things like, the access, XML, HTTP requests, and, and even JSON data should only be called from the same domain. But again, we're going to look at in a second how you can get around that as well. So firstly, a very simple real-world example of a cross-site request fordry attack against Gmail that essentially brute forced a password reset against your account. So again, it was using the image source and the iframe source tag. So again, we're starting to see similarities to the example earlier. So, what the, the researcher found was that he could make these requests directly to reset the password with Google. So it has to provide an old password, so your current password, and then the password he wants to reset your account to. Now, normally, when you do the password reset with Gmail, you have to enter a capture. But by making this request directly, he could bypass the capture system. So he could brute force those values and try and reset your password for you. As I said, I think it, it took around 18 months, I think, from, from this guy first reporting it to when, to when it actually got fixed. And then the next kind of JSON-based attack I'm going to look at is also against Google. I'm not trying to beat up on Google here. Just like later on, I'm not going to try and beat up on Facebook. But they've got the best examples of these attacks so far, in my opinion. So normally, as I said, the XML, HTTP request, should be, should be, should be, should be, should be, should be, should be, should be, should only be able to pull in data from the same domain location. And the same for JSON. We shouldn't be able to request data from, from an off-domain location. But, you know, that's, that's not very Web 2.0 friendly. We mentioned before that we have to allow that cross-domain access. So we have a thing called JSON callbacks. And what a JSON callback allows you to do is to wrap the JSON data within a JavaScript function. So you can make that cross-domain request. Or grab that data, the JSON data, from a separate domain. So what a researcher found out was that he could use this to his advantage and steal your Google contacts. Unfortunately, he only used it as a proof of concept. So he didn't really steal your contacts. But, obviously, other people could do. So really, at the top of the screen there, we have the JavaScript function called Google. And we're waiting for the JSON data to be, to be wrapped in there, essentially. And when he receives it, he's just going to do a document. Write out your contact information to the page there. So at the bottom, we can see that there's also a URL to Google Docs. So normally what this URL would allow you to do is, one, when you're using Google Documents, you should be able to view your contacts whilst you're doing it. But the researcher found out if he, if he put the callback parameter on the end of the URL, wrap that within a JavaScript function, whenever you come to his page, that code would execute. Grab your contacts. And then. In this case, he'd just write it to the page. But, you know, he could have sent that anywhere he wanted. So SQL injection, again, not a new vulnerability. It's been around for a long time. And what we're seeing now is probably a different way of exploiting SQL injection, or a different motive for the attack in particular. So again, it's not new, but it's potentially worse. And really, what does SQL injection take? Well, what the attack is, it allows an attacker to inject his own bit of SQL into your backend SQL query. So we have a, a really simple example here where we're just gonna do, we're gonna take in a username from the user, and we'll do a select star from users where the name equals the username that the guy's provided. So if he provides, you know, a 1 or 1 equals 1, you know, the example that probably everyone's familiar with, then that query will become, you know, give me all the usernames where it's 1 or 1 equals 1. So give me all the names where it's equal to true. And again, this is a real simple example, but we're gonna look at a real world exploit in a minute which wasn't too much more complicated than this. So again, that was a simple example, but SQL injection's been used to steal large amounts of data, generally cause chaos on the internet through different, different means. So card systems, they lost 40 million credit card numbers through a SQL injection attack. We've seen automated SQL injection attacks compromise tens of thousands of millions of machines by exploiting vulnerabilities on the desktop. We're gonna look at one of these attacks that was, it's only about a week and a half old in a minute as well. And when I, when I try and give people a measurement of how many of these vulnerabilities we're seeing every year, I tend to use the amount of CVE numbers issued. And every different vendor will give you a different statistic on how many SQL injection attacks occur every year and so on. But for me. I find the CVE numbers quite useful. What's also useful is there is a great interface. So if you just do a Google search for CVE statistics, there's a great way to search for these yourself. But really the point is that of the CVE numbers issued in 2008 and 2009, 20% of all those vulnerabilities were SQL injection attacks. And kind of following on from that a bit, in 2008 and 2009 so far, cross-site scripting and SQL injection have accounted for roughly 33% of those vulnerabilities. Back in 2006, they accounted for less than 1% of all of the CVE numbers issued. So you can see that there's a definite switch in focus from the attackers. And from my point of view, SQL injection is the inspiration for my favorite XKCD comic. So I don't know if everyone might have seen this before, but really what's going on here is the mom receives a phone call from the school. They're having some computer trouble. So the mom says, oh, dear, did my son break something? They say, well, in a way. And they say, did you really name your son Robert, you know, drop table students? So she said, yeah, that's little Bobby Tables. And if you go to Facebook, the Bobby Tables account is also mine as well. I don't know whether that says a lot about me or not, but really the mom says, well, you know, that's your fault. Make sure you sanitize your database input. And whilst it's only a simple comic, it actually makes a very good point. Before you use any externally supplied data or any data in your SQL queries, make sure you validate it first. So in terms of Web 2.0, SQL injection, I think, for the time being, will still continue to be used for data theft, bypassing authentication systems, you know, dropping tables and someone like Bobby Tables' mom has just done. But what we're also seeing is if you think of things like Flash. And then kind of JavaScript as technologies that users have to have enabled nowadays to go and use these kind of Web 2.0 sites, well, the attackers know that just as much as we know that. So what they're starting to do is exploit the fact that people will need Flash or will have Flash and JavaScript enabled when they come to these sites. I mean, it's okay as security guys telling people you should use NoScript. But most of the sites the average user use nowadays will be completely broken if they go there with NoScript. NoScript turned on. So we're seeing SQL injection vulnerabilities not being used to steal data, not directly, but to inject malicious Flash files into sites that then when a user comes to the site, views the Flash video, it exploits the floor in the Adobe Flash player. We're also seeing people injecting malware serving JavaScript as well. And we'll look at an example in a minute from about a week and a half ago of an automated attack. Trying to inject this malware serving JavaScript. And it doesn't kind of matter how you're transmitting your data around. As long as you take externally supplied data and put it into your SQL query in the backend, it doesn't really matter whether you're doing that through JSON, XML, SOAP, whatever you want to use. So firstly, a simple example, a recent example of an authentication bypass SQL injection attack. So what this guy found was that in this server called Alumni Server, it would take in two values from the user. Take an email address and a password value, and then use them directly in a SQL query without doing any validation. So what he did is he put his email address in there, single quote parenthesis, or one equals one. So so far he's saying pick an email address where it's equal to true. And then the slash star in MySQL actually says, essentially, I'm going to do this. Essentially ignore the rest of that. So he doesn't have to provide a password value. So he's just put, essentially, any email address or one equals one, ignore the rest of it, and he's bypassed the authentication system. So like I said, even though the kind of one equals one example, probably people get fed up of seeing that, sometimes it is that easy in the real world. So the very simple attack there. Now this one, I'm not going to try and step through all the white SQL stuff here at the moment. There's a lot of it there. Obviously this was from, I think it was about a week and a half, two weeks ago. And the bit in orange on the screen there is really the important thing to look at here. And what this attack was doing, it was automatically trying to find SQL injection vulnerabilities in websites, inject the script tags. When anyone came along, viewed the site, it would basically make a request to execute this JavaScript file. And then try and exploit the Office web component's vulnerability, which I think even now might still be on patch. And at the time of me writing this presentation, the file contained two URLs. And the code it tried to push down was only being picked up by 15 of the 41 virus scanners on VirusTotal. And that was on the 16th of July. So you can see that attackers know that people have to have the ability to execute JavaScript when they come to pages. So they try and exploit that. So next up is Cross-Site Script in Worms. We know that Cross-Site Script in itself isn't new to Web 2.0. And I guess there's an argument whether Cross-Site Script in Worms is or isn't. Because essentially, when Sammy exploited MySpace, it wasn't a Web 2.0 site. But he used Web 2.0 technologies like XML HTTP requests for the exploit. Now, like I said, I'm not going to step through the Sammy code today. But I would say I'm definitely going to have a read of it, because he did some quite clever things when he exploited. He exploited MySpace there. I do feel a little bit obliged to mention Sammy, because I think that it was probably the first big example of Cross-Site Script in attacks, let alone Cross-Site Script in Worms, in my opinion. So he did this four years ago. And he managed to exploit over a million profiles, or in fact, a million profiles in about 24 hours. And even in 2009, Sammy is still a hero, firstly, because he's not really been eclipsed in terms of the amount of infections he's got. But if you do a Google search for, you know, a site, MySpace, and I think whatever line of text he injected, something like, and above all, Sammy is my hero, you'll still see reams and reams of profiles that still have that text. Not the JavaScript in there anymore, but that text in there. Most notably, actually, Hulk Hogan has got that. Now, I don't know whether I would go exploiting Hulk Hogan's MySpace page, but, you know, Sammy managed to do that. Okay. So I guess if I was sat in the crowd now, I'd be thinking, well, Sammy's old. Tell me about something new. So I managed to kind of find something a bit more recent. The Stork Daily, or I think it was also referred to as the Mikey Worm, that infected Twitter in April, Easter weekend. And really, the problem here was that on your Twitter profile, you can put your URL into the page. And they weren't validating that URL field correctly. So what this guy managed to figure out was he can put his Stork Daily in there. StorkDaily.com, URL in there, throw a script tag on the end. Whenever someone come and viewed that, the script would execute and so on and so on and affect their profile. So what we're going to do is step through some of the code, or the most important points in the code, at least, anyway, here. So firstly, what he did was to grab your authentication token. So at the top there, we've got a regular expression where he's just going to grab your authentication token, because he needs that to make two requests on your behalf, which he's going to do in a minute. In the middle there, as well, he had an array of tweets. So he wasn't going to use the same tweet for everyone. I don't know if that was to try and evade people picking up on us as an exploit or something like that. But basically, what he would do is he would pull one of the tweets out of that array, and then use that to update your page with one of the posts in a second. And then at the bottom there, he's got his StorkDaily.com URL with that script source on the end, which again, he's going to use to inject into your profile in a minute. All right. So like I said, he makes two requests. Firstly, he updates your status with one of those tweets out of his array. So he passes along the authentication token that he grabbed. He takes one of those tweets, updates your profile. And then secondly there, he makes a second post to change your account settings to include his attack code. So again, he's passing the authentication token. He injects that code into your page. Anyone comes along, this will all execute on their page, and so on and so on. I think he got something out of that. It's been like 17,000 infections with this StorkDaily worm. They fixed it, and he did another worm the day after. I think that was the Mikey worm. I think he exploited a different floor. Pretty much the same thing in Twitter two days in a row. So just two more extra points there as well. He needed to have your screen name to make a post on your behalf. So again, he's got another regular expression there where he pulls your screen name out of the meta content field so he can make those updates on your behalf. And then the next thing he does is he puts your screen name on the post. And lastly, at the bottom there, he takes your username and cookie and sends it off to another domain of his. Why not? If you can do, take everything you can get. That's not my professional opinion, of course. So how will this get worse, or how can this get worse? Well, some of the worms that we've seen so far rely on kind of some quirks in browser behavior. So first, if you could get a worm that's fully supported by all browsers, I don't know how easy or hard that is because a lot of websites aren't supported by all browsers, but if you can get your worm code to be fully supported across all browsers and build a worm that is kind of site or floor independent, I mean, you've seen the Stalk Daily code there, and if anyone's seen Sammy's code, you'll know that they were written very specifically for a specific floor and a specific site. If you could find a way of writing a kind of universal or generic cross-site scripting worm, then you could have whatever you want and call it an intelligent hybrid super worm. Now, PDP and Billy Hoffman have done some great research on this. I'd recommend, if you want to learn more about this specific issue, take a look at it. But really what they're proposing is if you can build this kind of generic worm code that can go to sites like XSS.com, and I think there's an area on Arsnake's forum as well that talks about new cross-site scripting attacks, but mainly XSS.com. If you go there, it not only tells you the site that was exploited, but I think, you know, exactly where the floor is and so on. If you could go to that site, pick the top 50 off, and go and automatically exploit all of those with a worm similar to Sammy or StorkDaily, then you could be talking to millions, millions of people infected, depending on who you're exploiting. And then, lastly, one of the things that I don't think we've seen on a wide scale yet is using cross-site scripting worm infections for distributed denial-of-service attacks. If you think Sammy essentially had... a million-plus browsers under his control at one point or another, now, what if he would have used every one of those to make a hundred or a thousand requests to your website? You're talking the kind of traffic that not many websites would be able to handle, you know, hundreds of millions of requests. So we've not really seen that yet, but it's something that is possible. If you've got a big enough amount of people infected, then people might use it in the same way as they would use a traditional kind of botnet. So the next thing I want to quickly look at is feed injection. So, like I said at the start, with Web 2.0, we don't want people to have to come back to our site every half an hour to see if we've made an update to our block. We want them to be able to pull that down automatically with things like RSS and Atom and using readers to pull that down. Now, the problem is, again, kind of like with any other of these problems, if you pull that data down and use it without validating it, then you open yourself up to attack. So we kind of have two kind of main differences between readers, ones that are either web browser-based or web-based or ones that are on the desktop. And there are kind of clear differences between the security issues between the two of them. Well, when you're in the browser, you're a little bit limited to the kind of damage you can do to the user. You know, things like cross-site scripting, cross-site request forgery, you know, they're possible through remote zone risks, as I call them. So the remote zone readers, whilst you're in the web browser, you can, you know, cross-site script the user and so on here. But you're kind of limited to that context. And we'll look at a local zone reader in a second of a real-world vulnerability there. But in the remote zone, if you just pulled in this RSS story and put it into the reader without doing any validation, then that code could execute. And in this example here, it's just stealing their cookie and sending it to my cookiemonster.cgi. Again, it just comes back to input validation, essentially. Validate that before you use it. And that's one of the things we'll look at later on is fixing security vulnerabilities doesn't have to be particularly complex, in my opinion. And we'll look at what I mean on that a little bit later on. So the local zone risks, this is where we have kind of a reader installed on the desktop. And what that can give an attacker is access to read and write content from the file system. You'll be able to use things like ActiveX components to do... a lot of different interesting things. And we'll again see a vulnerability in a second where someone was able to execute any Perl code he wanted on your computer just through injecting a malicious feed. Basically, with these local zone readers, what a lot of them do is they pull down the feed, write it to a HTML file locally, and when you want to view that feed, you click on it, it takes it out, puts it in the browser, away you go. And when you're using those readers, you're in the local context. So if a vulnerability exists, then you can read and potentially write from the file system. So an example here is if I injected that into a feed and you came along in your local reader and tried to view it, then what it's essentially doing is it's grabbing a file called secrets.txt using one of those ActiveX components to allow me to take that data out to my file monster.cgi. Now obviously when a user clicks on this, you'll get an ActiveX pop-up saying, do you want to allow this? Nine times out of ten, the user just thinks it's asking, do you want me to go to that website for you to get your news? They'll click yes, and you can steal secrets.txt. So a real-world vulnerability here in a local zone reader called Yasser. Basically, part of this application was a thing called GUI.pm. Now when this presentation goes up online, I've got all the code for GUI.pm in the notes if you want to step through it and see the vulnerability for yourselves. But basically what that did was it took in the URL, and when you wanted to view it, it put it into an exec statement and launched the browser without doing any validation on the URL. So what the researcher figured out was that fine, well I'll exploit that then. So he was passing in the link, putting a semicolon at the end, and doing a perl minus e, and well, whatever he wanted at the end there really. So again, there's nothing really complicated about that attack. But again, it just shows lack of validation, for example, allows him to do that. He can do, essentially, whatever he wanted to with that perl on the system. So how can these attacks get worse? Well, I think if you could find a vulnerability in a widely used site and a widely used reader, so I know something like the BBC news site and a popular reader. I'm not really up on what's popular in RSS readers, but Google Reader, for example. If you could find an exploit in both of those, you could inject malicious code into the BBC site, which then exploits the floor and all the Google Reader users. Then obviously you could have wide-scale exploitation of users. And whilst you're down on the client side in particular, you can do a lot of things like data theft, port scanning, and so on. If you can find the vulnerability, as you saw with the YASA vulnerability there, you're only, in that case, limited by your perl skills, really. So mashup and widgets, and kind of where I say widgets here, that means anything that could be regarded as a widget. You know, Facebook applications, things you put on NetVibe sites, Page Flakes, all of those types of things. I couldn't find a common term for it, so I just called it a widget for now. So really, kind of mashups, mashup sites and widget sites, I guess are kind of a good example of Web 2.0 sites. So a mashup site will pull in data from different sources to give you one single output. And a widget site, is essentially a blank canvas site for a user. They can come along, use something like iGoogle, and build the web page that they want to see first thing every morning. So we'll look at two examples in a second, but I found this site for a mashup that I thought was actually quite interesting. What this site does is it takes in news feeds, I don't know where they get them from, but Reuters in this case, and it's looking there and it's saying, that story is coming from London, so I'll take you to London on Google Maps. Simple example, but we see a lot of similar types of sites that are out there, where they take something and show it to you on a Google Map. The problem is, and like I said, Douglas Crockford said that a mashup is essentially a self-inflicted cross-site scripting attack, but we're pulling multiple inputs and giving it to you in one output as a user. Now, we're pulling that data from multiple sources, and again, if you don't validate that and just push it straight out there into one place for the user, then you can exploit the user. If you think of maybe a similar example to the one we just looked at, maybe a photo website where you take your photos and you put a location tag in there saying where you took the picture. Now, if someone comes along and he wants to map your photos to Google Maps, then you might have to provide your photo site logon details to him. Now, normally if you go to your photo site, it's probably SSLed and so on, and you're comfortable with the fact that your credentials are posted, and so on, and so forth. It's probably protected in transit. But how do you know that the mashup site, that essentially that man in the middle, how is he handling that data for you? Is he taking a copy of it from himself? Is he just sending over HTTP instead of SSL? And I guess, whilst I'm speaking at DEF CON, probably everyone's thinking, well, SSL is not that great either. But the point is, if he's not protecting it in transit, then you can lose that data. And mashups, by default, by their design, they have to have that cross-domain access. So again, if we were still relying on same-origin policy, it's kind of goodbye to those types of protections anyway now. And then ultimately, the mashup site is the middleman. And you have to decide, do you trust the mashup site itself? On the example before, I probably trust Reuters. I probably trust Google Maps. But the output I'm getting is, strictly speaking, not from either of those. It's coming from the mashup middleman site itself. So there's the potential. Maybe if you have a housing site, for example, and people come and look at that, look it on Google Maps, and say, oh, I want to go to an area with a lower area of crime. Now, how do you know that the mashup site, the middleman there, isn't trying to sell you his house, is editing that data on the way through to you, and saying, yeah, my area is in the lowest crime area. Buy my house from me for an inflated price. And it really comes back to, again, you might trust the individual sources of data, but you're not getting it from those. You're getting your output from that middleman. From a widget point of view, I've used iGoogle here, but you can see it's essentially a way of pulling different little applications, or bits of code, or however you want to call it, to give you that customized kind of page. So giving you access to your emails, stock prices, news, calendaring, and so on, on a single page. So again, it's really just multiple applications. Like I said, different components. The problem can come, though, is if you have a shared DOM model between all of those widgets. So if I have my Security Ninja widget up here, and you've got your stock price and your email widget down here, and we're in the same DOM, then my widget can potentially read your emails, or make stock trades on your behalf. Because whilst they're all within that same DOM, I can also access any of the document dot whatever elements from my Security Ninja widget. So if you're cooking. If you're using a key, or even doing things like key login, stealing data, as I said, from your Gmail widget. And I think more importantly, more important than that previous point, is that these widgets are developed, or can be developed and uploaded by literally anyone. And anyone could include malicious users. Now there's not a sign on iGoogle saying, yeah, this is a malicious widget, don't install it. That's down to you as an end user. And I've got an example of a Facebook, an application I want to look at in a minute. But what Facebook's saying, their terms and conditions, is basically, we're not going to review any of that. If there are security problems with any of these applications, it's down to the users themselves to report that to us. So again, you install these very much at your own risk. So in, in Facebook, there was an application called the Secret Crush application. And basically, you've got a message pop up saying, someone's got a secret crush on you. Do you want to go and find out who it is? If you want to go and find out who it is, click it, click here. Oh, surprisingly, you have to install this application as well to find that out. You install it, and then an iframe pops up afterwards. Now what, this iframe wasn't pushing malicious data directly itself. Basically what it was saying, well now you've got your Facebook application, do you want to install this other thing from us as well on your desktop? And the iframe was being served up by a company called Zango, who are quite a well-known spyware company. So if you install that on your desktop, you've got spyware down there. So really, like I said, it prompts you to install spyware. They managed to get that on 4% of all the Facebook profiles, so 4% of 250 million users. And probably at the end of the day, none of those users really loved you. Only Zango probably did. That's not really a good place to be. I'm going to have to fly through these last few now, but next up, information leakage. Really what we're talking about here is if your application crashes or someone does a SQL injection attack, you don't spit out internal information back to the user. So a simple example here, we've got a URL, and user columns equals two on the end, trying to do a bit of SQL injection attack. We don't handle the error properly. It spits out this internal SQL error message back to me. So yeah, real simple example there. What can make this worse in Web 2.0? Well, we have the idea of publishing things like WSDL files. And what a WSDL file is, is it essentially defines how and where you can access web services. There's a lot of information in there that makes it easy to people to come and use your web service. It also makes life easier when I want to come and hack your web service as well. We're also doing a lot of business logic, validation, storage of data down on the client side as well. And again, we're going to look at two quick examples here. So my Google hacking skills, not really fantastic. I don't think I'm going to replace Johnny I hack stuff yet. But we're doing a file type WSDL search. You can just go and look at these WSDL files, and you can see people straight away here saying, yeah, here's the technology I use in the back end to create these files. Not going to bring the house down by themselves, but if I'm trying to finger print your infrastructure and find out what you're doing, it's a little bit of a help there. And this one here also made me laugh a bit as well. Now I don't have to try and figure out how you're validating my data, because you're telling me up front. So you're telling me I'm going to take your email address. This is the amount of character space you've got to play with, and here's the pattern I'm going to match that against as well. So I don't have to bang my head around the keyboard. I can just go and grab your WSDL file and find that out for myself. Another quick one here. If we're doing validation, we're going to do validation of data on the client side, always back it up server side, and never assume if you're storing sensitive data on the client side that it's going to be safe. So the Macworld conference found that out the hard way in 2007. Basically, in the client side JavaScript, they had an array of hashes. And what was happening here is when you went to buy a pass for the conference, there was a special codes field. When you put anything in that special codes field, it checked it against these values. So the researcher looked at it and thought, well, OK, let me see if I can brute force one of those values. And he brute forced one of them in like 10 seconds and got a $2,000 platinum pass to the conference. When there's money involved, that kind of money, don't do silly things like that. I think they got caught out the following year, again, by the same research with something very similar as well. So yeah, it's not a good idea. Authentication and authorization flaws, really making sure that whoever's using our application is who they say they are and not accessing things they shouldn't do. So with authentication, that's a good thing. And authorization, we're looking at things like making sure that passwords have maximum age, reasonable lengths. If we use things like capture systems, make sure it's not just there to look pretty, that it's actually a useful capture system. I was using a website back home before I came out the other day, and they had four numbers in the capture. And they had two little red lines, one above the numbers and one underneath the number. It's not really obscuring the capture at all. So if you're going to use it, make sure you use a decent one. It's not easy to get right at Microsoft, Google, Yahoo. There's a bunch of those capture systems out there that have been broken. So if you're going to put that out there, make sure it actually does something for you. From a session management point of view, make sure your IDs have sufficient entropy, so every character is random enough, don't have predictable session IDs, don't reuse session IDs, and so on. A flaw I found in Facebook earlier this year, which allowed me to bypass the prevention, the security mechanism, so they had on accessing people's picture albums. So what they found out is they had a very predictable URL to access photo albums. So the URL just had three parameters. It had an album ID, a user ID, and an L equals value. And the L equals value is the only unique value in some instances. So everyone's profile picture's album always had an album ID of minus three. So I don't have to guess that. The user ID value, I don't have to be your friend or anything to get that. And just do a search for you in Facebook, hover my mouse over the add friend link, and I can just see your user ID. So I'll pop that in there. So again, I don't have to try and brute force that. So I just needed to brute force the L equals value. They used five characters, A to F, zero to nine. It didn't take the Burp Suite very long to brute force those for me. If you go to my blog, you'll see that they did fix it, but they fixed it very badly. So the example I'm going to show you in the Burp Suite now would still apply. It would just take a little bit longer. So really what I did is I loaded the URL up into Burp Suite. Sorry, the pictures are a little bit fuzzy. But like I said, if you go to my blog, there's a full write upon on the Facebook issue there. The two red values is basically I'm saying brute force those two. It went away. Brute force them. Found a genuine URL for me. I threw that into the browser, and I could access Bobby Table's photos. I'm not logged in. I'm not his friend, anything like that. So again, it worked for different albums and so on as well, but you had to brute force the album ID value and so on. But as I said, if you go to my blog, search for Facebook, it'll be all up there. What makes it worse in Web 2.0? If we use capture systems that don't provide actually any increase in security, then they might as well not be there. More access points in Web 2.0 makes it more difficult to identify weaknesses. Using things like single sign-on, your Google account, one username and password for loads of sites. Its selling point is also its biggest security issue in my eyes. And then the growth in some of those other attacks, so cross-site scripting, for example. You might have the most random, longest, strongest session ID in the world. If you've got a cross-site scripting vulnerability, they can just grab that anyway, and it doesn't really matter. Running out of time here, guys, but insecure storage and communications of data, really not encrypting data when you're storing it or transmitting it, using weak protection mechanisms and so on. Those types of things are what I'm talking about here. What makes this worse in Web 2.0? More data in more places. It's including a lot of data. It's including the client side. We saw that with the Macworld vulnerability before. If you can't be confident about securing it, don't put it in that location is pretty much the answer. And when you mix secure and insecure content on a single page, the insecure content can undermine the secure content's security. There's a talk by Sam Bowne and I think Robert Hanson as well at 3 o'clock today. I think that's what they're talking about, so go along and look at that. What makes my job harder with Web 2.0? More code. And the applications are largely more complex. It has to be generally more than one language as well. So people are using the best language for the job. So JavaScript down on the client side, PHP or whatever on the server side. Just little differences between languages, even right down to if you look at your regular expressions you use for input and output validation. Different languages have slightly different formats or syntaxes for their regular expressions. So it's more of just getting all those little bits right between different languages. The dynamic nature of the pages themselves. In Web 2.0, a single page could have many different representations of that page because we create them dynamically with things like manipulation of the DOM. It's difficult to make sure that you've tested every type of page A, for example. And then the increased amount of input points makes it more difficult to make sure you're validating every input that comes in. How can you prevent these vulnerabilities? One of the approaches that I take, and if you want more in-depth information on these principles, if you go to my blog, I spoke about them at Security B-Sides on Thursday, so there's a whole PowerPoint up there for that. But really, the idea that I try and push is not to try and prevent specific vulnerabilities, but just develop securely and prevention of loads of vulnerabilities that will come out of that. So what I mean by that is the secure development principles, input and output validation, make sure you've got error handling, strong authentication and authorization, session management, secure communications, secure storage, and secure resource access. As I said, if you've got a lot of data, you've got a lot of information. If you go and grab that other presentation, there's a lot more information on these. And then just visually here, to finish off, secure development doesn't happen by accident. You need to plan it right at the start, have it in your requirements and design documents, do things like threat modeling, educate your developers. Don't just assume that you're going to be able to develop securely. Educate them so they can build security into the code, make it part of the application's DNA. Think of it as you make it part of its DNA instead of trying to put a code around it at the end, because it will fail if you try and do that. So get someone independent from yourself to review the code, and then finally try and hack it yourselves before it goes live. So thank you very much.