WEBVTT

01:17.840 --> 01:19.340
Okay, I'm Jeremiah Grossman.

01:19.340 --> 01:20.400
This is Lex Arquette.

01:20.400 --> 01:22.980
We're going to be doing a talk on web application security.

01:24.280 --> 01:25.220
Thank you.

01:28.220 --> 01:30.820
This talk is going to be different from the one we did last year.

01:30.820 --> 01:36.200
There's going to be a lot more exploit theory and a lot more exploits and how to beat different CGI filters.

01:36.760 --> 01:42.480
Things that every CGI application is going to be exposed to, if not now, later.

01:42.480 --> 01:44.020
So, let's just start.

01:44.440 --> 01:45.560
A lot to cover.

01:46.380 --> 01:48.340
What is web application security?

01:48.640 --> 01:51.600
Simple enough, it's the securing of web applications.

01:52.060 --> 01:53.120
It's pretty simple.

01:53.380 --> 02:03.980
Web applications, they're used everywhere, you know, they transfer money within bank accounts, you know, message boards, web mail, I mean, you name it, there's a web application for it.

02:04.180 --> 02:13.560
And the security that we're going to be showing applies to them all because they're all taking user input and sit between a web server with a web interface.

02:13.580 --> 02:18.580
Anything that does that, anything that processes via a web server is a CGI and this is what we're going to be covering.

02:21.440 --> 02:38.140
The difference between software programming, at least from a security standpoint, is different from the way that before when you wrote an application, you know, on a LAN or, you know, maybe like ten years ago, the application that you write, the user base is relatively small.

02:38.140 --> 02:42.320
So, you didn't see as much abuse of the applications that you do now.

02:42.320 --> 02:57.300
Now, when a web developer or any kind of software engineer writes a program that's shipped via the web, everybody has access to it and there's going to be some people, a thousand people, they're going to have an infinite amount of time to mess it up, you know,

02:57.300 --> 03:00.680
throw whatever they can at it to make it screw up or do whatever they feel.

03:01.620 --> 03:10.900
So, some of the attacks when we're talking about web application security is browser hijacking, which means is an attacker threw a web page on the client side.

03:10.900 --> 03:13.780
It's important to realize what client side is when we talk about it.

03:13.900 --> 03:24.200
Client side is like when you're viewing a web page, somebody injects JavaScript via like a message board or something and takes control over your browser.

03:24.200 --> 03:29.920
Client side through like document dot location or closes your window and a million different abuses like that.

03:29.920 --> 03:32.780
There's also cookie theft and we'll get into cookie theft in a minute.

03:32.780 --> 03:45.020
There's server and client side compromise, shipping weird characters and input validation manipulation to get the server to give up more than it should or more access than it should.

03:45.260 --> 03:55.300
There's also denial of service where creativity within a web application exploit, you can actually render a site useless by no one is allowed to get there.

03:55.300 --> 03:57.780
Every time they go there, they're pushed away.

03:58.440 --> 04:08.300
There's also different abuse mechanisms like cheating on games or cheating on auctions or buying a laptop for $20 where you should have paid $2,000.

04:09.660 --> 04:12.140
And there's also user privacy invasion.

04:12.280 --> 04:19.600
The client side scripting applications give you tremendous amount of power and information about the user of which they execute.

04:19.760 --> 04:27.520
You'll get IP addresses, host names, subnets, user names, email addresses, system configurations, you name it.

04:27.520 --> 04:32.500
There's all kinds of data you can access with a client side script.

04:34.060 --> 04:36.360
So, let's get right to it.

04:36.360 --> 04:40.800
How to steal cookies because it seems like many people aren't too sure how it's done.

04:42.000 --> 04:48.420
Cookies are, the cookie security is, you know, according to the RFCs and different documentation you might read, they're restricted to domains.

04:48.420 --> 05:00.320
So when a cookie is set within a client, there is a domain that is attached to the cookie which the client should only send the cookie back to cookies within that domain.

05:00.420 --> 05:08.260
Cookies bleeding over into another domain is considered not good and that's a cookie theft and can lead to all types of user compromise.

05:09.340 --> 05:19.600
Basically how a cookie is stolen is by somebody injecting JavaScript or some kind of cookie thieving tool onto the domain that steals a cookie.

05:19.600 --> 05:27.640
So basically if you're a web administrator, you do not want to have uncontrolled web data on your domain or at least on a protected domain.

05:28.020 --> 05:34.460
So, I just use JavaScript, you know, you can do the same thing with VB scripts and a lot of other, you know, web application scripting languages.

05:34.800 --> 05:37.040
But we have the expression document.cookie.

05:37.240 --> 05:44.140
Basically that's just a string of the cookie data of the domain of which the script is executed on.

05:44.760 --> 06:02.320
Now what you can do here is with these following functions like window.open, document.image.source, you set window.open equals to attacker.com.cgi.bin pointed at your CGI and append the cookie data to it.

06:02.320 --> 06:10.100
What happens is the cookie data actually gets passed over a get connection or an HTTP post or get or whatever and you can actually pick it up off domain.

06:10.100 --> 06:16.080
So you're basically just moving strings around and using the power of HTML and JavaScript to move the cookie off the domain.

06:16.080 --> 06:17.480
So there's lots of ways to do it.

06:17.480 --> 06:23.840
You know, I've written utilities on it, but I've been hesitant to do it recently because I don't feel like a bunch of script kiddies need to be running around stealing everybody else's cookies.

06:27.950 --> 06:30.650
So, what are secure web programming practices?

06:30.750 --> 06:31.790
You'll hear this a lot.

06:31.790 --> 06:33.750
Do not trust client-side data.

06:33.850 --> 06:39.710
You'll understand more why later, but as a whole, you cannot trust anything coming from a client.

06:39.710 --> 06:42.650
You have to validate it, you have to sanity check it.

06:42.690 --> 06:44.050
You do not trust it.

06:45.730 --> 06:48.850
There's also hidden form elements are not hidden.

06:49.230 --> 06:55.430
If you put a price inside of like an online order form, they're not hidden.

06:56.270 --> 06:59.210
These are just common things that we see around.

06:59.350 --> 07:03.910
Password elements, still transferring clear text, just because you can't see it doesn't mean it's encrypted or anything.

07:04.590 --> 07:08.210
Use solid crypto when you're doing anything online.

07:08.650 --> 07:12.590
Don't use DoubleRot13, no matter how secure your friend thinks it is.

07:14.190 --> 07:19.530
Of course, stick to DES, triple DES, Blowfish, there's lots of good ones out there, but stick to the ones you know that have been proven.

07:20.530 --> 07:23.830
Avoid authentication mechanisms using JavaScript.

07:25.750 --> 07:34.230
Basically everything happens client-side using authentication via JavaScript, all the passwords or at least all the authentication credentials are going to be at your fingertips.

07:35.710 --> 07:45.710
Re-authenticate the user with a password before issuing new passwords, you know, just goes right towards like the Unix mindset, you know, they have to type in their own password before you issue new ones.

07:45.710 --> 07:54.250
You'd be surprised or maybe not so surprised how many sites allow you to change password just by manipulating some of the input fields to change a password once you have a stolen cookie.

07:55.270 --> 07:56.170
Let's see.

07:57.190 --> 08:01.210
Do not host uncontrolled data on a protected domain.

08:01.230 --> 08:06.690
I realize for some people doing this is hard, but as a general rule, try not to do this.

08:07.350 --> 08:17.450
Sanity check and qualify all incoming data and another great resource is the World Wide Web Security FAQ, if you haven't read it already.

08:17.870 --> 08:22.950
By the way, all this material will be available on whitehatsec.com probably Monday when we get home.

08:25.590 --> 08:28.570
These are the basic client-side scripting languages.

08:30.570 --> 08:31.810
There are a lot of them.

08:31.810 --> 08:33.470
This is not a finite list.

08:33.470 --> 08:34.430
There are more.

08:35.310 --> 08:42.290
We have DHTML, JavaScript, Java, Applets, VBScript, Flash, ActiveX, XML, and XSL.

08:42.550 --> 08:46.090
Getting to XML, most people are using on the backside right now.

08:46.090 --> 08:56.110
However, browsers are supporting it on the client side and when you get to some of the security issues about XML and XSL and Microsoft.net at the end.

08:56.250 --> 08:57.930
And there's also CSS.

08:58.530 --> 09:00.970
We have the document object model.

09:01.330 --> 09:11.950
Basically, this is like the object-oriented model for HTML and JavaScript to access different functions and features and information within the browser.

09:12.350 --> 09:23.950
Basically, with all these client-side scripting languages, all their complexities, all the different things they can do can be combined to gain increased access to the DOM, which they really shouldn't.

09:25.930 --> 09:32.850
Basically, you can get background colors, you can get files, and you can even execute system calls.

09:36.760 --> 09:43.260
Okay, if you're running a web application, or at least with some kind of complexity, you're going to be taking input from the user.

09:43.500 --> 09:46.160
So again, never trust client-side data.

09:46.660 --> 09:50.080
Escape, validate, parse, filter, and sanity check all data.

09:50.400 --> 09:51.540
All of it.

09:51.540 --> 09:55.180
Not just like the ones where they're typing in like a search field.

09:55.200 --> 09:56.480
Get the hidden ones.

09:56.480 --> 09:59.100
Everything coming over has to be checked.

10:00.840 --> 10:03.020
With client-side data, you can never be too paranoid.

10:03.020 --> 10:04.600
Let your paranoia be your guide.

10:06.220 --> 10:07.560
Let's see, common input.

10:07.780 --> 10:08.660
Mistakes.

10:10.020 --> 10:11.580
Sanity check all input.

10:12.940 --> 10:31.460
When I say sanity checking, a lot of CGI's that we find, like, for instance, the yes or no, we find that a lot of times, you know, the pull-down menu says yes or no, but we can actually add like a nothing or some other string in there to cause panic within or an error within the web application.

10:31.500 --> 10:39.540
So for instance, if you're using a numeric value or a yes or no, check the input for what you're expecting and ditch the rest.

10:39.540 --> 10:40.520
Escape it.

10:40.780 --> 10:45.200
Don't be just taking in whatever you want or whatever they send to you.

10:45.380 --> 10:47.180
Same goes for file names, paths.

10:47.260 --> 10:50.860
Don't parse and especially don't use what you don't know.

10:53.380 --> 10:55.660
Escape all input special characters.

10:58.400 --> 11:08.340
So it's important to understand that special characters have a lot of meanings on a lot of different operating systems where it's piping, redirecting, semi-colons, stars, file-globbing.

11:08.580 --> 11:15.380
Special characters can do a lot to your system so they all have to be escaped or replaced or something has to happen to them.

11:15.380 --> 11:18.940
Preferably, if you need to use special characters, escape them.

11:18.940 --> 11:20.760
If you don't, remove them.

11:21.140 --> 11:23.060
And null characters is very important.

11:23.060 --> 11:32.140
Null characters don't belong in, should not come over the wire unless there are some really weird circumstances, but they all should be ripped out completely.

11:35.290 --> 11:44.740
If you have need to allow HTML into your site, however it's not supposed to execute, use these little guidelines so it doesn't.

11:44.740 --> 11:49.720
Basically, you just want to convert the less than and greater than signs and the quotes into HTML entities.

11:49.720 --> 11:51.560
It's real simple, very important though.

11:51.560 --> 11:57.240
Everything from file not founds to search fields to search errors.

11:59.520 --> 12:07.520
A few other things that you got to watch out for, you know, the directory transversals, the file-globbing, appending commands.

12:07.860 --> 12:18.580
We find a lot of times registering for, for instance, like a mailing list or something, you type in your email address and it auto-responds, it'll just do a quick send mail, send mail to this email address.

12:18.880 --> 12:25.640
Well, pipe a semi-colon on and execute another command, cat direct etc password and you got it.

12:27.860 --> 12:36.240
Data piping, quotes are, quotes can do a lot of damage, especially when you're using fixed strings like in a sequel and things like that.

12:36.240 --> 12:40.680
So if you're not wanting these, you know, strip them out or escape them.

12:42.100 --> 12:45.100
Output filtering a lot of times is ignored.

12:46.040 --> 12:58.020
Output filter queries from a database, for instance, somebody might be updating their profile information and put a lot of nice, a lot of little cool HTML and stuff and they go, hey, see my profile.

12:58.020 --> 13:04.680
So, does a query, ships it back to the person that saw and there's XML or HTML executing on the client side.

13:04.680 --> 13:06.760
So you have to output filter as well as input filter.

13:08.560 --> 13:16.080
And if you want to take a quick note, here's some other good CGI examples that give a lot of, a lot of really good data.

13:19.250 --> 13:20.890
HTML is dangerous.

13:21.150 --> 13:27.910
You know, it's, you know, it seems light, loose, everybody uses it, but it is dangerous, especially for web applications or client side security.

13:28.750 --> 13:38.130
If your system, if it's web mail, message boards or whatever, if it's using HTML input from users, it's very hard to get it secure.

13:38.410 --> 13:42.050
Even when the proper precautions are taken, it's very hard to lock it down.

13:42.790 --> 13:47.530
So the best way I could suggest to lock it down is use allow permit lists.

13:47.950 --> 13:54.030
Know what HTML you want your users to be able to send in and only allow those.

13:54.030 --> 13:55.670
This goes for attributes too.

13:56.610 --> 13:58.390
Also, let's see.

14:00.010 --> 14:08.070
Yeah, limit your lists, keep them short, know what they are, and know what attributes and tags are harmful so you don't put them on your allow list.

14:08.070 --> 14:09.910
We'll get to the list in a second.

14:10.450 --> 14:11.330
Well, there it is.

14:11.330 --> 14:16.190
So these are the common tags that are known to be dangerous for various reasons.

14:16.190 --> 14:19.570
Applet, you can input Java and gain a lot of access.

14:20.010 --> 14:22.110
Image, inline images can grab cookies.

14:22.130 --> 14:24.130
Layers, you can source in other data.

14:24.290 --> 14:29.050
You know, object, ActiveX controls.

14:29.910 --> 14:32.550
Style and script are pretty self-explanatory.

14:33.030 --> 14:43.850
But these are basically the tags that are known to be dangerous that every system allowing HTML has danger inherent when they are allowing these tags.

14:43.990 --> 14:49.270
Any tags with attributes that have style, source, href, or type are also at risk.

14:49.270 --> 14:52.530
So you have to watch out for these attributes in any tag that allows them.

14:55.210 --> 14:58.050
Now we're going to get a bit into user authentication.

15:04.650 --> 15:10.790
Web applications a lot of times have need to authenticate the user, whether it's username and password or persistent cookies and that nature.

15:10.790 --> 15:15.810
So we're going to get... go into a lot of things in that nature that we see out there.

15:16.370 --> 15:20.330
And some guidelines to help out people so they know what to do and what not to do.

15:21.330 --> 15:24.530
Passwords, as a general rule, are your user's weakest link.

15:24.530 --> 15:27.290
Users are always picking easy passwords.

15:27.290 --> 15:29.370
Users are always giving up their passwords.

15:29.610 --> 15:32.650
So, never store passwords in plain text.

15:32.670 --> 15:33.870
Age all passwords.

15:33.870 --> 15:42.010
It's very important that passwords, at least at a given amount of time, they die or they invalidate themselves.

15:42.010 --> 15:43.050
Age all passwords.

15:43.050 --> 15:45.750
Otherwise, make sure good system maintenance.

15:45.750 --> 15:52.850
So you don't have a password that's on the system for about, you know, six years and you forgot about and somebody can still log in or steal it.

15:53.090 --> 15:55.090
Age them and deny them.

15:55.330 --> 15:58.610
Password restrictions, we'll get to that next.

15:59.210 --> 16:00.530
General guidelines.

16:00.730 --> 16:04.090
Passwords should be, at least in my opinion, should be six letters in length.

16:04.090 --> 16:05.870
Six letters in length.

16:05.870 --> 16:07.570
Not matching the username.

16:08.070 --> 16:11.950
And not a common password and contains one capital letter.

16:11.950 --> 16:16.210
It's a very simple password, but however, it gets a decent amount of security.

16:16.410 --> 16:24.170
Now, a lot of usability experts and security people have different mindsets on it as far as usability versus security.

16:24.710 --> 16:31.070
This should, for the most part, secure your passwords to at least a minimum level.

16:31.170 --> 16:33.330
You know, it's better than password being password.

16:33.910 --> 16:37.790
If they have to have password as their password, make it a capital P with a 1 at the end.

16:40.050 --> 16:41.910
Passwords should be six letters in length.

16:42.310 --> 16:47.610
For an increased security, passwords should be six letters in length, not matching the username or part of it.

16:47.610 --> 16:50.910
Not a common password and must contain one capital and one special character.

16:51.110 --> 16:52.230
This is pretty good.

16:52.230 --> 16:55.970
This would be pretty hard to crack, at least on a brute force level on a web basis.

16:56.830 --> 16:58.850
Again, let your paranoia be your guide.

17:00.070 --> 17:01.050
What not to do.

17:01.050 --> 17:02.830
Now, we see this out there a lot.

17:03.490 --> 17:05.590
Placing a maximum password length.

17:05.770 --> 17:07.130
Okay, don't do that.

17:07.610 --> 17:11.810
I've seen places where they're allowing like, you know, no passwords over 4 or 5 characters.

17:11.810 --> 17:13.330
Now, how long does that take to crack?

17:15.590 --> 17:18.010
Passwords that are allowed to be changed into the old ones.

17:18.010 --> 17:19.650
So, let's say you're doing aging.

17:19.750 --> 17:23.110
Don't let your users change their password into the current password.

17:23.110 --> 17:24.050
Check for that.

17:27.960 --> 17:34.620
A lot of sites we've seen, well, maybe not a lot, but it does happen, echo the new password that they typed in over a non-SSL link.

17:34.620 --> 17:35.920
No need for sniffer bait.

17:37.360 --> 17:38.780
Password restrictions are too high.

17:38.780 --> 17:40.980
This is kind of like a sticky point.

17:40.980 --> 17:44.980
You can make your password restrictions pretty high for, you know, most competent users.

17:44.980 --> 17:48.420
But if you make them like too high, like, you know, really, really high.

17:54.550 --> 17:55.010
Both.

17:55.010 --> 17:55.830
These are like general guides.

17:55.830 --> 17:58.430
You can actually adapt these to a lot of secure programming.

17:59.670 --> 18:01.750
Making password restrictions too high.

18:03.930 --> 18:05.790
What happens if you make a password too high?

18:05.790 --> 18:08.730
You know, they're typing upper and lower case and numbers and symbols and stuff.

18:09.210 --> 18:15.230
Users are, at least on like a web sense when you're dealing with like a, you know, 50 million users or 30 million users or what have you.

18:15.450 --> 18:18.910
They're going to write down their password and stick it on a sticky note and put it on their monitor.

18:19.190 --> 18:21.930
So, you know, so you have to walk that line.

18:21.930 --> 18:26.510
You want to make it secure, yes, but not too secure where they're tempted to do stupid things.

18:29.110 --> 18:30.350
Okay, brute force attacks.

18:30.350 --> 18:32.590
We're going to go real quick over this because this is Uber Hacker.

18:32.590 --> 18:34.030
You guys should be all aware of this stuff.

18:35.730 --> 18:42.710
Brute force in a web account, web accounts, there's two main attacks, at least from like a web sense, for instance, like, you know, banking and stuff like that.

18:42.710 --> 18:49.890
One user name against many passwords or less common but very effective, one password against many usernames.

18:49.890 --> 18:58.470
So some systems, if they don't have password restrictions, pick the password password and level it against 1,000 user accounts and you're probably going to crack a couple.

18:59.390 --> 19:03.390
Each attack can be very effective and both must be defended against.

19:03.970 --> 19:08.230
We're going to state some defense mechanisms against it.

19:08.830 --> 19:11.830
So how do you defend your web apps against brute force?

19:12.110 --> 19:23.710
Set an acceptable threshold of the amount of failed attempts a single account can receive before that offender is blocked at an IP level, because you don't want to keep doing it, and the account itself is locked.

19:24.090 --> 19:27.330
Same thing goes for multiple accounts from the same IP.

19:27.630 --> 19:32.830
Okay, when an IP set, you know, goes over like 10 failed attempts, you have to block them.

19:32.990 --> 19:38.010
Okay, so for instance, like on the reverse brute force, a single account isn't going to get like 10 attempts.

19:38.690 --> 19:43.410
10 attempts, however, you still want to block the IP.

19:43.450 --> 19:47.550
Now a lot of people are thinking like, you know, wait a minute, there's like DOS attacks regarding this, right?

19:47.550 --> 19:56.750
Like, for instance, if, you know, somebody's, two people are competing at an auction, you know, and I want to win, so I'm going to lock my opponent's account so he can't make a bid.

19:56.770 --> 19:59.070
So where to get to the point?

20:00.230 --> 20:01.190
Did you guys get that?

20:01.190 --> 20:02.370
I'll say that one more time.

20:02.370 --> 20:15.370
So let's say I'm, you know, I like this Dell laptop and I want to get another, so I log on to my favorite auction, and there's a bid war, you know, going up and up and up and up, and I'm sick of having to, you know, bid-bask my opponent.

20:15.370 --> 20:24.170
So what I do is, I sent, I knowingly send 10 failed attempts against his account, and now he can't bid, and I win.

20:24.170 --> 20:31.190
So, however, like, one second, yes please.

20:35.030 --> 20:37.750
He asked about proxied users, we'll get to that in a second.

20:39.090 --> 20:39.650
Okay.

20:41.390 --> 20:45.750
So, now, there's DOS attacks against these systems, as I just said.

20:45.950 --> 20:53.350
Basically if an attacker wanted to DOS an account, he could, because he doesn't really care about cracking the account, he just wants to block the user, many abuses in this regard.

20:53.830 --> 21:02.250
Now, also as a result from IP blocking, AOL and proxied users are blocked also, because they're amassed behind like a single subnet.

21:02.850 --> 21:03.890
Know your users.

21:03.890 --> 21:10.710
If you're in a restricted environment, you can IP block without restriction.

21:10.710 --> 21:20.010
However, if you're, like, servicing the entire web, you're going to have to make allowances for proxy users and AOL users, so, you know, basically, you can't block AOL.

21:20.010 --> 21:23.650
So, basically, you just have to set the rules, then, that you can't block AOL.

21:25.590 --> 21:26.390
Bummer!

21:28.910 --> 21:30.190
Possible solutions.

21:30.530 --> 21:33.610
When blocking an account, log the offending IP with the account block.

21:33.710 --> 21:47.630
Now, what happens is, if the legitimate user logs on to the account, and the system is going, okay, this account's blocked, but I want to take, I want to do a comparison against the new requesting IP and the one that was the original offending one.

21:47.630 --> 21:51.830
If they don't match, and if they get the password right, let's say in, like, three attempts, you can allow them.

21:52.090 --> 21:54.790
However, if they get it wrong over three attempts, then you can block them, too.

21:54.810 --> 22:02.110
So, basically, these are some of the solutions against the DOS attacks, against these types of anti-brute force mechanisms.

22:04.250 --> 22:06.210
Okay, we're going to get to cookie authentication.

22:11.630 --> 22:20.270
Cookies, everyone knows, this is UberEcker again, that cookies are used a lot of times for authentication, you know, maybe not htaccess or something like that, but cookies are used for authentication.

22:21.330 --> 22:32.150
Now, we're not going to get into all the different kind of ways people are doing the authentication, but we're going to show you some of the basic steps on how to increase the security of your cookie authentication that you're already using.

22:33.670 --> 22:39.150
Use SSL for, these are very simple, use SSL for username and passwords, again, no need for sniffer bait.

22:39.430 --> 22:42.550
Don't store plain text passwords or weakly encrypted passwords in a cookie.

22:42.570 --> 22:46.350
Again, don't use ROT13 for passwords in cookies, that's very bad.

22:47.330 --> 22:49.070
Cookies are going to get stolen.

22:49.330 --> 22:55.390
Now, there are just far too many ways this is going to happen, so you have to remember this, cookies are going to get stolen, okay?

22:55.510 --> 23:01.210
You know, there's plenty of IE bugs, there's plenty of cross-scripting exploits, cookies are going to get stolen.

23:01.810 --> 23:04.690
It's too bad, it's sad, but it's going to happen.

23:05.270 --> 23:08.190
Now, if a cookie is compromised, two things should not happen.

23:08.510 --> 23:13.410
The cookie should not be able to be reused or reused easily by another person on another computer.

23:13.890 --> 23:20.130
The password should not, information from the password should not be extracted that's confidential, okay?

23:20.130 --> 23:21.470
That's two very important things.

23:21.470 --> 23:25.710
If a cookie is to be compromised, those two things should not happen.

23:26.030 --> 23:27.550
Also, cookie timeout.

23:27.550 --> 23:29.850
Cookies should not be valid for an extended period of time.

23:29.850 --> 23:36.230
You know, time them out after every 24 hours, no sense putting a validated cookie out there that's infinitely usable.

23:37.530 --> 23:39.530
Now, how do you increase cookie security?

23:41.510 --> 23:44.190
Tie cookie authentication credentials to an IP address.

23:44.490 --> 23:51.530
However, again, this is going to, you know, this is going to be tricky for a lot of the AOL users and a lot of the SSL users.

23:52.410 --> 24:00.870
However, if you're on a small business internet, maybe, you know, a few hundred people, you can tie the cookie to an IP address or the authentication credential to an IP address without worry.

24:00.870 --> 24:02.410
You have to know your users.

24:03.490 --> 24:09.690
If you're servicing the entire web, use a portion of the IP address, it's better than nothing, okay?

24:10.870 --> 24:15.290
Now, this is an experimental security practice we've been working on, we've seen other people try to work on it.

24:15.290 --> 24:17.550
They've had mixed results, so your mileage may vary.

24:17.870 --> 24:24.270
You can actually add salt to your cookie authentication credentials by hashing in, like, an IE or a Netscape user agent.

24:24.270 --> 24:25.550
It gives you a lot of salt.

24:25.550 --> 24:29.410
It gives you, like, system type, it gives you browser version, things of that nature.

24:29.410 --> 24:37.090
So if you're tying it to an IP address, the user agent, a stolen cookie moved is going to have a lot harder time being used by another person.

24:37.830 --> 24:39.370
It's the basic trick.

24:41.110 --> 24:43.410
It's not limited to user agent and accept language.

24:43.410 --> 24:46.290
Any header that stays constant within a browser can be used.

24:46.290 --> 24:50.670
So, again, you have to know your users, you know, sniff the wire, look at your logs, and see what's going on.

24:53.940 --> 24:55.800
Further authentication credentials.

24:56.960 --> 24:57.540
Yes.

24:58.980 --> 25:00.220
Oh, sure.

25:04.820 --> 25:05.820
Yes, it is.

25:10.300 --> 25:13.520
He said, basically, user agent and accept language is spoofable.

25:13.520 --> 25:14.100
Yes, it is.

25:14.100 --> 25:26.800
However, if the user, let's say a legitimate user is logged in, okay, the user agent and the accept language came over from the user, it's hashed up, MD5, SHA1, whatever you want, with their password, wherever you want to do it.

25:27.040 --> 25:36.200
If somebody were to compromise that cookie, they have no idea what that other user had or submitted to begin with and they're not going to be able to reverse it if you use strong crypto mechanisms.

25:56.900 --> 26:02.160
The question was, if he logs in from home and you log in from work, there might be conflict?

26:04.100 --> 26:04.860
Sure.

26:08.040 --> 26:10.300
Oh, you're going to have to have logout mechanisms for that.

26:10.300 --> 26:12.460
If you stay logged in, you're going to have trouble.

26:12.460 --> 26:14.260
You should provide logout mechanisms.

26:17.720 --> 26:19.940
Like I said, the session should not last forever.

26:19.940 --> 26:21.020
There should be timeout.

26:21.320 --> 26:23.940
He asked about, you know, what if he upgrades his browser?

26:23.940 --> 26:26.440
Well, the session cookie should not last forever.

26:28.820 --> 26:31.540
Right, so, I'm sorry, I missed that one.

26:32.760 --> 26:33.480
Yes, please.

26:40.670 --> 26:46.250
Right, basically he said, if they can get the cookie, why can't they get the user agent?

26:46.410 --> 26:51.610
Basically because, you can in JavaScript, but it's not foolproof.

26:51.610 --> 26:52.470
You know, let me just state that.

26:52.470 --> 26:53.330
This is not foolproof.

26:53.330 --> 26:54.230
It's just increased.

26:54.230 --> 26:58.430
The level of skill of the attacker is going to be a lot greater than your average person.

26:59.430 --> 27:00.250
Yes, please.

27:06.930 --> 27:08.730
Could you stand up, please?

27:12.800 --> 27:14.300
I'm like a MAC address.

27:18.620 --> 27:21.360
All right, you could do that, but then, you know, you have key sharing.

27:21.560 --> 27:29.620
He basically said , yeah, you can solve it on the server side, but again, we're not going to get to that level yet .

27:29.720 --> 27:38.360
But again, this is not foolproof, but however, it is a lot better than a lot of things where you can move a cookie from one computer over to another and clone that user.

27:38.360 --> 27:44.420
I mean, imagine you can pop into any, you know, financial transaction, steal a cookie, and then you're them.

27:44.620 --> 27:49.560
So basically, if you're just hashing in a little bit more data, it's going to be that much harder for a person doing it.

27:51.380 --> 27:55.660
This is a new paper that came up from some people at MIT.

27:56.160 --> 28:01.740
It gives a lot of... it's one main reason why we didn't go over different cookie authentication mechanisms.

28:01.800 --> 28:08.320
They did an excellent job and pointed out some very good mechanisms that a lot of major sites are using.

28:08.320 --> 28:10.880
So if you have need, go check it out.

28:13.220 --> 28:14.920
Session tickets and passwording.

28:16.480 --> 28:22.540
A lot of times, when you're getting data from a web form or something from a user, you want to make sure it's not tampered with.

28:22.540 --> 28:27.540
You know, you can use SSL for that and has not been sent fraudulently on the behalf of a user.

28:27.540 --> 28:32.760
For instance, like a CGI action to delete a database or something.

28:32.760 --> 28:37.080
You want to make sure that the user sending that actually did that purposely.

28:37.840 --> 28:39.180
So how do you do that?

28:39.520 --> 28:45.880
Well, if the CGI is performing a particular critical action, have them reconfirm their password.

28:45.880 --> 28:47.120
It's a real simple step.

28:47.180 --> 28:49.100
It buys you a lot of security.

28:49.760 --> 28:50.960
Have a yes or no button.

28:50.960 --> 28:52.140
Very simple again.

28:52.320 --> 28:55.200
Yes, I did want to delete my entire domain off this web server.

28:55.260 --> 28:59.620
Instead of, like, just basically sending a get request, they have to say yes or no.

28:59.780 --> 29:01.060
Very simple stuff.

29:01.260 --> 29:03.480
Entirely underused out there.

29:05.440 --> 29:07.320
I can't stress the importance enough of this.

29:07.320 --> 29:21.340
Basically, if you know a user is logged into, like, you know, any kind of service, any kind of message board, you send it to a chat room or a message board administrator, you send them a personal message or some kind of message and they read it, guess what?

29:21.360 --> 29:23.940
You can perform any action as them, at least for the moment.

29:24.140 --> 29:28.260
So basically, if it's a critical action, say yes or no or a new password.

29:29.780 --> 29:30.620
Referrer checking.

29:30.620 --> 29:32.120
This is something I don't recommend.

29:32.120 --> 29:33.500
This is entirely spoofable.

29:33.500 --> 29:37.100
However, if you know your users, this can be done.

29:37.100 --> 29:40.520
Like, for instance, on a business internet, we're just going to kind of gloss over this.

29:40.520 --> 29:44.580
But as far as referrers are concerned, don't trust client-side data.

29:44.840 --> 29:46.080
Okay, that's very important.

29:47.540 --> 29:48.800
Get versus post.

29:49.060 --> 29:54.160
A lot of times the same results can be had from a CGI by using gets and posts.

29:54.160 --> 30:01.880
If a form is, if the legitimate form is supposed to be being sent as a post request, accept only post requests.

30:01.980 --> 30:12.460
This stops a lot of automated scripting because basically because if you send like a cross-scripting exploit to someone, it's, and it sends like a get request, it's going to, it sends a get request and not a post.

30:12.460 --> 30:16.380
So that way it buys you a little bit more security by checking the request method.

30:18.280 --> 30:20.700
Off-domain hosting of user data.

30:21.100 --> 30:25.980
If you can't control or if you don't want to control user data, host it on a different domain.

30:26.060 --> 30:31.140
Basically if you're using, if you're hosting on like acme.com, host user data on acme.net.

30:31.140 --> 30:34.160
It might be a little painful, however, it does buy you a lot of security.

30:35.680 --> 30:41.120
Now, the parts that I find most interesting and most fun to screw around with.

30:41.120 --> 30:41.980
Filter bypassing.

30:41.980 --> 30:43.540
JavaScript is a cockroach.

30:43.540 --> 30:44.820
It's hard to stamp out.

30:46.120 --> 30:52.580
There are all kinds of, you know, input filters in web applications that try to prevent HTML and JavaScript from entering into a system.

30:52.580 --> 30:57.980
So this next section is basically how do you audit, how do you beat HTML filters.

30:58.020 --> 30:59.320
A lot of data inside.

30:59.320 --> 31:01.120
Again, you don't have to scribble it all down.

31:01.120 --> 31:02.380
It'll be available later.

31:03.460 --> 31:11.240
So basically what these exploits or methods show is how to do, you know, cross-scripting exploits, browser hijacking.

31:11.240 --> 31:14.380
We've already kind of glossed over how you can do some of those attacks.

31:14.380 --> 31:15.960
These are how to execute them.

31:17.420 --> 31:21.120
Testing the filters, first of all, we're going to start real simple and work our way up pretty fast.

31:21.480 --> 31:30.600
If you're auditing your own application, send as much HTML to it as you can, every single tag in the arsenal, with every attribute you can find, and view the output and see what changed.

31:30.780 --> 31:33.360
Okay, it goes a long way towards auditing.

31:35.780 --> 31:39.280
The script tag, you know, still very simple.

31:39.280 --> 31:42.800
Script tag, you can enter any JavaScript expression, including document.cookie.

31:43.040 --> 31:44.080
This is important here.

31:44.080 --> 31:48.700
Anytime you can get like an alert to show up in an environment, basically that's cause for alarm.

31:51.370 --> 31:53.190
Sourcing JavaScript protocol.

31:53.330 --> 32:02.750
Basically, in Netscape, I don't think it works in IE, I have to double check, the JavaScript protocol, and after the colon, you can execute any expression that you want.

32:03.110 --> 32:04.730
The image that's source equals.

32:04.790 --> 32:09.010
Any tag that you can source has that problem.

32:09.010 --> 32:15.610
So you're going to have to substitute the JavaScript string inside a source attribute.

32:15.690 --> 32:17.170
You know, just change it a little bit.

32:17.170 --> 32:23.990
You can use the underscore, or you can erase a letter, or put a hyphen in it, whatever you want, but you have to do something with it.

32:24.170 --> 32:32.690
So, again, any tag that has a source attribute, you're going to have to put your pattern matching in and search for all the source attributes for this type of thing.

32:33.230 --> 32:40.390
Even worse, LiveScript and Mocha achieved the same results in Netscape, old Netscape codename throwback that still works to execute JavaScript.

32:40.650 --> 32:51.870
What you're going to find in this, HTML is so loose that you can actually just totally manipulate and warp everything, and things still execute, which is one of the good things about XML that it'll help out with.

32:52.670 --> 32:54.530
Another one, the line breaks.

32:54.530 --> 32:56.290
Same thing, JavaScript and alert.

32:56.290 --> 32:58.850
Line break it, and it'll probably beat the pattern match.

32:59.970 --> 33:06.570
Basically, if you visualize the regular expression, it's going to be trying to match JavaScript as a string inside a source.

33:06.790 --> 33:12.050
However, if there's a carriage return in it, it's not going to match, and it's just going to blow up, and that will still execute.

33:12.750 --> 33:17.870
Oh, tabs, new lines, carriage returns in all whitespace count for this type of thing.

33:18.750 --> 33:27.350
HTML entities, kind of a derivative of the previous one, using HTML entities to put whitespace into the strings.

33:27.690 --> 33:35.950
This works, as well as the decimal, the hex, and multiple zeros in front will all execute JavaScript expressions inside any source attribute.

33:38.600 --> 33:40.300
I call this and curly.

33:40.560 --> 33:41.800
I don't know where this came from.

33:41.800 --> 33:42.820
I kind of saw it online.

33:42.820 --> 33:44.620
I was kind of screwing around with it, but the syntax is very...

