00:00:00.500 --> 00:00:04.004 Welcome to the game of hacks. >> Hi everyone. Hi guys. So this is 00:00:04.004 --> 00:00:10.010 myself first talk at DEF CON so go sees see on me, okay. So, 00:00:26.393 --> 00:00:30.464 we're going to talk about something called game of action 00:00:30.464 --> 00:00:36.169 some of you may know it other may not. Were going to dig into 00:00:36.169 --> 00:00:41.041 more details about the platform. In terms of the agenda we are 00:00:41.041 --> 00:00:45.946 going to start by understanding what game of HACK s'es what we 00:00:45.946 --> 00:00:52.052 made it to be what's behind it. We are going to have a type of 00:00:52.052 --> 00:00:58.258 T-shirt contest not really going to be a wet T-shirt contest so 00:00:58.258 --> 00:01:05.565 no need for water. After that, we're going to talk about 00:01:05.565 --> 00:01:11.305 [indiscernible] which the platform is based on OJS and 00:01:11.305 --> 00:01:15.409 just a few take a ways. Regarding the game anyone who 00:01:15.409 --> 00:01:18.679 has internet connection don't worry we are not going to HACK 00:01:18.679 --> 00:01:22.749 you just want to have you participate in the game ten 00:01:22.749 --> 00:01:27.854 first places are going to win a cool T-shirt so hope you'll 00:01:27.854 --> 00:01:33.860 join. >> Okay. So, game of HACQS was initially was born by -- 00:01:37.064 --> 00:01:41.568 HACKS was born by a few of my legs at checkmarks we were 00:01:41.568 --> 00:01:46.640 walking around ACON freeness we saw a few guys standing in front 00:01:46.640 --> 00:01:51.478 of a wall we saw they were looking at a wall with code on 00:01:51.478 --> 00:01:55.916 it and ired are it said spot the vulnerability there was no prize 00:01:55.916 --> 00:02:00.153 no anything but people just standing there and trying to 00:02:00.153 --> 00:02:05.258 figure out vulnerability we thought that's interesting. On 00:02:05.258 --> 00:02:11.264 top of that, OIS published a research that showed that one of 00:02:13.634 --> 00:02:17.771 their top concerns or priorities as wear injections for training 00:02:17.771 --> 00:02:22.075 of developers so secure training for developers. In addition to 00:02:22.075 --> 00:02:28.382 that, they're challenges as I said are related to -- related 00:02:28.382 --> 00:02:33.387 to the education -- we looked at all of these facts, the people 00:02:33.387 --> 00:02:38.959 standing in front of a wall reading code we said okay let's 00:02:38.959 --> 00:02:43.864 put one and one together and make something out of it. So we 00:02:43.864 --> 00:02:48.268 both -- built a game the game is actually a challenge either 00:02:48.268 --> 00:02:52.039 against yourself or you can challenge a colleague too spot 00:02:52.039 --> 00:02:58.278 vulnerability. The idea was initially, you know, just to to 00:02:58.278 --> 00:03:01.248 get people interest Ted it was kind of a marketing campaign. 00:03:03.316 --> 00:03:08.422 And win the first 24 hours we had thirty five thousand 00:03:08.422 --> 00:03:15.028 participants play the game. So, to our surprise. I'm going too 00:03:15.028 --> 00:03:18.131 quickly go into the game so hopefully internet is going to 00:03:18.131 --> 00:03:24.037 work properly. Yep, its working so this is a game you get to 00:03:24.037 --> 00:03:27.874 choose single player or challenge a friend. Once you 00:03:27.874 --> 00:03:33.046 choose, you have three levels of difficulty so the beginner, 00:03:33.046 --> 00:03:39.052 intermediate and advanced. And we'll go for beginner. It starts 00:03:42.055 --> 00:03:45.325 up you have the different sections of the game we'll dig 00:03:45.325 --> 00:03:50.130 into Thorstein few minutes. It gives you vulnerability on the 00:03:50.130 --> 00:03:55.202 screen code with vulnerability on the screen if anyone wants to 00:03:55.202 --> 00:04:00.073 guess the answer I'll be happy to hear out of the four. 00:04:00.073 --> 00:04:07.414 Beginner, come on guys? >> You can't read it? >> Let me zoom it 00:04:07.414 --> 00:04:13.420 in for you. Too much. Better? >> I can't hear you. We got 20 00:04:21.528 --> 00:04:27.534 seconds left. Command injection. All right. Nice. Okay. So that's 00:04:30.470 --> 00:04:33.240 the idea you get five questions you have a timer a minute 00:04:33.240 --> 00:04:37.511 percent question. After five questions trs a -- there's a 00:04:37.511 --> 00:04:43.016 leader board the faster you are the bore -- more points you get 00:04:43.016 --> 00:04:45.685 and of course the more answers correct the more points you get 00:04:45.685 --> 00:04:51.691 as well. But that was not it. So we said okay. This is 00:04:54.060 --> 00:04:57.597 interesting we can do more than just marketing campaign with it 00:04:57.597 --> 00:05:00.700 we thought why not get some more information out of it. We are 00:05:00.700 --> 00:05:07.140 going to publish this on line and why not gain some data and 00:05:07.140 --> 00:05:11.711 understand what hackers are really doing or really trying to 00:05:11.711 --> 00:05:16.049 do with these types of web applications based on need we'll 00:05:16.049 --> 00:05:21.054 talk about need in a section. As you can see our assumptions were 00:05:21.054 --> 00:05:24.791 found to be correct these are screen shots from, from some 00:05:24.791 --> 00:05:29.963 discussion boards so some of them said I don't know if you 00:05:29.963 --> 00:05:32.832 guys can read it something like game itself was harder than to 00:05:32.832 --> 00:05:39.339 hack it. Tries to teach security but fails at it. So, we actually 00:05:39.339 --> 00:05:43.210 failed on purpose. We wanted to have vulnerability in the game. 00:05:43.210 --> 00:05:48.515 We wanted people to try and hack the game along the line we fixed 00:05:48.515 --> 00:05:54.521 vulnerability to see if people get more out of it. The 00:05:57.324 --> 00:06:02.662 architecture of the game, as I said It's based on OJS client 00:06:02.662 --> 00:06:05.765 side is chrome web browser or mobile device and then you have 00:06:05.765 --> 00:06:11.771 local server with -- we see that [indiscernible] work perfectly 00:06:18.411 --> 00:06:24.417 together we'll talk about that as well. So no JA single 00:06:26.987 --> 00:06:31.725 dwelling thread d -- event driven and I just want to 00:06:31.725 --> 00:06:35.428 quickly go over the idea of OJS because it is relevant the rest 00:06:35.428 --> 00:06:40.300 of the talk. As you can see on the left side you have the event 00:06:40.300 --> 00:06:45.939 C U E, it actually is what's waiting to be processed tasks 00:06:45.939 --> 00:06:49.309 that are waiting to be processed in the middle you have event 00:06:49.309 --> 00:06:52.212 loop which is actually the brain. Events loop has ability 00:06:52.212 --> 00:06:57.183 to use CP U as much as it wants however it will try to send all 00:06:57.183 --> 00:07:01.121 the tasks to its -- to spare time. So every time event loop 00:07:01.121 --> 00:07:06.660 gets something it will pass it on to the event handlers as fast 00:07:06.660 --> 00:07:10.497 as possible freeing up the next event and the next event that 00:07:10.497 --> 00:07:14.034 way the single thread can work very fast and very efficiently. 00:07:17.270 --> 00:07:22.375 Just to make this a bit clearer, this is kind of an analogy to 00:07:22.375 --> 00:07:27.714 OJS you have single thread whose cashier here he's getting the 00:07:27.714 --> 00:07:33.486 orders from the crowd from the C U E. You have the event hand her 00:07:33.486 --> 00:07:37.424 simply doing the task that he's getting from the single thread 00:07:37.424 --> 00:07:43.430 the event loop. Going back to game of action, you have 00:07:47.233 --> 00:07:50.603 different entities, we have different entities which we 00:07:50.603 --> 00:07:55.241 based the application on there's questions difficulty level, the 00:07:55.241 --> 00:08:00.947 score, the answers, the question number of course, sixty-second 00:08:00.947 --> 00:08:05.952 timer and code itself where effect of the score is based on 00:08:05.952 --> 00:08:12.125 the time as I mentioned the correct answer of course and the 00:08:12.125 --> 00:08:18.131 speed, which was the answer was answered at. Okay. Guys. I want 00:08:22.369 --> 00:08:28.208 you to experience a bit of game of action. It's not going to be 00:08:28.208 --> 00:08:33.046 only val never rant I'm going to open up the screen now and I 00:08:33.046 --> 00:08:38.184 need you guys to either join via laptop or your phone. I'll give 00:08:38.184 --> 00:08:44.190 I was few second to do that. Just go into cart captioning 00:08:46.926 --> 00:08:51.664 hoot do the IT punch in that opinion that you see on the 00:08:51.664 --> 00:08:57.670 screen right now. I see people joining already, cool. Okay. 00:09:06.046 --> 00:09:12.051 Nice. Remember, top ten will get a T-shirt. Maybe even like mine. 00:09:20.193 --> 00:09:26.199 All right. That's going better than expected. All right I'm 00:09:48.021 --> 00:09:50.590 going to start. You still have sometime to join I think the 00:09:50.590 --> 00:09:56.596 first question doesn't have any points to it. So let's go. Why 00:09:59.399 --> 00:10:05.405 don't I have any sound? >> Doesn't matter. Okay no worries 00:10:12.579 --> 00:10:18.585 no points in this one. Let's move on. Second question. Okay. 00:10:25.058 --> 00:10:31.064 >> [Laughter] >> Okay. From now on it's a bit more serious so 00:11:06.566 --> 00:11:12.572 concentrate. The current leader. Okay we're going to have three 00:11:17.410 --> 00:11:23.416 vulnerability questions. Okay. That was beginner level. Can you 00:11:57.884 --> 00:12:05.058 see the code? >> That makes sense then. I'll try and zoom in 00:12:05.058 --> 00:12:11.064 for you. Hope that will work. Whose DKS. Raise your hand, come 00:12:20.506 --> 00:12:26.512 on. Way to go. Okay. All right. That was that interactive 00:13:08.988 --> 00:13:16.763 immediate yacht level. Let's see how that went. DKS, nice. All 00:13:16.763 --> 00:13:22.769 right. Last one. Last game -- after that we're moving on. I 00:13:32.845 --> 00:13:38.851 see the results for this one. It is confusing. Let's move on. All 00:14:33.806 --> 00:14:39.812 right. Nice. DKS, what happened? >> Okay now these are a bit more 00:14:47.053 --> 00:14:49.322 relevant to the platform that we're talking about. Very -- 00:14:49.322 --> 00:14:55.328 well not very well done. Okay. Okay. Actually, the server won't 00:15:19.986 --> 00:15:23.790 no the answer if the client is doing the random. There's no way 00:15:23.790 --> 00:15:29.428 for the server to -- just a second. There is away for the 00:15:29.428 --> 00:15:33.199 server to know the answer but most -- won't no the answer yeah 00:15:33.199 --> 00:15:39.205 go ahead. I can't hardly here -- hear you. We use [indiscernible] 00:15:54.487 --> 00:16:00.426 we can discuss that off line later. Another question related 00:16:07.834 --> 00:16:13.840 to -- oh, POO. Nice. Gave you free points. Shall I ask who the 00:16:45.171 --> 00:16:51.177 three we're -- stay seated. It's okay. All right eight out of 15. 00:16:54.647 --> 00:17:00.586 -- nine out of ten. Very well done. So, yeah the client 00:17:24.477 --> 00:17:27.413 actually, if there's no validation on the server side, 00:17:27.413 --> 00:17:31.684 the client can answer the same question multiple times. The 00:17:31.684 --> 00:17:35.688 solution for that is actually to write a flag saying answer 00:17:35.688 --> 00:17:41.294 question. Question answered, sorry. Okay. And the last one 00:17:41.294 --> 00:17:48.768 before we move on with our talk. So the calculations on the dash 00:17:48.768 --> 00:17:55.241 didn't yep if you put in negative number your score is 00:17:55.241 --> 00:17:58.177 going to go very very high. Okay. So, let's finish this off. 00:17:58.177 --> 00:18:04.116 We have the top five on here. Actually, I don't think I can 00:18:36.515 --> 00:18:44.256 see the top ten, we'll trust you then. No, I don't think zoom out 00:18:44.256 --> 00:18:50.262 will help. All right. So let's move on with the talk. Okay, so 00:19:00.773 --> 00:19:03.943 these are just a few items related to the question that we 00:19:03.943 --> 00:19:09.448 had so initially the -- and answers allowed hackers or 00:19:09.448 --> 00:19:15.154 developers or script kit tease to answer the same question over 00:19:15.154 --> 00:19:18.124 and over again and you can see a snapshot. I don't know if you 00:19:18.124 --> 00:19:23.696 can read that it says more or less you can -- post the answer 00:19:23.696 --> 00:19:27.733 for the same question multiple times. And that was obviously 00:19:27.733 --> 00:19:30.936 resolved by putting up a flag on the server side saying that the 00:19:30.936 --> 00:19:37.510 question was already answered. The next one was the timer. The 00:19:37.510 --> 00:19:41.680 timer initially was handled by the client on purpose, of 00:19:41.680 --> 00:19:46.952 course. We p wanted to see if people are going to use it. 00:19:46.952 --> 00:19:49.655 Timer was there to force the user to go on to the next 00:19:49.655 --> 00:19:55.661 question when the time ends. So once -- is on the client's side 00:19:57.763 --> 00:20:02.568 the user can halt the timer and gain time to answer the 00:20:02.568 --> 00:20:09.942 question. And what you see here someone who said here's how to 00:20:09.942 --> 00:20:14.346 hack the hack and game pretty simple in your console -- answer 00:20:14.346 --> 00:20:22.221 one time minus anyone anyone anyone anyone anyone anyone. And 00:20:22.221 --> 00:20:28.928 that -- casually 88888 that actually -- dash obviously after 00:20:28.928 --> 00:20:35.868 that we patched that and that was it. The time now is 00:20:35.868 --> 00:20:41.307 calculated on the server side. We have -- it does create a 00:20:41.307 --> 00:20:47.313 small [indiscernible] but not effective enough to modify this 00:20:49.415 --> 00:20:55.554 -- the scores. It was also one guy who found a nice trick on I 00:20:55.554 --> 00:21:01.060 phone on IOS he found if you hold your finger on the time 00:21:01.060 --> 00:21:05.965 phone on the iPhone screen it actually stops the time so 00:21:05.965 --> 00:21:10.236 that's another trick that was circumvent Ted using the server 00:21:10.236 --> 00:21:16.242 side time validation. Okay. A few more no JS points to I mean 00:21:18.310 --> 00:21:21.514 remember remember now these are related more to code admitting I 00:21:21.514 --> 00:21:26.785 know J s'es very very pop her however it does have ghts up 00:21:26.785 --> 00:21:31.323 sides and down sides up side single thread d quick response 00:21:31.323 --> 00:21:37.797 very good for IO intensive tasks. However, its less good 00:21:37.797 --> 00:21:42.835 for CP U intensive tasks so let's see try and see that in 00:21:42.835 --> 00:21:46.539 action I mean we're going back to this image here imagine the 00:21:46.539 --> 00:21:51.010 guy who has the single thread on his head over there having to do 00:21:51.010 --> 00:21:55.447 a lot more work before he moves onto the event hand her that 00:21:55.447 --> 00:21:58.551 would create a huge C U E and a huge delay in people getting 00:21:58.551 --> 00:22:04.490 their food so same thing goes for for no JS. I'm going to show 00:22:07.259 --> 00:22:10.095 you a quick sample of denial of service I hope it's going to 00:22:10.095 --> 00:22:13.699 work. What you see at the bottom is a small script that we've 00:22:13.699 --> 00:22:18.070 created that actually sums up the number between one and P 00:22:18.070 --> 00:22:23.842 where the number -- the P can be anything you put in. Which is a 00:22:23.842 --> 00:22:30.115 CP U intensive option as the more the number the calculated 00:22:30.115 --> 00:22:35.688 number is high. So if we put in five for example we'll get 15 so 00:22:35.688 --> 00:22:40.893 one plus two plus three, so on we get to 15 and let's try and 00:22:40.893 --> 00:22:46.899 see this in action. I pop -- I hope you can see the screens on 00:22:58.911 --> 00:23:02.815 there. So this is actually going to run the script. I'm going to 00:23:02.815 --> 00:23:06.652 put the number, I don't know, visit -- 50 for example in here 00:23:06.652 --> 00:23:12.658 we'll get a response quick CP U calculation and that's it. Now 00:23:14.893 --> 00:23:20.099 we are talking about single thread so the no JS can only run 00:23:20.099 --> 00:23:25.104 a single CP U intensive tasks at one. What we'll do now I'm going 00:23:25.104 --> 00:23:28.741 to put a large number on this screen here. Hope I'm not going 00:23:28.741 --> 00:23:32.077 to make it too large then I might key 98 myself a denial of 00:23:32.077 --> 00:23:38.117 service. How many Sears to I have on here. Let's make it like 00:23:38.117 --> 00:23:43.122 that. Okay. At the same time, I'm going to calculate this for 00:23:43.122 --> 00:23:48.327 let's say five. We'll start this one and after that I'll start 00:23:48.327 --> 00:23:51.697 the second one and what you'll see is that this one as long as 00:23:51.697 --> 00:23:54.667 it works, agencies its calculating the other one won't 00:23:54.667 --> 00:23:58.671 be calculated Ted so it's going to have to wait for the event 00:23:58.671 --> 00:24:04.610 loop to complete the job. That was too fast. Another zero. 00:24:13.185 --> 00:24:18.958 Okay. Now you see the one on the right is still calculating and 00:24:18.958 --> 00:24:23.529 the one on the left is not able to perform its tasks as long as 00:24:23.529 --> 00:24:27.499 the right window has not completed the calculation. And 00:24:27.499 --> 00:24:35.140 that's very sim p l single thread problem and there it is. 00:24:35.140 --> 00:24:39.778 So once the large number completed the small number went 00:24:39.778 --> 00:24:45.784 immediately after that. All right. Everyone clear? >> Cool. 00:24:55.427 --> 00:25:01.567 Okay. Another thing with OJS it's very popular to work with 00:25:01.567 --> 00:25:06.805 with [indiscernible] because of the Jason based functional will 00:25:06.805 --> 00:25:11.677 the that it has. It has the ability actual toll take objects 00:25:11.677 --> 00:25:17.549 to take Jason values and put them in the request or database. 00:25:17.549 --> 00:25:21.253 What happens in this case is that a user can actually, when 00:25:21.253 --> 00:25:24.556 you are trying to log into an application a user can use they 00:25:24.556 --> 00:25:29.094 values or these Jason values to play around with the log in. So 00:25:29.094 --> 00:25:35.901 this is kind of -- without [indiscernible] I'm going to try 00:25:35.901 --> 00:25:41.907 [indiscernible] that as well. So we have this log in application 00:25:49.715 --> 00:25:55.921 here, so this is justs -- just the log in screen if I punch in, 00:25:55.921 --> 00:26:01.860 it let's me in. Which is great. And if I take this in the U RL 00:26:05.964 --> 00:26:10.302 it's the same thing actually I'll just do this, so you see 00:26:10.302 --> 00:26:16.308 that it works the same way. Okay. So that works. But what 00:26:21.713 --> 00:26:25.250 happens if I use the great than tag so I'm going to use the 00:26:25.250 --> 00:26:29.488 greater than A which means that any user on the system 00:26:29.488 --> 00:26:32.157 registered on the system is going to be able to allow any 00:26:32.157 --> 00:26:34.927 user that's greater than A which is probably all of them and 00:26:34.927 --> 00:26:39.298 password that is great than A is going to be able to log in. So, 00:26:39.298 --> 00:26:42.868 I don't have the ADMIN password in here once I CLICK enter 00:26:42.868 --> 00:26:48.941 there's no differences let's try a different let's -- letter 00:26:48.941 --> 00:26:56.115 let's try B and it logs me in as a different user so what I've 00:26:56.115 --> 00:27:02.321 actually done I've used a Jason parameter greater than to 00:27:02.321 --> 00:27:08.160 overcome the validation, which is kind of a Jason injection. 00:27:10.762 --> 00:27:16.768 All right. One more thing regarding to Jason, because of 00:27:23.709 --> 00:27:27.913 that ability to use the Jason values, you can actually use a 00:27:27.913 --> 00:27:31.783 lot of Jason values one of them is regular expression. Regular 00:27:31.783 --> 00:27:37.489 expression is highly CP U intensive. And as you can see, 00:27:37.489 --> 00:27:41.326 or as you can remember, the no J s'es very very sensitive to CP U 00:27:46.665 --> 00:27:52.671 heavy CP U tasks. If you take this line for example, and we're 00:27:52.671 --> 00:27:56.308 going to go again -- sorry. We're going to go again to that 00:27:56.308 --> 00:28:00.178 log in page. We are going to see that we can cause denial of 00:28:00.178 --> 00:28:04.616 service or regular expression denial of service to the log in 00:28:04.616 --> 00:28:09.755 process to, the application but just giving it a huge number of 00:28:09.755 --> 00:28:15.761 regular expression wild cards. So, let's see that in action. 00:28:24.736 --> 00:28:28.073 What were going to see now I'm going to try and open my task 00:28:28.073 --> 00:28:34.079 manager here. Hopefully it will work. Okay. If I load this, 00:28:41.119 --> 00:28:47.125 where's my task manager my computer is already stuck my 00:28:50.395 --> 00:28:54.700 browser is already stuck because of that what you would see in 00:28:54.700 --> 00:28:58.904 this case and you just saw that the [indiscernible] is using 25 00:28:58.904 --> 00:29:03.909 percent of my CP U, which is a single core out of my four 00:29:03.909 --> 00:29:09.114 course so very easily I could enforce the application -- and 00:29:09.114 --> 00:29:15.120 by that actually causing denial of service. All right. Some take 00:29:20.092 --> 00:29:25.797 a ways. -- we really believe in edge indicating developers to 00:29:25.797 --> 00:29:32.070 write correct code to write secure code it's not only when 00:29:32.070 --> 00:29:37.342 you say I think the strep understand that that one of the 00:29:37.342 --> 00:29:43.348 best ways to educate is -- it works forever one all ages. So, 00:29:48.420 --> 00:29:54.826 any time you have opportunity to make learning experience fun 00:29:54.826 --> 00:29:58.130 highly recommend we saw that with game of action we saw that 00:29:58.130 --> 00:30:00.399 with the number of -- develop first of all types and kinds. 00:30:00.399 --> 00:30:02.868 Regarding the code that you are using when you are using new 00:30:02.868 --> 00:30:08.874 code in this case OJS you want to make sure you know what it -- 00:30:14.813 --> 00:30:21.953 its pitfalls are. What we could have done to avoid denial of 00:30:21.953 --> 00:30:28.360 service and Jason is to actually validate completely the length 00:30:28.360 --> 00:30:35.600 of the fields and the validity of the field completely. And 00:30:35.600 --> 00:30:42.007 last point OJS highly sensitive to CP U. Important to watch out 00:30:42.007 --> 00:30:47.646 for that. And that's it. It's time for questions. >> 00:30:47.646 --> 00:30:53.652 [Applause] into is it -- yep. >> Question asked. >> In this on 00:30:56.121 --> 00:31:02.060 line version of the game it doesn't. It just tell us you 00:31:04.529 --> 00:31:12.304 wrong. There are other versions that we could integrate win your 00:31:12.304 --> 00:31:16.007 product and that allows you more information once you get 00:31:16.007 --> 00:31:22.013 something wrong. Any more questions? >> Okay. Thank you 00:31:28.186 --> 00:31:30.188 everyone.