start	end	text
77840	82160	Okay, I'm Jeremiah Grossman. This is Lex Arquette. We're going to be doing a talk on web application
82160	90820	security. Thank you. This talk is going to be different from the one we did last year.
90820	94960	There's going to be a lot more exploit theory and a lot more exploits and how to beat different
94960	102480	CGI filters. Things that every CGI application is going to be exposed to, if not now, later.
102480	109420	So, let's just start. A lot to cover. What is web application security? Simple enough,
109420	115680	it's the securing of web applications. It's pretty simple. Web applications, they're used
115680	119480	everywhere, you know, they transfer money within bank accounts, you know, message boards,
119480	126440	web mail, I mean, you name it, there's a web application for it. And the security that
126440	129220	we're going to be showing applies to them all because they're all taking user input
129220	135440	and sit between a web server with a web interface. Anything that does that, anything that processes
135440	142320	via a web server is a CGI and this is what we're going to be covering. The difference
142320	146760	between software programming, at least from a security standpoint, is different from the
146760	153020	way that before when you wrote an application, you know, on a LAN or, you know, maybe like
153020	158960	ten years ago, the application that you write, the user base is relatively small. So, you
158960	163400	didn't see as much abuse of the applications that you do now. Now, when a web developer
163400	168280	or any kind of software engineer writes a program that's shipped via the web, everybody
168280	172840	has access to it and there's going to be some people, a thousand people, they're going to
172840	178340	have an infinite amount of time to mess it up, you know, throw whatever they can at it
178340	183560	to make it screw up or do whatever they feel. So, some of the attacks when we're talking
183560	188700	about web application security is browser hijacking, which means is an attacker threw
188720	192960	a web page on the client side. It's important to realize what client side is when we talk
192960	200960	about it. Client side is like when you're viewing a web page, somebody injects JavaScript
200960	204820	via like a message board or something and takes control over your browser. Client side
204820	209400	through like document dot location or closes your window and a million different abuses
209400	212960	like that. There's also cookie theft and we'll get into cookie theft in a minute. There's
212960	219840	server and client side compromise, shipping weird characters and input validation manipulation
220520	225480	to get the server to give up more than it should or more access than it should. There's
225480	231920	also denial of service where creativity within a web application exploit, you can actually
231920	236460	render a site useless by no one is allowed to get there. Every time they go there, they're
236460	242020	pushed away. There's also different abuse mechanisms like cheating on games or cheating
242020	250580	on auctions or buying a laptop for $20 where you should have paid $2,000. And there's also
250580	255660	user privacy invasion. The client side scripting applications give you tremendous amount of
255660	262900	power and information about the user of which they execute. You'll get IP addresses, host
262900	267900	names, subnets, user names, email addresses, system configurations, you name it. There's
267900	276540	all kinds of data you can access with a client side script. So, let's get right to it. How
276540	282400	to steal cookies because it seems like many people aren't too sure how it's done. Cookies
282400	286300	are, the cookie security is, you know, according to the RFCs and different documentation you
286300	291040	might read, they're restricted to domains. So when a cookie is set within a client, there
291040	296180	is a domain that is attached to the cookie which the client should only send the cookie
296180	303040	back to cookies within that domain. Cookies bleeding over into another domain is considered
303040	309860	not good and that's a cookie theft and can lead to all types of user compromise. Basically
309860	315400	how a cookie is stolen is by somebody injecting JavaScript or some kind of cookie thieving
316740	321800	tool onto the domain that steals a cookie. So basically if you're a web administrator,
321800	326840	you do not want to have uncontrolled web data on your domain or at least on a protected
326840	331320	domain. So, I just use JavaScript, you know, you can do the same thing with VB scripts
331320	335680	and a lot of other, you know, web application scripting languages. But we have the expression
335680	341860	document.cookie. Basically that's just a string of the cookie data of the domain of which
341860	347860	the script is executed on. Now what you can do here is with these following functions
347860	355380	like window.open, document.image.source, you set window.open equals to attacker.com.cgi.bin
355380	363820	pointed at your CGI and append the cookie data to it. What happens is the cookie data
363820	368540	actually gets passed over a get connection or an HTTP post or get or whatever and you
368540	372580	can actually pick it up off domain. So you're basically just moving strings around and using
372580	376600	the power of HTML and JavaScript to move the cookie off the domain. So there's lots of
376600	380500	ways to do it. You know, I've written utilities on it, but I've been hesitant to do it recently
380500	382660	because I don't feel like a bunch of script kiddies need to be running around stealing
382660	391270	everybody else's cookies. So, what are secure web programming practices? You'll hear this
391390	397150	a lot. Do not trust client-side data. You'll understand more why later, but as a whole,
397150	401670	you cannot trust anything coming from a client. You have to validate it, you have to sanity
401670	409810	check it. You do not trust it. There's also hidden form elements are not hidden. If you
409810	417590	put a price inside of like an online order form, they're not hidden. These are just common
417590	421730	things that we see around. Password elements, still transferring clear text, just because
421730	426070	you can't see it doesn't mean it's encrypted or anything. Use solid crypto when you're
426070	431930	doing anything online. Don't use DoubleRot13, no matter how secure your friend thinks it
431930	437930	is. Of course, stick to DES, triple DES, Blowfish, there's lots of good ones out there, but stick
437930	443830	to the ones you know that have been proven. Avoid authentication mechanisms using JavaScript.
445750	450090	Basically everything happens client-side using authentication via JavaScript, all the passwords
450090	456710	or at least all the authentication credentials are going to be at your fingertips. Re-authenticate
457430	461650	the user with a password before issuing new passwords, you know, just goes right towards
461650	464950	like the Unix mindset, you know, they have to type in their own password before you issue
464950	468750	new ones. You'd be surprised or maybe not so surprised how many sites allow you to change
468750	473170	password just by manipulating some of the input fields to change a password once you have
473250	481950	a stolen cookie. Let's see. Do not host uncontrolled data on a protected domain. I realize for
481950	488030	some people doing this is hard, but as a general rule, try not to do this. Sanity check and
488030	496210	qualify all incoming data and another great resource is the World Wide Web Security FAQ,
496210	500830	if you haven't read it already. By the way, all this material will be available on whitehatsec.com
500830	508570	probably Monday when we get home. These are the basic client-side scripting languages.
510570	516990	There are a lot of them. This is not a finite list. There are more. We have DHTML, JavaScript,
516990	525070	Java, Applets, VBScript, Flash, ActiveX, XML, and XSL. Getting to XML, most people are using
525070	529810	on the backside right now. However, browsers are supporting it on the client side and when
529810	536110	you get to some of the security issues about XML and XSL and Microsoft.net at the end.
536250	542750	And there's also CSS. We have the document object model. Basically, this is like the
542750	549290	object-oriented model for HTML and JavaScript to access different functions and features
549950	556250	and information within the browser. Basically, with all these client-side scripting languages,
556250	560510	all their complexities, all the different things they can do can be combined to gain
560510	567810	increased access to the DOM, which they really shouldn't. Basically, you can get background
567810	577660	colors, you can get files, and you can even execute system calls. Okay, if you're running
577760	582180	a web application, or at least with some kind of complexity, you're going to be taking input
582180	588480	from the user. So again, never trust client-side data. Escape, validate, parse, filter, and
588480	594080	sanity check all data. All of it. Not just like the ones where they're typing in like
594200	601660	a search field. Get the hidden ones. Everything coming over has to be checked. With client-side
601660	607040	data, you can never be too paranoid. Let your paranoia be your guide. Let's see, common
607040	615980	input. Mistakes. Sanity check all input. When I say sanity checking, a lot of CGI's that
615980	621880	we find, like, for instance, the yes or no, we find that a lot of times, you know, the
621880	627080	pull-down menu says yes or no, but we can actually add like a nothing or some other
627080	632480	string in there to cause panic within or an error within the web application. So for instance,
632480	638180	if you're using a numeric value or a yes or no, check the input for what you're expecting
638180	644060	and ditch the rest. Escape it. Don't be just taking in whatever you want or whatever they
644060	649740	send to you. Same goes for file names, paths. Don't parse and especially don't use what
649740	660620	you don't know. Escape all input special characters. So it's important to understand that special
660620	663360	characters have a lot of meanings on a lot of different operating systems where it's
663360	670380	piping, redirecting, semi-colons, stars, file-globbing. Special characters can do a lot to your system
670380	676720	so they all have to be escaped or replaced or something has to happen to them. Preferably,
676720	681540	if you need to use special characters, escape them. If you don't, remove them. And null
681540	685540	characters is very important. Null characters don't belong in, should not come over the
685540	692140	wire unless there are some really weird circumstances, but they all should be ripped out completely.
695290	702160	If you have need to allow HTML into your site, however it's not supposed to execute, use
702160	706760	these little guidelines so it doesn't. Basically, you just want to convert the less than and
706760	711000	greater than signs and the quotes into HTML entities. It's real simple, very important
711000	720240	though. Everything from file not founds to search fields to search errors. A few other
720240	726020	things that you got to watch out for, you know, the directory transversals, the file-globbing,
726020	732780	appending commands. We find a lot of times registering for, for instance, like a mailing
732780	735800	list or something, you type in your email address and it auto-responds, it'll just do
735900	741020	a quick send mail, send mail to this email address. Well, pipe a semi-colon on and execute
741020	750220	another command, cat direct etc password and you got it. Data piping, quotes are, quotes
750240	755500	can do a lot of damage, especially when you're using fixed strings like in a sequel and things
755500	762540	like that. So if you're not wanting these, you know, strip them out or escape them. Output
762540	769760	filtering a lot of times is ignored. Output filter queries from a database, for instance,
769760	775260	somebody might be updating their profile information and put a lot of nice, a lot of little cool
775260	780220	HTML and stuff and they go, hey, see my profile. So, does a query, ships it back to the person
780220	785220	that saw and there's XML or HTML executing on the client side. So you have to output
785220	790540	filter as well as input filter. And if you want to take a quick note, here's some other
790540	796080	good CGI examples that give a lot of, a lot of really good data.
799250	804290	HTML is dangerous. You know, it's, you know, it seems light, loose, everybody uses it,
804290	810610	but it is dangerous, especially for web applications or client side security. If your system, if
810610	816410	it's web mail, message boards or whatever, if it's using HTML input from users, it's
816410	820970	very hard to get it secure. Even when the proper precautions are taken, it's very hard
820970	827530	to lock it down. So the best way I could suggest to lock it down is use allow permit lists.
827950	834390	Know what HTML you want your users to be able to send in and only allow those. This goes
834390	842650	for attributes too. Also, let's see. Yeah, limit your lists, keep them short, know what
842650	847390	they are, and know what attributes and tags are harmful so you don't put them on your
847390	852410	allow list. We'll get to the list in a second. Well, there it is. So these are the common
852410	858470	tags that are known to be dangerous for various reasons. Applet, you can input Java and gain
858570	863310	a lot of access. Image, inline images can grab cookies. Layers, you can source in other
863310	872550	data. You know, object, ActiveX controls. Style and script are pretty self-explanatory.
873030	879130	But these are basically the tags that are known to be dangerous that every system allowing
879130	886230	HTML has danger inherent when they are allowing these tags. Any tags with attributes that
886230	890350	have style, source, href, or type are also at risk. So you have to watch out for these
890350	898050	attributes in any tag that allows them. Now we're going to get a bit into user authentication.
904650	908330	Web applications a lot of times have need to authenticate the user, whether it's username
908330	913150	and password or persistent cookies and that nature. So we're going to get... go into a
913150	918590	lot of things in that nature that we see out there. And some guidelines to help out people
918590	923430	so they know what to do and what not to do. Passwords, as a general rule, are your user's
923430	928450	weakest link. Users are always picking easy passwords. Users are always giving up their
928450	934550	passwords. So, never store passwords in plain text. Age all passwords. It's very important
934550	942010	that passwords, at least at a given amount of time, they die or they invalidate themselves.
942010	947010	Age all passwords. Otherwise, make sure good system maintenance. So you don't have a password
947010	951050	that's on the system for about, you know, six years and you forgot about and somebody
951050	956690	can still log in or steal it. Age them and deny them. Password restrictions, we'll get
956690	962930	to that next. General guidelines. Passwords should be, at least in my opinion, should
962930	970150	be six letters in length. Six letters in length. Not matching the username. And not a common
970150	974070	password and contains one capital letter. It's a very simple password, but however,
974070	979450	it gets a decent amount of security. Now, a lot of usability experts and security people
979450	986510	have different mindsets on it as far as usability versus security. This should, for the most
986510	991810	part, secure your passwords to at least a minimum level. You know, it's better than
991810	996390	password being password. If they have to have password as their password, make it a capital
996390	1004010	P with a 1 at the end. Passwords should be six letters in length. For an increased security,
1004010	1007890	passwords should be six letters in length, not matching the username or part of it. Not
1007990	1011790	a common password and must contain one capital and one special character. This is pretty
1011790	1015970	good. This would be pretty hard to crack, at least on a brute force level on a web basis.
1016830	1022830	Again, let your paranoia be your guide. What not to do. Now, we see this out there a lot.
1023490	1029130	Placing a maximum password length. Okay, don't do that. I've seen places where they're allowing
1029130	1035950	like, you know, no passwords over 4 or 5 characters. Now, how long does that take to crack? Passwords
1035950	1039930	that are allowed to be changed into the old ones. So, let's say you're doing aging. Don't
1039930	1048600	let your users change their password into the current password. Check for that. A lot
1048600	1052200	of sites we've seen, well, maybe not a lot, but it does happen, echo the new password
1052200	1058140	that they typed in over a non-SSL link. No need for sniffer bait. Password restrictions
1058140	1062160	are too high. This is kind of like a sticky point. You can make your password restrictions
1062160	1066120	pretty high for, you know, most competent users. But if you make them like too high,
1066120	1076250	like, you know, really, really high. Both. These are like general guides. You can actually
1076250	1084290	adapt these to a lot of secure programming. Making password restrictions too high. What
1084290	1087170	happens if you make a password too high? You know, they're typing upper and lower case
1087170	1091450	and numbers and symbols and stuff. Users are, at least on like a web sense when you're dealing
1091450	1095690	with like a, you know, 50 million users or 30 million users or what have you. They're
1095690	1098910	going to write down their password and stick it on a sticky note and put it on their monitor.
1099190	1104010	So, you know, so you have to walk that line. You want to make it secure, yes, but not too
1104010	1110630	secure where they're tempted to do stupid things. Okay, brute force attacks. We're going
1110630	1113250	to go real quick over this because this is Uber Hacker. You guys should be all aware
1113250	1119270	of this stuff. Brute force in a web account, web accounts, there's two main attacks, at
1119270	1122710	least from like a web sense, for instance, like, you know, banking and stuff like that.
1122710	1129110	One user name against many passwords or less common but very effective, one password against
1129110	1132870	many usernames. So some systems, if they don't have password restrictions, pick the password
1132870	1138470	password and level it against 1,000 user accounts and you're probably going to crack a couple.
1139390	1145910	Each attack can be very effective and both must be defended against. We're going to state
1145910	1151070	some defense mechanisms against it. So how do you defend your web apps against brute
1151070	1156230	force? Set an acceptable threshold of the amount of failed attempts a single account
1156230	1160550	can receive before that offender is blocked at an IP level, because you don't want to
1160550	1166130	keep doing it, and the account itself is locked. Same thing goes for multiple accounts from
1166130	1171730	the same IP. Okay, when an IP set, you know, goes over like 10 failed attempts, you have
1171730	1176410	to block them. Okay, so for instance, like on the reverse brute force, a single account
1176410	1183590	isn't going to get like 10 attempts. 10 attempts, however, you still want to block the IP. Now
1183670	1186970	a lot of people are thinking like, you know, wait a minute, there's like DOS attacks regarding
1186970	1192130	this, right? Like, for instance, if, you know, somebody's, two people are competing at an
1192130	1195810	auction, you know, and I want to win, so I'm going to lock my opponent's account so he
1195810	1201810	can't make a bid. So where to get to the point? Did you guys get that? I'll say that one more
1201810	1206850	time. So let's say I'm, you know, I like this Dell laptop and I want to get another,
1206850	1211350	so I log on to my favorite auction, and there's a bid war, you know, going up and up and up
1211350	1218130	and up, and I'm sick of having to, you know, bid-bask my opponent. So what I do is, I sent,
1218130	1224170	I knowingly send 10 failed attempts against his account, and now he can't bid, and I win.
1224170	1236910	So, however, like, one second, yes please. He asked about proxied users, we'll get to
1236910	1245750	that in a second. Okay. So, now, there's DOS attacks against these systems, as I just said.
1245950	1249730	Basically if an attacker wanted to DOS an account, he could, because he doesn't really
1249730	1253350	care about cracking the account, he just wants to block the user, many abuses in this regard.
1253830	1260190	Now, also as a result from IP blocking, AOL and proxied users are blocked also, because
1260190	1264630	they're amassed behind like a single subnet. Know your users. If you're in a restricted
1264630	1272550	environment, you can IP block without restriction. However, if you're, like, servicing the entire
1272550	1277270	web, you're going to have to make allowances for proxy users and AOL users, so, you know,
1277270	1282490	basically, you can't block AOL. So, basically, you just have to set the rules, then, that
1282490	1292050	you can't block AOL. Bummer! Possible solutions. When blocking an account, log the offending
1292050	1296930	IP with the account block. Now, what happens is, if the legitimate user logs on to the
1296930	1301730	account, and the system is going, okay, this account's blocked, but I want to take, I want
1301730	1307370	to do a comparison against the new requesting IP and the one that was the original offending
1307370	1310490	one. If they don't match, and if they get the password right, let's say in, like, three
1310490	1313610	attempts, you can allow them. However, if they get it wrong over three attempts, then
1313610	1317790	you can block them, too. So, basically, these are some of the solutions against the DOS
1317790	1324930	attacks, against these types of anti-brute force mechanisms. Okay, we're going to get
1324930	1334490	to cookie authentication. Cookies, everyone knows, this is UberEcker again, that cookies
1334490	1338370	are used a lot of times for authentication, you know, maybe not htaccess or something
1338370	1343030	like that, but cookies are used for authentication. Now, we're not going to get into all the different
1343030	1346730	kind of ways people are doing the authentication, but we're going to show you some of the basic
1346730	1351450	steps on how to increase the security of your cookie authentication that you're already
1351450	1357630	using. Use SSL for, these are very simple, use SSL for username and passwords, again,
1357630	1361710	no need for sniffer bait. Don't store plain text passwords or weakly encrypted passwords
1361710	1368010	in a cookie. Again, don't use ROT13 for passwords in cookies, that's very bad. Cookies are going
1368010	1372390	to get stolen. Now, there are just far too many ways this is going to happen, so you
1372390	1376310	have to remember this, cookies are going to get stolen, okay? You know, there's plenty
1376310	1381210	of IE bugs, there's plenty of cross-scripting exploits, cookies are going to get stolen.
1381810	1386830	It's too bad, it's sad, but it's going to happen. Now, if a cookie is compromised, two
1386830	1391310	things should not happen. The cookie should not be able to be reused or reused easily
1391310	1396430	by another person on another computer. The password should not, information from the
1396430	1401550	password should not be extracted that's confidential, okay? That's two very important things. If
1401650	1407550	a cookie is to be compromised, those two things should not happen. Also, cookie timeout.
1407550	1410550	Cookies should not be valid for an extended period of time. You know, time them out after
1410550	1416230	every 24 hours, no sense putting a validated cookie out there that's infinitely usable.
1417530	1423210	Now, how do you increase cookie security? Tie cookie authentication credentials to an
1423210	1427930	IP address. However, again, this is going to, you know, this is going to be tricky for
1428010	1434170	a lot of the AOL users and a lot of the SSL users. However, if you're on a small business
1434170	1438270	internet, maybe, you know, a few hundred people, you can tie the cookie to an IP address or
1438270	1442410	the authentication credential to an IP address without worry. You have to know your users.
1443490	1448070	If you're servicing the entire web, use a portion of the IP address, it's better than
1448070	1453610	nothing, okay? Now, this is an experimental security practice we've been working on, we've
1453610	1457550	seen other people try to work on it. They've had mixed results, so your mileage may vary.
1457870	1462870	You can actually add salt to your cookie authentication credentials by hashing in, like, an IE or
1462990	1466770	a Netscape user agent. It gives you a lot of salt. It gives you, like, system type,
1466770	1470830	it gives you browser version, things of that nature. So if you're tying it to an IP address,
1470830	1476290	the user agent, a stolen cookie moved is going to have a lot harder time being used by another
1476290	1483590	person. It's the basic trick. It's not limited to user agent and accept language. Any
1483590	1487110	header that stays constant within a browser can be used. So, again, you have to know your
1487110	1494820	users, you know, sniff the wire, look at your logs, and see what's going on. Further authentication
1494820	1512560	credentials. Yes. Oh, sure. Yes, it is. He said, basically, user agent and accept language
1512560	1517160	is spoofable. Yes, it is. However, if the user, let's say a legitimate user is logged
1517160	1523060	in, okay, the user agent and the accept language came over from the user, it's hashed up, MD5,
1523060	1527740	SHA1, whatever you want, with their password, wherever you want to do it. If somebody were
1527740	1532780	to compromise that cookie, they have no idea what that other user had or submitted to begin
1532780	1557340	with and they're not going to be able to reverse it if you use strong crypto mechanisms. The
1557340	1568500	question was, if he logs in from home and you log in from work, there might be conflict? Sure. Oh,
1568500	1571840	you're going to have to have logout mechanisms for that. If you stay logged in, you're going to
1571840	1579940	have trouble. You should provide logout mechanisms. Like I said, the session should not last forever.
1579940	1584060	There should be timeout. He asked about, you know, what if he upgrades his browser? Well,
1584060	1593000	the session cookie should not last forever. Right, so, I'm sorry, I missed that one. Yes,
1593000	1606250	please. Right, basically he said, if they can get the cookie, why can't they get the user agent?
1606410	1612290	Basically because, you can in JavaScript, but it's not foolproof. You know, let me just state
1612290	1615890	that. This is not foolproof. It's just increased. The level of skill of the attacker is going to
1615890	1633580	be a lot greater than your average person. Yes, please. Could you stand up, please? I'm like a
1633580	1642160	MAC address. All right, you could do that, but then, you know, you have key sharing. He basically
1642160	1649300	said, yeah, you can solve it on the server side, but again, we're not going to get to that level
1649300	1653800	yet. But again, this is not foolproof, but however, it is a lot better than a lot of things
1653800	1658540	where you can move a cookie from one computer over to another and clone that user. I mean,
1658540	1664420	imagine you can pop into any, you know, financial transaction, steal a cookie, and then you're them.
1664620	1668320	So basically, if you're just hashing in a little bit more data, it's going to be that much harder
1668320	1676560	for a person doing it. This is a new paper that came up from some people at MIT. It gives a lot
1677120	1682160	of... it's one main reason why we didn't go over different cookie authentication mechanisms. They
1682160	1687940	did an excellent job and pointed out some very good mechanisms that a lot of major sites are
1687940	1697700	using. So if you have need, go check it out. Session tickets and passwording. A lot of times,
1697700	1701340	when you're getting data from a web form or something from a user, you want to make sure
1701340	1706540	it's not tampered with. You know, you can use SSL for that and has not been sent fraudulently on
1706540	1712960	the behalf of a user. For instance, like a CGI action to delete a database or something. You
1712960	1718580	want to make sure that the user sending that actually did that purposely. So how do you do
1718580	1725320	that? Well, if the CGI is performing a particular critical action, have them reconfirm their
1725320	1731180	password. It's a real simple step. It buys you a lot of security. Have a yes or no button. Very
1731180	1736400	simple again. Yes, I did want to delete my entire domain off this web server. Instead of, like,
1736400	1741660	just basically sending a get request, they have to say yes or no. Very simple stuff. Entirely
1742300	1748960	underused out there. I can't stress the importance enough of this. Basically, if you know a user is
1748960	1754320	logged into, like, you know, any kind of service, any kind of message board, you send it to a chat
1754320	1759520	room or a message board administrator, you send them a personal message or some kind of message
1759520	1764340	and they read it, guess what? You can perform any action as them, at least for the moment. So
1764340	1770920	basically, if it's a critical action, say yes or no or a new password. Referrer checking. This is
1770920	1776520	something I don't recommend. This is entirely spoofable. However, if you know your users, this
1776520	1779920	can be done. Like, for instance, on a business internet, we're just going to kind of gloss over
1779920	1785360	this. But as far as referrers are concerned, don't trust client-side data. Okay, that's very
1785360	1793400	important. Get versus post. A lot of times the same results can be had from a CGI by using gets
1793400	1800000	and posts. If a form is, if the legitimate form is supposed to be being sent as a post request,
1800000	1804780	accept only post requests. This stops a lot of automated scripting because basically because
1804780	1810060	if you send like a cross-scripting exploit to someone, it's, and it sends like a get request,
1810060	1813540	it's going to, it sends a get request and not a post. So that way it buys you a little bit
1813540	1822100	more security by checking the request method. Off-domain hosting of user data. If you can't
1822100	1826360	control or if you don't want to control user data, host it on a different domain. Basically
1826360	1831580	if you're using, if you're hosting on like acme.com, host user data on acme.net. It might
1831580	1838900	be a little painful, however, it does buy you a lot of security. Now, the parts that I find most
1838900	1843540	interesting and most fun to screw around with. Filter bypassing. JavaScript is a cockroach.
1843540	1849540	It's hard to stamp out. There are all kinds of, you know, input filters in web applications that
1849540	1854080	try to prevent HTML and JavaScript from entering into a system. So this next section is basically
1854080	1860020	how do you audit, how do you beat HTML filters. A lot of data inside. Again, you don't have to
1860020	1868100	scribble it all down. It'll be available later. So basically what these exploits or methods show
1868100	1872740	is how to do, you know, cross-scripting exploits, browser hijacking. We've already kind of glossed
1872740	1878320	over how you can do some of those attacks. These are how to execute them. Testing the filters,
1878320	1882400	first of all, we're going to start real simple and work our way up pretty fast. If you're auditing your
1882400	1887080	own application, send as much HTML to it as you can, every single tag in the arsenal, with every
1887080	1892600	attribute you can find, and view the output and see what changed. Okay, it goes a long way towards
1892600	1900620	auditing. The script tag, you know, still very simple. Script tag, you can enter any JavaScript
1900620	1905400	expression, including document.cookie. This is important here. Anytime you can get like an alert
1905400	1913190	to show up in an environment, basically that's cause for alarm. Sourcing JavaScript protocol.
1913330	1918270	Basically, in Netscape, I don't think it works in IE, I have to double check,
1918270	1922750	the JavaScript protocol, and after the colon, you can execute any expression that you want.
1923110	1929430	The image that's source equals. Any tag that you can source has that problem. So you're going to
1929430	1936750	have to substitute the JavaScript string inside a source attribute. You know, just change it a
1936750	1940950	little bit. You can use the underscore, or you can erase a letter, or put a hyphen in it, whatever
1940950	1947830	you want, but you have to do something with it. So, again, any tag that has a source attribute,
1947830	1951630	you're going to have to put your pattern matching in and search for all the source attributes for
1951630	1956790	this type of thing. Even worse, LiveScript and Mocha achieved the same results in Netscape,
1956790	1961170	old Netscape codename throwback that still works to execute JavaScript. What you're going to find
1961170	1967130	in this, HTML is so loose that you can actually just totally manipulate and warp everything,
1967130	1971870	and things still execute, which is one of the good things about XML that it'll help out with.
1972670	1977130	Another one, the line breaks. Same thing, JavaScript and alert. Line break it,
1977130	1982930	and it'll probably beat the pattern match. Basically, if you visualize the regular expression,
1982930	1987930	it's going to be trying to match JavaScript as a string inside a source. However, if there's a
1987930	1990890	carriage return in it, it's not going to match, and it's just going to blow up, and that will
1990890	1997010	still execute. Oh, tabs, new lines, carriage returns in all whitespace count for this type
1997010	2005830	of thing. HTML entities, kind of a derivative of the previous one, using HTML entities to put
2005830	2011850	whitespace into the strings. This works, as well as the decimal, the hex, and multiple zeros in
2011850	2019720	front will all execute JavaScript expressions inside any source attribute. I call this and
2019720	2023320	curly. I don't know where this came from. I kind of saw it online. I was kind of screwing
2023320	2024620	around with it, but the syntax is very...
