Closer? Yes! Alright, thanks. Web application security, I'm here to talk about, well first, I've been working web application security for about three years. Some of the things I've seen, how to get into different systems on a purely web application level, not the web server, more like the CGI's on top of it. So, I'll just briefly go over what a web application is. Web application is basically a CGI, they're message boards, web mail, guest books, auctions, online banking, stock quotes, the biggest companies run these things, they're everywhere. You see them, if you go on the web and do just about anything, chances are you're working on a web application. So what as security folks do we see and how to break them down, how to circumvent the security. So that's what I'll be covering. So the scope of the topic I'm going to try to keep to on the client side of the connection. Web application security does deal with the actual exploitation of the system, however RFP or many other people cover it a lot better than I do. So this is sticking to basic client level, attacking the browsers, attacking the cookies and things of that nature. However, if you guys have like system things you want to ask, also if you guys have any questions, anytime, go for it. So who uses web applications, eBay, Yahoo, Microsoft Hotmail, E-Trade, anybody got some more? All right. What was that? Right, there's a web application too, like say like Linksys routers and stuff like that. I don't know if you guys are familiar with that. That would be a web application. Right, at least like distance learning and things like that? Right, right, right. Or like All Advantage or something? Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. All right. Yeah. Yeah. Yeah. I'm not sure exactly if I follow but if you have questions on it. So... ? Porn sites? Okay. Let's see. From a security standpoint, when you're auditing a system, or I'm attacking a system, generally there's three main types when I'm trying to profile a system as far as learning about it and what I'm seeing. There's the CGP. or the web applications that allow the user to input HTML and get an echo of HTML back where it means it might be filtered, but it still comes back as HTML. It's actually allowable. See it in chat rooms and message boards and things of that nature where it stays HTML. The other ones are the ones that do not allow HTML at all. The ones that strip it out blatantly for whatever reason, you know. We'll figure out why later. And the other ones are systems that use their own subset of HTML. I won't cover this too much, but you'll come across, like, chat rooms and message boards and stuff like that where you want to change the formatting of the web application. You have to use their own subset of tags. And there's also the ones I'll briefly cover on the ones that use Java-based engines to run it. The chat rooms, like, you know, Java-based client that connects to IRC or something like that. There's a lot of them out there, but I won't cover those too much because they're kind of their own embedded app. Q&A So, when you have a CGI, what kind of things are you exposed to by putting it up on the web where everyone can look at it? There's system exploits on the system itself. You can, there's browser redirects for the user. If you can find it and implement a CGI bug, you could throw an entire site to another site, say, a portal site. That would be kind of fun. There's page spoofing where we've seen instances of... Q&A of a bug being exploited in a system where the user gets a fake login page and then willingly give up their username and password. There's also theft of their cookie file on that domain, which could give up their authentication for that particular session. And there's also things you can, you can get user information and you can also track the user, even though it's not really your site. So, we can cover, anybody have a question so far? Q&A Q&A Q&A Well, I'm sorry, what was your question? No, Sure. Q&A No, I'm just Okay. First, we'll cover the systems that allow the HTML. Q&A Let's see here. Let's go over basic cookie security because lohot of sites, they use cookies for simple authentication and reauthentication as they move through the sites. Also, like, for shopping carts and things like that where the cookie actually keeps track of local procedence here. the actual session. Basic cookie security is a particular website should not have access to any cookies or only should have access to cookies for its particular domain. It shouldn't get access to cookies from another domain. However, nice people at Microsoft with that latest IE bug kind of destroyed that one. But basically that's the security implementation. Let's see. So let's say you found a wireless coverage. Okay, what is JavaScript now? What does JavaScript have access to? JavaScript, when you're implementing it to the system, into like a chat room or a message board or something like that, what does it actually have access to? Well, it has access to all the browser information. It has access to the IPs of the user, all the plug-ins and the paths to the plug-ins, just about every thing that they're using. It also has access to the cookie files and their environmental variables. The important one that it has access is to the domain that JavaScript is executing on. It has access to the cookies on that domain. Now, the trick would be for a supposed hacker or malicious user is to try to get the user's cookies off the domain into another domain. Okay, so I'll show you how a lot of how that's accomplished. How that is accomplished is if a user was to put HTML and JavaScript into a message board and you were to go read that message, the JavaScript would execute in your browser environment. Okay, you would be able to grab the domain cookie string and append it to some HTML mechanism that would send a get request off the domain to somewhere else. For instance, you could change the source of an image on that page and append it to another domain. You could change the URL to the end, so a get request would go to another server off the domain and you'd get the actual cookie string. I hope that's clear. Okay. Anybody have any questions on that so I know what I did to get clear? Yes. Okay, I guess the flaw would lie in JavaScript. Okay, if you're able to put JavaScript into a system and users would read it, okay, if a user would read it, the code would grab the string and say, make it real simple, open a new window with the attacker's domain and append it to it with a CGI and append the cookie data to the CGI variable. So, it would do a get request with the cookie value off of the CGI. So, basically, the whole cookie value gets passed to the CGI off the domain. It's for authentication. That seems to be one of the more widespread ones. If you're able to get the user's cookies, you can replace your cookie with theirs and in essence become them. So, if an active E-Trade user was... running, grab their cookie file, replace it with yours, and guess what? You get to trade stocks in their account. So, now, in a lot of systems, they'll have, I guess, HTML, JavaScript filters to try to clean up the problem, but still have to allow, I know, for whatever formatted reason, to keep HTML and JavaScript in the HTML itself for their users' features. So, so, I'll talk about some of the ways to get around it or how you test it. The basic, basic, basic tags you're doing, when you're running off CGI, what you don't want to allow into your system to be able for the user to pass into the message board are the following tags. You don't want to have the P tag go in. I'll explain these why later. You don't have the applet tag come in, the embed, script, layer, frameset, frame, HTML, body, style, meta, or object. There's a lot of them you have to filter. If you, like, for instance, if you allow the applet tag into the system, into a system that allows HTML, they can load a, whatever Java applet you want, and do whatever to them on somebody else's domain. You know, imagine if somebody, you know, like Microsoft Hotmail, you email somebody a message with a, with an applet, and it loads, and then you have access to their, everything on their domain with a Java applet. The same thing goes for, you know, the style tag, embed, anything of that nature. So, those tags. You actually have to strip out, even though you're allowing HTML. Nothing good can happen when you're, when you're using those tags. So, the script tag, the P tag, there's a known, there's a known exploit that's been posted to BugTrack. I think Georgie Ganinski found it, where you can actually add a VB expression that actually execute JavaScript without actually having any JavaScript. Looking things in it, so nobody knows really the filter for it. You'll find it on BugTrack and things like that. Which brings right into the, the things that you can check in your own CGI's or other people's CGI's. Thank you. I'm sorry. I just want to comment. One of the original reasons why URL came out as a philosophy or a tool was that you had one address. Pretty much the system for this is the request you're giving to the server, then it's going to give you something back. Right. And we've seen on four of those things, and cookies, that this constraint is everything you need for messages to get into the URL, has been violated. Do you think that there needs to be some kind of use of it for browsers that allows us to continue to see what we're sending, what we're providing, and perhaps get that information accessible? The question was, do I think that more security should be in place for, say, forms of values being passed to the CGR to the web server, as far as, should it show you what you're actually sending them? I think yes, but no one's seen it so far. Basically, I guess the idea of the web is to try to make it user friendly, but yeah, I think so. I'd like to be able to know immediately what, you know, cookie data I'm sending without actually having to look in the cookie file. That'd be my preference. Thank you. So, when you're testing a system, if you're actually auditing your own systems or somebody else's systems, what can you actually test against? What actually are the exploits to get past the, I guess, the string filters and things like that? One very simple one is the script tag, if anybody's, you know, everybody should be familiar with HTML and JavaScript. The actual script tag, when you put an expression in there, you submit it to the system. You can even try it like on, like a lot of search engines will allow you to put, right into their search function, put a script tag in, and it brings back a script tag and it executes. Major no-no to have on your major site. Another way to, so what major sites do is they, they filter for the script tag itself. They'll strip it out, replace it with whatever. They'll strip it out completely or replace it with something, which is a good tactic and you should all use. Another way to get around that would be to, when you're submitting the, to the search engine itself a string, instead of just one single string, and then you have a string, it'll take that string out. singular line, throw a carriage return in it, because it's actually a character, and it will actually, a lot of times, beat. They won't escape the carriage return, so it will actually beat the filters and still get by and echo back. Let's see. Let me show you. Okay, you see the script tag way up there? That's the most basic one. Try that into a lot of places, and that will work. So basically, what you can do is, if you know somebody's active on a session, say, like anywhere, like on Hotmail or something like that, and you email them, I'm not saying it works in Hotmail, but you email them an HTML mail with the script tag in it, and it executes, you have access to everything that Hotmail actually has. It has access to. The second one from the top is what I call image sourcing. Basically, what the idea is, the JavaScript colon and then the JavaScript expression will actually execute inside of Netscape and run. It doesn't actually look like JavaScript, but it actually works. So sites will have to. Look for the JavaScript keyword and, like, separate it somehow or do whatever they want to do so it doesn't execute anything other than what it originally looks like before it gets echoed back to the user. It has to be done. And the ones below it were actually Netscape's code names for JavaScript while they were developing it. Mocha and LiveScript in replace of JavaScript will also work, which is quite nice of Netscape not to tell us about. So basically those, in all systems that allow HTML, have to strip those out before they get echoed back to the user, otherwise, you know, security breakdown again. The singular line break below that is what I was talking about before. That will still execute in Netscape and beat a lot of filters. The multi-line break, so, you know, trying these against systems, they'll get smart and wise up and start escaping the carriage returns. Well, you can multi-carriage return it and it still works. So you can do that. You can escape the whole thing. So we begin to start to see the thing where HTML and JavaScript start not to look like HTML and JavaScript. It looks visually broken, but it still works. So you still have to, you know, clean it up before it gets echoed back to the user. The one just below it, HTML Entity String Break, this is one that's like an HTML entity of just like a weird character you want to display. I'm sorry, you have a question? Yeah. I haven't seen any commercially available ones. Most companies that I deal with have been writing their own for their own developers. Which means that they want to strip like things like this out. And they'll write their own libraries and have all user input variables filter through them. And then they can use them, or they'll just blatantly rip out every instance of HTML. I haven't seen any commercial products that do this. So I'm not sure what you're talking about. everybody's kind of on their own until someone figures one out. The HTML entity string, the ampersand, pound sign, zero, nine, semicolon, it's just a, I think that's like a tab or something in ASCII, and the whole ASCII set is available in Netscape so you can make all the weird characters show up, but I found that that particular string, nine through 12, actually breaks it up and will still execute, so it'll bypass the implemented filters once again. So things like that will work. So basically what happens is when you throw that into the system and you view source on it, that will actually not look like that, but it'll be separated but still work. All these require the 3-minute lifespan, what if they just strip out the 3-minute? Right, that's the most effective way I've seen so far on a system that does not want to allow HTML into the system. You rip out the less than and greater than signs and also the quotes. And you lose all HTML functionality, yet you get all your security back. But you can still, if the application allows you to insert an image, you can still be able to use the other jobs? Yes, you will. So, you know, most chat rooms, most of the boards do allow that. Yeah. The one just below it. Yeah. Yeah. The HTML entity. I did have to figure out why this works, but I found it one day and it works. The ampersand, I guess, open curly brace, and the syntax has to be perfect for it to work, and it only works in Netscape. The ampersand curly brace open has to be filtered for, otherwise JavaScript will execute any expression that you throw in there. So it might be a good one to remember because it's posted out there. But it's hard to find. Oh, sure. She asked me to repeat the question before I answer. Sorry. Okay. When I'm auditing a system, what I'm generally looking for is I'm looking at the URL, I'm looking at all the source code in the web page. Looking at all the form values. Looking at all the link URL values. Anything that has a CGI and all the variables to it. And seeing what values it's taking. If it's taking any. And, you know, like shopping carts are notorious for this. When you're buying an item, it'll have price equals. And then you submit. Right? So what stops me from, you know, I'll buy like my, you know, like Sony Viya here from, you know, 3,000. I'll just make it five bucks. Many, many sites put this in there. And trust me. I'll pay them right? That's the value that I give it. And I bought a laptop for five dollars. So. How do you build that? I didn't get that question. How do you build that? Take the fifth. Also, all the strings. A lot of times developers will put strings inside of URL variables and stuff that you actually get thrown up on the page, for instance, like ads and things like that. So a lot of times they don't filter those. So you might want to play with the strings also. And see what actual variables are getting filtered. what aren't. You can change it to anything. Change it to JavaScript, HTML, put a negative 999 in there and crash the CGI. Many, many things. Also, what I had to mention is many CGI's, when they're doing authentication for the users that aren't using cookies, they'll use a login equals. Like for portfolios and things like that. So if you actually just change the login to a different username, you'll get their portfolio. Don't do this. People are looking. Now, basically you've seen a lot of the exploits. There are more. But as of yet, no one's put out a good security auditor yet. I've heard rumor of them, but haven't seen any that good. So how to protect and defend. Do not trust any of the input that the user is going to give you. From the website, I don't care if it's the browser information, their username and password, anything. Do not trust anything that they're giving you. Check everything, strip everything. Because people are doing this with a lot of free time. And testing every single value they could put into every variable and just seeing what your CGI does. So you have to account for everything. One rule of thumb when you're developing a CGI, never, ever, ever allow JavaScript, Java, or any plug-in. So that means if your users are able to put JavaScript, Java, or a plug-in on your system, you've got to disallow it because it will do very bad things. For instance, Flash has JavaScript in it as far as a sub-language with lingo. And they have full JavaScript functionality from inside of Flash. So you might think, okay, I've got everything all blocked and you're allowing them to use Flash. And all of a sudden, no. Your whole entire user base shifted to somewhere else. Also, if you're really security paranoid and you're running, say, business.com, and you have to allow some of these things to go through and you're really paranoid that you're not going to get everything right, like say for your message board or your chat room, you want to keep pretty good security for the cookies themselves, host it on a different top-level domain. Instead of business.com, go through business.net. That's the way all your .com cookies are held safe for the moment until you move them back over to business.com. It's a method I've seen work pretty effective in the past. Again, somebody asked the question how to defend. If you're in a workload type environment, create libraries to do HTML stripping that all your developers can use and funnel all the user input variables through and get them back out so they know all the variables are safe to use, both in the user's environment and out of the user's environment. Okay. Also, one more authentication scheme that I've seen a lot of people use is when you're doing cookie-based authentication and you're doing a session ID with a, you know, you're hashing the username and password with a random variable or something, you can actually rehash another variable. Let's say I've got a form submittal. You put a hidden variable inside the form that you're submitting to the CGI with a hash of their cookie, okay? That means no one else is going to be able to submit the form off of your site. I don't know if that's quite clear. It's kind of like tagging the web page of, you know, sorts. So, well, let's say I'll use Hotmail, for instance. Let's say they're doing a session-based ID, session-based authentication, and you don't want people logging into Hotmail from places other than Hotmail. So, what you would theoretically do is run a hash on their cookie that's in their system and tag it as a hidden variable inside your login page. That way, if you move it to somewhere else and try to submit again with different values, it will fail because the hash won't match. The hash has to be server-generated otherwise it defeats the purpose. Right. Yeah, the question was you'll pass different or multiple variables off pages as you go through, so it's important to check every single variable as you're going through the site. So, basically, you have to crawl the whole site and be thorough. Any other questions? Oh. The question was, would I feel that this is a problem of, I guess, lazy developers not looking, doing correct string matches or not being very security conscious in general? Basically, I would say yes and no. One, I would say yes, they're lazy programmers. They're not looking at BugTrack or the other sources for the known exploits. Two, no, they aren't because they don't know them all. So, they can't filter for something that they didn't know existed. Yes, it does. That's why HTML email pretty much exists. I'm sorry. He asked, does HTML mail execute JavaScript? Yeah, it can. That's, you know, you'll see in the news all those HTML mail exploits and stuff like that. That's that. Those I haven't played with firsthand, but problems with those probably could and do exist. So, any other questions? Are there any tools out there that help you ? I know of, like, a couple, but I wouldn't classify them as good yet. They're looking for, basically, the tools that I've seen are looking on a, they're looking for, like, auto-auditing commercially available applications. Most bigger systems where these are going to be needed the most are not something that you can write an immediate big software package for because they're proprietary and you have to do it manually now unless somebody comes up with something pretty good, and I haven't seen that yet. . No, basically, you would, his question was about how to, you know, defeating the hashing. I guess it wasn't quite clear on that. You hash a variable, like a random, something random on the page and also part of their session with only a hash that you possess. You have to keep your hash kind of, you know, private. And do it that way. Not, you have to use something on the server side that only the user has and the site has. So it has to be done well. I'd probably not explain it well as, like, applied cryptography would, but you can hash the page and have it work well. . Well, that's the idea. That's the idea of hashing. You can't go backwards. At least I can't. . Any other questions? Go ahead. . If you turn off the, the, the, his question was if you turn off JavaScript and Java, will the image sourcing one work? No, it won't. All JavaScript is pretty much turned off, but that makes for a pretty lousy web environment and everything breaks on the web as those who run it have seen. Any other questions? . All right, I guess that's it. Thank you. Oh, okay. . How hard is it to, what, how I feel about crypting the browser session and or the data being passed, right? I would say I would like it all encrypted. However, I guess the, the RSA licensing gets pretty expensive from time to time. I mean, you have to get a license for every single server, so it gets pretty expensive. That's why they only do it on, you know, purchases and stuff like that. But I would like to see all of it, but we don't have it yet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . is he could claim to be whoever he wants and there's no checking on the client side end. So, yeah, you're right. Also, actually, I didn't get to ask Jennifer Granik one question. I don't know if she's here or not, but basically I wonder if viewing the source of a web page would fall under unauthorized access of a source code of an interpreted page or, I guess, fall under reverse engineering of the DMCA. Would viewing the source code of a web page fall under that? I don't know. Maybe. Unless there's any other question. I guess I... Oh, I'm sorry. Yeah, I'm a government employee and I put out a website and a bunch of users are saying, I'm not using your website because you're using it on the script and it's my inside. Okay. Besides stealing cookies, is there anything I'm missing that I don't understand about this? Well, let's say, I guess, some people want to direct traffic away from your site to somewhere else and they put... If you post something on your site, that means all your visitors that go to your site get forwarded to somewhere else. That would be one other thing. If they can't put... Well, if you're the only one posting the information on your site, then you're pretty much clean. That means everything that you do is your fault. So... All right. Yeah. Is there a way to hide or to sort of... disguise the URL of the page that you're visiting in the location bar by using sort of a parent frame on that? The parent frame is... He's asking a way to hide the URL if I know any ways. I haven't seen any really good ways to do it. I say the parent frame technique works quite well. I haven't seen any other really good ways. I have seen... Begin to load a page and then stop the load. And then he kind of gets a URL that way. But I haven't seen any really good ways. That's kind of weak. The question was, you can actually... Yeah, I forgot to mention that one. It's a pretty good one. A lot of, I guess, browsers and search engines will take not only ASCII as a domain name, but you can actually... Or, like, IP addresses. You can actually re-encode them in URL encode and get those to work. Or you can get Hex to work. I've seen Okta work and everything like that. So those are actually good filter-passing mechanisms. The question was, using... Hidden iframes. Yeah. Hidden iframes. You can use hidden layers and do it that way. Lots of ways. So, yeah. Again, don't allow people inputting layers on your page. Bad, bad, bad news. Any more? Oh, okay. The P tag. I can't... Sorry, I don't have, like, the perfect syntax memorized to type it out for you. However, there's a... I guess in VBScript, there's a left... left colon expression. You can search for that under the P tag. I think Georgie Ganinsky on his site has it posted. But it's a VBScript expression that will execute. Also, style has one similar like that. On a style tag, you have type equals, and you can put JavaScript and stuff in between it, in between the beginning and style tags. And, once again, JavaScript's into the system. JavaScript's pretty much a cockroach. You have to exterminate it. Okay. I'm sorry. I missed that. I really don't know XML all that well, but from what I read from the specs, it seems it's... Like, for instance, the ones that look, you know, broken visually don't work under XML because it's very specific, meaning the programming is not forgiving when you make a mistake. So... Any other questions? What time do we have? Probably so. Sound lovely. That's all I got, so... Thank you.