1 00:00:00,120 --> 00:00:03,420 Let's quickly talk about preventing cross site scripting. 2 00:00:03,420 --> 00:00:06,150 So how might we prevent cross-eyed scripting. 3 00:00:06,150 --> 00:00:09,550 Well there's a few different ways and this isn't even everything. 4 00:00:09,570 --> 00:00:10,860 Well let's talk about this. 5 00:00:11,280 --> 00:00:20,010 So first we have encoding now encoding is converting a control character to its escape sequence. 6 00:00:20,040 --> 00:00:20,330 OK. 7 00:00:20,340 --> 00:00:30,080 So for example here you see that we have the less than symbol becomes the ampersand L T and then a semicolon. 8 00:00:30,090 --> 00:00:38,730 So if we had script then script would just become Ampersand LTE semicolons script etc. you see the example. 9 00:00:39,630 --> 00:00:39,960 OK. 10 00:00:39,990 --> 00:00:41,470 So we're doing that. 11 00:00:41,490 --> 00:00:50,160 So that these symbols are not interpreted for like example an Excel tag or in this situation the script 12 00:00:50,160 --> 00:00:51,050 itself. 13 00:00:51,120 --> 00:00:52,350 You just can't interpret it. 14 00:00:52,380 --> 00:00:54,480 We can't use that character anymore. 15 00:00:54,510 --> 00:00:55,260 Right. 16 00:00:55,300 --> 00:00:58,170 And that's a very common way of doing things. 17 00:00:58,170 --> 00:01:06,090 Another thing is filtering so where you just take script and you strip out everything and anything and 18 00:01:06,090 --> 00:01:07,380 then just becomes script. 19 00:01:07,380 --> 00:01:12,700 So any of those characters that you don't want in there they just get wiped out basically. 20 00:01:12,870 --> 00:01:13,550 Right. 21 00:01:13,560 --> 00:01:15,060 So we say hey we don't want that. 22 00:01:15,060 --> 00:01:16,590 We're going to take it out. 23 00:01:16,680 --> 00:01:19,410 Another one is validating. 24 00:01:19,470 --> 00:01:25,800 So that's comparing inputting it's like a white list or a set of known good numbers. 25 00:01:25,800 --> 00:01:30,740 Say for example you have an account number and you type in the account number well if the account number 26 00:01:30,740 --> 00:01:36,960 is not in a set of known good numbers then it's not going to validate and it's going to prevent that 27 00:01:36,960 --> 00:01:42,910 from even reaching server side right or reaching an attack level. 28 00:01:42,930 --> 00:01:47,790 And then lastly there's sanitization which is basically a combination of everything and that's really 29 00:01:47,790 --> 00:01:54,660 what you're after is this combination of encoding filtering validating and making sure that this malicious 30 00:01:54,930 --> 00:02:03,690 activity and malicious code cannot be injected into your Web site so special note goes out to the H 31 00:02:03,690 --> 00:02:05,490 TTP only flag. 32 00:02:05,520 --> 00:02:10,170 So if you've been paying attention and birth sweet and looking at your cookies when your cookies get 33 00:02:10,170 --> 00:02:15,810 set a cookie can have an HP only flag and a secure flag. 34 00:02:15,810 --> 00:02:23,400 We're curious more for cross site scripting about the TTP only flag because its purpose is to prevent 35 00:02:23,400 --> 00:02:27,880 cookies from actually being observed by unauthorized parties. 36 00:02:27,930 --> 00:02:28,370 OK. 37 00:02:28,380 --> 00:02:35,580 So what that means is if we do a javascript and we try to steal cookie via javascript if we have the 38 00:02:35,610 --> 00:02:39,400 HP only flag we're not going to be able to see that cookie. 39 00:02:39,450 --> 00:02:40,560 We'll steal that cookie. 40 00:02:41,160 --> 00:02:44,300 So that will also help prevent this. 41 00:02:44,310 --> 00:02:47,250 So there's a bunch of different things that we can do and help guide this long. 42 00:02:47,250 --> 00:02:53,040 There's also headers out there that are a cross site scripting best practice headers that we can utilize 43 00:02:53,040 --> 00:02:54,650 to help prevent this as well. 44 00:02:54,720 --> 00:02:59,670 A lot of modern browsers are starting to help out here and prevent these. 45 00:02:59,670 --> 00:03:06,150 So this is a very very common exploit that you see and I would say out of all the things I have found 46 00:03:06,150 --> 00:03:15,200 the most bugs on it's probably cross site scripting level would be up there on the number one for me. 47 00:03:15,240 --> 00:03:17,450 So you'll see this all the time. 48 00:03:17,940 --> 00:03:20,370 So that is it for cross-eyed scripting. 49 00:03:20,370 --> 00:03:27,120 Hopefully you learned a bit here and you know you just take away the big takeaways are what it does 50 00:03:27,150 --> 00:03:35,340 why it's malicious and the three types of cross-eyed scripting which are reflected stored and done based. 51 00:03:35,340 --> 00:03:41,880 So from here we're going to talk a high level of insecure D serialization in the next video which is 52 00:03:41,880 --> 00:03:43,590 number eight on our list. 53 00:03:43,590 --> 00:03:47,340 We've only got three more to go so I will see over in the next video.