WEBVTT

00:00:06.269 --> 00:00:08.609
<v Brad Causey>Hey, folks! Welcome to the Cyber Threat Perspective.

00:00:08.759 --> 00:00:27.410
<v Brad Causey>Today, I have a cat with a keyboard, and welcome back, Jordan, who is our resident web app pen tester. And so, yeah, yeah, and as you guys might have guessed and probably can read, we're talking about the OWASP top 10.

00:00:24.230 --> 00:00:47.950
<v Brad Causey>We have finally made it to number five on the list, so we are halfway there. Progress, probably progress. I know, right? Well, it's taken us like six months to get here. Just we've been super busy, and we have other podcasts to record, obviously, but we're we're gonna try to get the last five knocked out in 2026. We'll see if that actually works.

00:00:48.340 --> 00:00:50.590
<v Jordan Natter>Hey, I have face.

00:00:48.340 --> 00:00:56.140
<v Jordan Natter>I have face. If we have to do it all in one evening, don't question why we're wearing the same clothes for the right.

00:00:53.619 --> 00:00:56.140
<v Jordan Natter>Yeah, we might record like six

00:00:56.200 --> 00:01:03.960
<v Brad Causey>in a row. Wait, that would be too many. But but yeah, so so this one I think personally this is my favorite.

00:01:04.230 --> 00:01:05.370
<v Jordan Natter>I agree, 100%

00:01:05.670 --> 00:01:13.680
<v Brad Causey>Yeah, yeah. So we're talking about injection, folks. So what is injection?

00:01:08.040 --> 00:01:27.950
<v Brad Causey>Well, fundamentally, we are pushing code to some layer of the application, and and it's not handled properly, and it is then executed by that layer of the application. Now that can be any number of different things.

00:01:28.010 --> 00:01:31.340
<v Brad Causey>It could be the browser, right?

00:01:28.010 --> 00:01:39.019
<v Brad Causey>It doesn't have to be a component that lives server side. So yeah, it can be. There are many many variations.

00:01:35.959 --> 00:02:07.620
<v Brad Causey>Probably the ones you guys have heard of are things like cross site scripting, one of the most popular and common vulnerabilities that we see. SQL injection, which I'm going to put beneath SQL injection, like all of the other data layer manipulation ones, right? No SQL, LDAP. Although again, those are technically obviously not SQL, but when we start talking about like data layer injection, it there there's so many of them you just can't list them all, right?

00:02:07.709 --> 00:02:15.030
<v Jordan Natter>I feel like they're in the same family, so like we can just count it as a category in this case, just as long as we're explaining that to you guys, which we just did. So,

00:02:15.959 --> 00:02:40.908
<v Brad Causey>100% 100% and so so yeah, I mean, at the most fundamental level, you know, you can put a script tag in a form field, and the browser, if it's you know, again, if the application is not handling it properly, may execute that script on the user's browser.

00:02:34.068 --> 00:02:58.838
<v Brad Causey>And so, even beyond just the category of cross-site scripting. There are like I think three subcategories of cross-site scripting, and we're not going to go like super deep into any one thing. But with cross-site scripting, there's reflected cross-site scripting, right? So this would be more like a GET request, right? And and so, all right, I guess we are going to go deep into this.

00:02:59.348 --> 00:03:01.438
<v Brad Causey>So we're not going

00:03:01.500 --> 00:03:03.120
<v Jordan Natter>deep into it.

00:03:01.500 --> 00:03:03.120
<v Jordan Natter>Starts explaining it

00:03:03.120 --> 00:03:41.680
<v Brad Causey>immediately. Goes immediately goes to like you know HTTP methods. So usually when you're sending data between a browser and a web server, there are many different verbs, many different methods. But the two most common that we see on a web application are GET and POST. And a GET request and a post are very similar in that they transmit information between the client and the server, but they're different in the way that they do it. And so, GET uses parameters in the URL, and POST uses a body, which is basically just content that is like down inside the request.

00:03:37.159 --> 00:03:47.500
<v Brad Causey>Right. The easiest way I know to kind of illustrate the difference is if you're using a GET request, you can actually see the data in the URL, right?

00:03:47.500 --> 00:04:45.910
<v Brad Causey>If you copy the GET request, it's going to be this long string of val of key value pairs. When you do a post, you can't do that. You can't copy a post URL and paste it into a browser and get it to execute because it's actually like nestled down into the body of the request. Generally speaking, posts are more secure than than gets for that reason because they do not display the data in the URL. Anyway, I digress. So I say that say you know you can put these in cross-site scripting, right? Reflected cross-site scripting would be like grabbing that GET request, sending it to a user. The user clicks on the link, and the code that the bad guy wants the user's browser to run is contained within the link, and it fires and it executes.

00:04:39.800 --> 00:05:24.319
<v Brad Causey>Probably the most common, I would say, the most common reason for doing it would be like either causing the getting the user to do something they wouldn't do, right? So, like for example, I can have if if maybe the account creation page. Is also vulnerable to cross-site request forgery. Then I can chain. I'm getting ahead of myself a little bit here. We're going to talk about this, but but the point is, cross-site scripting by itself is kind of novel, right? But in almost every case, you need another vulnerability in the application to make it useful. Do you agree with that? Is that fair?

00:05:24.740 --> 00:05:40.819
<v Jordan Natter>Typically, yes, and not in all cases because, like, we'll we'll mention more about that. Especially because, like Brad was talking about, there's different kinds of cross-site scripting. But in most cases, if you want to take a cross-site scripting vulnerability and get it to a critical, you do kind of want to chain other vulnerabilities together.

00:05:41.420 --> 00:06:21.860
<v Brad Causey>Yeah, yeah, and I agree. Like cross-site scripting by itself, it can be like a medium or high, right, on a CDSS scale. But in most cases, if you want to do something with it, right, steal a session, you know, cause something else happen. But I mean, the reality to your point, actually, and I didn't even think about this until just now. But like, I mean, you could do HTML injection and call and and and just social engineer the user into doing something they don't want to do, right? We do that sometimes as proof of concept, and it's like email your password to blah blah blah blah blah, you know, and and so and so you know now all the users are going to log in and be like, well, I guess I have to do that.

00:06:22.009 --> 00:06:35.720
<v Brad Causey>So, so yeah, so so that's you know, reflected cross-site scripting is is is not stored anywhere, right? Has to be executed in in kind of real time. By contrast, stored cross-site scripting

00:06:36.439 --> 00:06:36.529
<v Jordan Natter>is

00:06:36.800 --> 00:06:38.300
<v Brad Causey>persistent, right?

00:06:38.810 --> 00:06:38.899
<v Jordan Natter>Yes.

00:06:39.560 --> 00:06:41.500
<v Brad Causey>And so it has to it can live within the application.

00:06:41.649 --> 00:06:43.930
<v Brad Causey>Those are, I would say, more dangerous.

00:06:45.250 --> 00:06:45.670
<v Jordan Natter>Absolutely.

00:06:45.730 --> 00:06:46.750
<v Brad Causey>Would you agree with that? Okay. Yeah.

00:06:46.810 --> 00:06:47.110
<v Brad Causey>Completely

00:06:47.170 --> 00:07:08.310
<v Jordan Natter>agree. Now, if those of you who listen to Brad's like four minute spiel about those three, if you want a like very short bulleted version of those of those two, look at it like stored cross site scripting is a script that's saved on the server, so any visitor that like goes to that page is going to see it, right?

00:07:04.889 --> 00:07:17.699
<v Jordan Natter>Think of reflected, like the script comes immediately from a malicious URL, so that that's like in very layman terms what to expect from those two and how to categorize those based on.

00:07:16.110 --> 00:07:17.699
<v Jordan Natter>Could have

00:07:17.790 --> 00:07:19.680
<v Brad Causey>saved me like five minutes of my life by saying. I

00:07:19.769 --> 00:07:22.910
<v Jordan Natter>mean, I I thought maybe you just like talking so no I'm

00:07:24.139 --> 00:07:33.319
<v Brad Causey>I'm just trying to like in real time formulate a way to describe it and you're just like oh yeah two sentences obviously see this this is why this is why you do this is why you do stuff right well

00:07:33.470 --> 00:07:42.819
<v Jordan Natter>you gave them the very in depth like you need to understand all the history of all of it and I gave them like hey if you want the cheat notes for a test. Here it is. Yeah,

00:07:42.939 --> 00:07:55.240
<v Brad Causey>yeah. No, to to be fair, I'm I I frequently have to explain this to technical people, like in in report delivery meetings, and and and and so you know we're we're I'm already deep diving into that.

00:07:51.970 --> 00:08:03.240
<v Brad Causey>So there is one more kind DOM based cross site scripting. I'm gonna be real with you, dude. I don't even think I care about the difference between reflected and DOM based.

00:08:04.230 --> 00:08:06.329
<v Jordan Natter>Yeah, there's not much of a difference, really.

00:08:06.540 --> 00:08:17.550
<v Jordan Natter>Again, if you had to have like a one liner, it's pretty much very similar to it, but it just improperly handles the data, so you're not really seeing what it's doing because it's not reflecting back.

00:08:18.209 --> 00:08:26.899
<v Brad Causey>Well, and I don't think it ever reaches the server. So, like, in I guess that's probably the core difference between DOM and reflected is that in in a DOMB.

00:08:26.899 --> 00:08:54.009
<v Brad Causey>By the way, if you don't know what the Document Object Model is, here I go. Think about it like the it's kind of like the browser's space that that executes the code, right? So the server sends down HTML and JavaScript and all this fancy stuff, and then the browser kind of interprets it. And so that's how we get from this this garbage code into a pretty website, right? That's the DOM.

00:08:50.740 --> 00:09:18.059
<v Brad Causey>The DOM handles all that stuff, and so you can you can actually drop script code or whatever kind of code into the DOM, and if it's not properly handling it, it'll execute. The big difference is it never goes to the server. With reflected cross-site scripting, it actually reflects back from the server to the browser. All right, and so I would say reflected and DOM based are probably similar in their risk.

00:09:15.059 --> 00:09:18.059
<v Brad Causey>Would you agree with that? Okay,

00:09:18.149 --> 00:09:18.809
<v Jordan Natter>I completely agree.

00:09:19.769 --> 00:09:25.519
<v Brad Causey>Okay, so we haven't even gotten to the other 72 different types of injection.

00:09:21.830 --> 00:09:49.690
<v Brad Causey>You know, I probably the the next biggest one on the list is SQL injection, right? And we we mentioned that a little bit earlier. We mentioned that there are 100 million different subcategories of that, which we absolutely do not have time to go into because we're already like 1/3 through the the podcast. But but suffice it to say this, right? Most applications have some sort of data layer behind them, right?

00:09:45.610 --> 00:09:54.490
<v Brad Causey>An application without data is kind of useless, and so right, like what are we doing, right?

00:09:54.549 --> 00:10:38.990
<v Brad Causey>Like maybe like a calculator or something. I don't know, but but I'm sure I'm sure there are plenty of wonderful applications that. Have data storage, but the point of this is, is if there's a SQL database structured query language, we can we can actually manipulate the requests that end up at the database to do the thing that we want it to do, right? Which would be like dump the database to me, for example, and even as subcategories of SQL injection, there are many different types of them, like blind SQL injection. You know, but but but the the moral of the story is this, right? We're not properly sanitizing the information before it reaches the data layer, and that's the theme of injection.

00:10:39.350 --> 00:10:39.500
<v Jordan Natter>Yes,

00:10:39.860 --> 00:10:48.309
<v Brad Causey>we we as application developers are not properly sanitizing the data before it reaches the place where it can be executed, and that can be anywhere, right?

00:10:49.059 --> 00:11:12.090
<v Brad Causey>LDAP, for example, is is is a authentication protocol, lightweight directory access protocol. I believe is what that state. I did that off top of my head, so I could be completely wrong. But you know, most most commonly known to be used for things like Active Directory and stuff like that. So it's an authentication component. Well, it's still a structured language, which means we can manipulate it.

00:11:12.179 --> 00:11:12.330
<v Jordan Natter>Yes.

00:11:14.190 --> 00:11:41.980
<v Brad Causey>Now I do want to mention this, and and this is probably going a little deeper than we need to go. Big surprise to literally No one, you know, SQL is is not the only type of of data layer that can exist out there. There are literally hundreds, right? There are flat, like no no SQL. There are object relational mapping frameworks, Hibernate query land, like literally, I can't even list them all. Right, we've run out

00:11:41.980 --> 00:11:44.590
<v of time. But here's the thing>I want you guys to take away from

00:11:44.620 --> 00:11:49.480
<v this>there is no data layer that is immune to injection.

00:11:50.440 --> 00:12:06.840
<v this>Meaning that even if you choose a widely considered to be secure data layer within your, you know, to support your application, then it is still possible to manipulate that, and and therefore you should still be doing input validation.

00:12:07.200 --> 00:12:07.320
<v Jordan Natter>Yes,

00:12:07.740 --> 00:12:14.250
<v Brad Causey>right, and that can take many forms. You know, the most common form, obviously, is is just you know a value.

00:12:14.490 --> 00:12:18.360
<v Brad Causey>Actually, you know what? We're going to talk about fixing this at the end of the episode, so I'm not going to deep dive into that.

00:12:18.659 --> 00:12:20.509
<v Jordan Natter>Are you sure you don't want to do it now? I

00:12:20.659 --> 00:12:25.220
<v Brad Causey>really do. Can you tell? Like, I really want to.

00:12:25.309 --> 00:12:32.149
<v Brad Causey>Okay, so let's talk about like real world examples. Before

00:12:32.210 --> 00:12:47.409
<v Jordan Natter>we get into that, I do want to say something. So, those of you guys who have been following like the OAS Top 10, right? You've probably noticed in recent years, that this wasn't actually number five; it was higher up in the list of of top 10. Oh yeah, I guess so.

00:12:47.679 --> 00:12:48.879
<v Brad Causey>Yeah, you're right.

00:12:47.679 --> 00:12:49.299
<v Brad Causey>I think it was like top three, wouldn't it?

00:12:49.480 --> 00:13:10.200
<v Jordan Natter>It was, yeah. So it's moved back to slots from like last year to this year, or whenever that they change it from year to year. That's not saying that it's any less of a problem, guys. Like it. What we're pointing out is the fact that what is more important right now. It does not mean that the things that are lower in the list are less important or less.

00:13:11.519 --> 00:13:13.320
<v Jordan Natter>What's the word I'm looking for?

00:13:11.519 --> 00:13:13.320
<v Jordan Natter>Prolific,

00:13:13.529 --> 00:13:14.250
<v Brad Causey>maybe common.

00:13:14.789 --> 00:13:26.330
<v Jordan Natter>Yeah, like they're not less common just because it moved. It's not less important. It's still like all bunch a big category of vulnerabilities, guys. Like, don't lower this on your yeah.

00:13:23.059 --> 00:13:31.039
<v Jordan Natter>Like, don't lower your prioritization of it just because it moved down in the list. It's not any less important.

00:13:31.490 --> 00:13:35.360
<v Brad Causey>Yeah, no, I completely agree with that, and it's still common. We still see this all the time.

00:13:35.480 --> 00:13:38.299
<v Jordan Natter>Oh no, I've got February pen test. Yeah, I've got

00:13:38.299 --> 00:14:08.639
<v Brad Causey>a report delivery meeting next week where where where you know I did a web app pen test on an app and you know it was dumping SQL code on you know error based SQL detection SQL injection detection and it was like wow guys you know I shouldn't be able to manipulate structure your query so yeah 100% so I agree with that anything else to add before we get into the war stories because this is my favorite part of these episodes. This is when we talk about like, hey, we actually saw one of these, and I know you've got probably some some good ones. So I'll let you go first.

00:14:09.210 --> 00:14:17.399
<v Jordan Natter>Cool. So if it's okay with you, I'm gonna cover the blood drive one. By all means, add your tidbits of information because you were there. I was there for that one.

00:14:17.399 --> 00:14:17.549
<v Jordan Natter>I was

00:14:17.669 --> 00:14:19.169
<v Brad Causey>I was a witness to this catastrophe.

00:14:19.740 --> 00:14:22.279
<v Jordan Natter>A witness, right?

00:14:19.740 --> 00:15:40.100
<v Jordan Natter>So for some context, guys, right? I started pin testing back in like 2018, but this was my first ever actual pen test, which is great because before this, I was just working on like reports and like kind of like having my training wheels and riding shotgun on things. But in this case, my first ever web application pen test. So, for context, there is this very big organization that's kind of in the medical space, right? Well, what happens is what they do is they reward their employees for every time they give blood with a $25 gift card. Now, the thing is, though, how. They apply for that gift card. Is that they go to this web application? They then say that they're an employee, and it's self-registry. So what's supposed to happen is that the employees are supposed to be like, "Hey, I'm an employee. I gave blood. Please give me my gift card. Okay. Well, the problem there is anyone can register as an employee. They're not cross cross referencing to their employee database, so that's one thing that's already interesting to me. Then there's also no limit on the amount of times you can apply for a gift card. So those of you who know a little bit about like giving blood, there's normally a limit of how much blood you can give within a certain amount of time.

00:15:37.820 --> 00:15:40.100
<v Jordan Natter>Don't you run

00:15:40.279 --> 00:15:40.929
<v Brad Causey>out at some point.

00:15:41.289 --> 00:15:46.480
<v Jordan Natter>Yeah, I mean, I would expect so. I don't feel like I have an indefinite amount. Not a doctor, just just a theory.

00:15:46.779 --> 00:15:48.159
<v Brad Causey>Okay, just just

00:15:48.340 --> 00:15:48.940
<v Jordan Natter>an assumption.

00:15:48.340 --> 00:15:48.940
<v Jordan Natter>This is

00:15:49.330 --> 00:15:50.889
<v Brad Causey>this is not medical advice, people.

00:15:51.279 --> 00:15:56.919
<v Jordan Natter>Yeah, no, please don't go give all your blood. I don't think they would allow you to anyway. Probably, but they're

00:15:57.009 --> 00:15:59.110
<v Brad Causey>obviously not using this app. No.

00:16:00.639 --> 00:16:48.399
<v Jordan Natter>Well, so that's another thing that's interesting is that I notice that there's not a limit to how many times you can apply that, like you gave blood and want a gift card, right? So there's supposed to be some kind of a limit because I'm obviously not giving blood every moment of every day. So already one note that I'm like looking at, I'm like, oh, this is interesting. So two things right there that we're already pointed out, right? So anyone can register for it, pretending they're an employee because there's no validation that you are an employee. Second, being you can apply for that gift card as many times as you want because there's no limit to the amount of times you can apply for that gift card within a period of time, even though it's asking for when how much blood that you gave, it's not actually validating that that makes logistical sense.

00:16:48.789 --> 00:16:49.720
<v Brad Causey>Business logic flaw.

00:16:50.409 --> 00:16:52.570
<v Jordan Natter>Yes. Have we

00:16:52.659 --> 00:16:54.429
<v Brad Causey>done business logic yet? I'm not sure.

00:16:55.059 --> 00:16:56.740
<v Jordan Natter>I don't remember.

00:16:55.059 --> 00:16:56.740
<v Jordan Natter>This is all kind of. We'll have

00:16:56.739 --> 00:16:58.658
<v Brad Causey>to we'll have to figure it out. All right. Go ahead. Go ahead. This

00:16:59.139 --> 00:17:58.599
<v Jordan Natter>is all kind of going together. Okay. So with all of that in mind, what would you guys want to do? Probably see how many gift cards you can get just for the like hell of it, right? I mean, I that's what I want to do. So looking at it, you're like, okay, cool. What what possibly could I do? Well, they have a SQL database. What if we just use SQL injection to then just absolutely ruin everything and get as many gift cards as humanly possible, that is exactly what I did. Lo and behold, this was also my first pen test where I didn't know that you should probably make sure that they have a backup of the database and not also test in production, which as you guys have heard on every episode, we specifically mention to make sure it's a staging or development environment and make sure that there's a backup of the database. This is why, because the database was absolutely destroyed.

00:18:00.640 --> 00:18:21.200
<v Brad Causey>Yeah. So so this was, and I think I think we may have mentioned this part of the story before, but yeah, this app was the one that we were like because up until that point it was kind of optional for the client, where it was like, hey, we prefer to not test in prod, and so unfortunately this app was the only copy of the app.

00:18:18.029 --> 00:18:30.049
<v Brad Causey>There was no alt. There was no backup of the source. There was no backup of the database, and Jordan corrupted the database, and there was no way to get it back. Right.

00:18:30.380 --> 00:18:42.039
<v Brad Causey>So like it was gone, gone, and so we reached out, and and we didn't know that at the time, right? We reached out and we're like, hey, I think the app is down, and then all of a sudden it was like, hey, we need you.

00:18:39.950 --> 00:18:50.410
<v Brad Causey>We need you on the phone right now. And we get on the phone, and and the app owner, like the executive over that department, did not know that the pen test was happening.

00:18:50.890 --> 00:18:51.130
<v Jordan Natter>Oh, so

00:18:51.460 --> 00:19:08.940
<v Brad Causey>we were, yeah, we were being sponsored by the cyber security department of this particular organization, and and they did it without letting the app owner know, and and so basically we got chewed out for like 20 minutes, and I mean again not our fault, dude.

00:19:05.910 --> 00:19:17.099
<v Brad Causey>Like literally, you you hired us to do a job. We're doing a job, and anyway, so long story short, at after that it was no longer optional. Like we do not test in production.

00:19:17.700 --> 00:19:17.789
<v Unknown>Yes.

00:19:18.390 --> 00:19:20.490
<v Brad Causey>And by the way, back up even your staging data.

00:19:20.609 --> 00:19:22.970
<v Brad Causey>Like back it up. Have a have a back up

00:19:23.059 --> 00:19:23.420
<v Jordan Natter>everything.

00:19:23.990 --> 00:19:26.930
<v Brad Causey>Yeah, because we don't intentionally break stuff, but it does happen.

00:19:27.289 --> 00:19:27.440
<v Unknown>Yes,

00:19:27.559 --> 00:19:31.039
<v Brad Causey>you know, and web apps are are even more fragile.

00:19:31.940 --> 00:19:43.869
<v Brad Causey>Maybe that's the right word for it than than other things that we do pen testing on. You know, like when we're hammering an SSL VPN with like you know credential stuffing attacks, like there's no chance we're gonna break the VPN.

00:19:44.319 --> 00:19:44.380
<v Jordan Natter>No,

00:19:45.190 --> 00:19:51.339
<v Brad Causey>but web app. If your code's bad enough, man, anything becomes a data recovery exercise.

00:19:51.700 --> 00:19:59.890
<v Jordan Natter>Well, I was gonna say, look at it in this in this case, right? So what we were inherently doing on this web application wasn't necessarily out of the norm. It was the.

00:20:00.059 --> 00:20:04.710
<v Jordan Natter>Amount of data we were pushing to the the SQL database, right?

00:20:04.859 --> 00:20:31.940
<v Jordan Natter>So we ended up getting, I think, like $25,000 worth of gift cards. Which, by the way, they're $25 gift cards. You guys can do the math on how many like queries that is. So what we're doing isn't necessarily inherently bad. Like we weren't purposely trying to knock off the the database or anything, or sorry, the servers. So what? But we just made so many requests that it was like barf and fell over.

00:20:32.420 --> 00:20:36.079
<v Brad Causey>Yeah, yeah, and it can happen. It absolutely can.

00:20:36.230 --> 00:20:43.150
<v Brad Causey>Again, if any code's bad enough, we can we can turn this into a data recovery exercise. Good.

00:20:39.410 --> 00:20:51.069
<v Brad Causey>No, I love that story. I love that story. I really only have one, and it's it's kind of lame, but I think it's it's still important to to to communicate.

00:20:51.160 --> 00:21:53.500
<v Brad Causey>So I'll I'll be quick. This was actually an external pen test, by the way, not a not a dedicated web app pen test, but this was a like a regional logistics company, like they did like regional shipping or something like that. I don't remember the details, but they had multiple hubs, obviously, all over the region. And and one of the tools on their like what on their website was to check to see if the if if all the hubs were up, and so you could you could select like a southeastern hub one, and it would ping the the the server at that location to see if it was working. And so anyway, long story short, I could manipulate the dropdown box and actually inject a value in there other than like hub one. And so what that what that ended up doing though is the way they had written the code is PHP code. The way they had written it is it would actually go down and do a ping at the OS level.

00:21:49.000 --> 00:23:05.549
<v Brad Causey>They would use the command line of the operating system to do the ping. Those of you who understand what OS command injection is, you guys know where I'm going with this, right? And so I was able to put any value in there. And if you if you if you actually look at like the way a ping command is structured, you can put a semicolon at the end of it, and then run more commands. Right, or you can do ampers a double ampersand on Linux and run additional commands, and so that's exactly what I did. Is I had it ping, and then I appended my own request at the end. In this particular case, I was able to get it to actually do a curl command to pull down and execute a Bash script that was a reverse shell. And so, literally, like 10 minutes after finding this little drop down, you know, check, and it's totally. It looks, it looks so innocent on the site, you know. It's like you want to drop down check, and and so that one little form with with a single field and one button turned into me running as the www data you www data user.

00:22:59.859 --> 00:23:24.890
<v Brad Causey>on that web server, and so yeah, it could be that simple and that dangerous. And and we didn't we didn't talk about OS commanding as an injection flaw at the beginning of the episode, but this this was my opportunity to kind of bring that back up. So so yeah, literally from like one button to hey, now I have access to your server directly via a shell. All right, back to you.

00:23:24.980 --> 00:23:27.049
<v Jordan Natter>Which is great. I know I'm. Isn't it? It's great

00:23:27.049 --> 00:23:37.369
<v Brad Causey>for me. It's awful for them. You know. Now, hey, at least they weren't running Apache's root. I've seen that before. So yeah. So that that one's fun.

00:23:38.029 --> 00:23:41.109
<v Jordan Natter>It just gets worse, guys. The more you know.

00:23:41.559 --> 00:24:38.839
<v Jordan Natter>Anyway, all right. So this next one's a little short, and then I say Brad and I tag team if we have time for the session hijack chain one because that one was something that he started talking about earlier. Plus that way he doesn't only have one story. So I'll pass him off one of mine. Less prepared. All right. So in this case, this is just basic cross-site scripting, right? So on this one application, I'm not going to list what kind of application it is because it doesn't necessarily matter. But in this one, a user has the ability to change their username to whatever you want. There's no input validation at all. So I decided to change my username, but for context, everyone can view usernames, especially because what you do when within the application is you see what people are applied to what projects. So people are going to see my username, whatever that may be, being reflected on everything else. So

00:24:39.650 --> 00:24:41.230
<v Brad Causey>I see where you're going with this. If

00:24:41.259 --> 00:24:45.279
<v Jordan Natter>you guys are seeing what kind of cross-site scripting this is stored, excuse me.

00:24:46.000 --> 00:24:46.569
<v Brad Causey>Nice. Yes.

00:24:48.549 --> 00:25:31.579
<v Jordan Natter>That's where this is going. So in this case, I just changed my name to a very complicated query, words or hearts, that requests a document cookie. So anyone who's going to hover over mine and it's going to fetch their document, their their cookie that they are using at that time, whenever they whenever they interact with my username. So let me scroll down to some evidence. Not that you guys can see this, but it makes my brain happy to to look at it, but pretty much I changed the first name to like give or take JavaScript alert document cookie. I'm just simplifying. So

00:25:31.849 --> 00:25:33.140
<v Brad Causey>we're we're throwing the session up.

00:25:33.619 --> 00:25:33.859
<v Jordan Natter>Yes. Yeah,

00:25:34.309 --> 00:25:35.420
<v Brad Causey>and a JavaScript dialog. Yeah.

00:25:35.839 --> 00:26:02.819
<v Jordan Natter>Yes, and then what's going to happen is when someone interacts interacts with it, I am now getting a little box that tells me what their document cookie is. Cookie is it's fetching it and then retrieving it to me. So anyone who's reacting with that now I have authentic authenticated cookies, and I can now hijack your session and log in as you because I have those valid cookies as long as they are logged into their that application at the same time.

00:26:03.000 --> 00:26:05.880
<v Jordan Natter>Obviously, they are if they're interacting. View your username.

00:26:05.970 --> 00:26:06.029
<v Brad Causey>Yeah.

00:26:06.269 --> 00:26:12.960
<v Jordan Natter>Yes, because they have to be logged in to view my username. Well, now I have everything to log in as you because you're interacting with me.

00:26:13.650 --> 00:26:30.079
<v Brad Causey>Yep. And this is a really good example. I'm glad you did this one, right? This is a really great example of where multiple flaws need to exist in an application in order for one of these to be dangerous, right?

00:26:25.910 --> 00:26:35.450
<v Brad Causey>So, I know that the the subject of of this is is injection, but if you have a proper CSP in place,

00:26:36.019 --> 00:26:36.109
<v Jordan Natter>yes,

00:26:36.589 --> 00:27:09.750
<v Brad Causey>you kill it. If you are using HTTP only on your session cookie, you kill it, right? Because it will not allow the JavaScript to access access the cookie values, and so if you are using you know any number of other protections that can be in place, you still defeat this attack, and so you know there are so many options available to application developers, and you know it's just part of a layered security approach. You know what I mean?

00:27:10.200 --> 00:27:11.220
<v Jordan Natter>No, absolutely.

00:27:10.200 --> 00:27:11.220
<v Jordan Natter>And

00:27:11.339 --> 00:27:34.009
<v Brad Causey>so you know I just I just like pointing that out because in almost every case when we start talking about injection flaws, you know, like I'll give you another example, right? Air-based SQL injection detection, right? Which is the way that works is we, you know, we would put in SQL code, and if the thing we get back is your your SQL structure is incorrect, try this. You know, like that.

00:27:30.140 --> 00:27:38.329
<v Brad Causey>Thanks, but but now now we're not, you know, we're not output filtering error error messages.

00:27:38.869 --> 00:27:56.049
<v Brad Causey>So that in of itself is a flaw, right? Now the SQL injection would still be there, and it would just be blind SQL injection at that point. But what I'm getting at is, we have so many opportunities and so many tools at our disposal that any one of them, if done well, will typically defeat an attack chain,

00:27:56.829 --> 00:27:57.069
<v Unknown>which

00:27:57.220 --> 00:27:58.569
<v Brad Causey>is actually what we're going to talk about next.

00:27:58.930 --> 00:27:59.109
<v Jordan Natter>Yes.

00:27:59.200 --> 00:28:01.380
<v Brad Causey>So yeah, no, I love it. Great story. Great story.

00:28:01.799 --> 00:28:05.279
<v Jordan Natter>Imagine the name of the next one is Session Hijack Chain.

00:28:06.240 --> 00:28:09.539
<v Brad Causey>Right, right. Which is the most common thing to do with cross-site scripting. Yeah.

00:28:10.170 --> 00:28:17.160
<v Jordan Natter>Well, and as Brad was mentioning, right. So if you have a SeaSurf token like already, that's already fixing things. So in oh, that would have

00:28:17.189 --> 00:28:18.598
<v Brad Causey>defeated the one you just yeah yeah.

00:28:18.990 --> 00:28:20.009
<v Jordan Natter>So that would have fixed. That was the one

00:28:20.160 --> 00:28:22.220
<v Brad Causey>I was thinking of.

00:28:20.160 --> 00:28:24.769
<v Brad Causey>That I and I was like, "If you just do the, and then I lost it.

00:28:22.279 --> 00:28:25.279
<v Brad Causey>So no, thank you for bringing that one back. I

00:28:25.609 --> 00:28:28.460
<v Jordan Natter>saved the day.

00:28:25.609 --> 00:28:38.150
<v Jordan Natter>Well, so in this case, right? So there were three things they weren't doing. They their CSRF token parameter accepted or is accepted without any server side validation, right? So it could be blank or any argument. So they had

00:28:38.539 --> 00:28:39.859
<v Brad Causey>one. They just weren't using it.

00:28:39.920 --> 00:28:51.220
<v Jordan Natter>Yeah. So it pretty much what what was happening is that they were like, I have sea surf, I'm doing nothing to actually make sure it's being used. So it just it's just there. It's a name, but it's it's not doing anything.

00:28:51.250 --> 00:28:57.700
<v Jordan Natter>It's not doing what it's supposed to do. So that's slightly worse because you took the time to put it there, but then didn't implement it. But

00:28:57.700 --> 00:28:59.289
<v Brad Causey>then you're just not doing it. Yeah, that's cool.

00:28:59.740 --> 00:29:25.190
<v Jordan Natter>So that was one of the things. Another thing was the fact that, like, of course, there's no like encoding or output sanitization or any input validation, right? So that was another thing that conjunct conjunctions with this. And then also the last one was the session cookie was issued with without the same site attribute, so neither lacks nor strict, so it would automatically be attached across origin requests.

00:29:26.210 --> 00:29:33.230
<v Jordan Natter>You guys can see where this is going. So in this case, let me scroll down. And by the way, feel free to chime in.

00:29:34.309 --> 00:29:35.720
<v Brad Causey>I'm loving it so far. Nothing to add.

00:29:38.690 --> 00:29:41.319
<v Jordan Natter>So of course, the SeaSurf token is set to empty.

00:29:42.279 --> 00:30:18.180
<v Jordan Natter>We go to the search field, which this great dandy part about this one is it's in the search field, and we just do cross-site scripting. Script alert document dot domain script, right? Of course, with all the extra tags, but I'm not sounding like a robot. Right. So when load. Into the same profile as an authenticated user, the form would submit automatically, resulting in a page rendered that the victim's authenticated navigation would execute an inject script, producing the same site and then getting. Or wait, hold up, my brain is rebooting.

00:30:20.069 --> 00:30:31.190
<v Brad Causey>But ultimately, though, right when when we're when we're leveraging this search field, because of the lack of additional protections in place, it sounds like we're able to control the user's browser.

00:30:31.549 --> 00:30:34.309
<v Jordan Natter>Yes, pretty much.

00:30:31.549 --> 00:30:36.829
<v Jordan Natter>My brain started combining this one with the other one, and I was like, "Hold up! It's a lot.

00:30:36.890 --> 00:30:38.029
<v Jordan Natter>It's a lot. So,

00:30:38.809 --> 00:30:53.019
<v Brad Causey>but yeah, no, I love that, and and this is another great example of of how these injection flaws can can can either you know again and we're about to talk about remediations in just a second, but you know some some really basic application hygiene can really go a long way,

00:30:53.559 --> 00:30:53.650
<v Jordan Natter>right?

00:30:53.769 --> 00:30:54.640
<v Brad Causey>It can really go a long

00:30:55.210 --> 00:31:05.910
<v Jordan Natter>way. Well, and there's not a like a vast number of things you have to do to like limit the ability to do cross-site scripting or injection attacks. I agree. Of like, like we're about to is we're about to go in solutions.

00:31:06.000 --> 00:31:12.809
<v Jordan Natter>But there's even just doing one or two of them will already like lower the amount of possibility that it's going to happen.

00:31:13.289 --> 00:31:23.240
<v Brad Causey>Yeah, and and even if you know exactly what you just said, right? If if the if the flaw exists from a cross-site scripting perspective, but you can't do anything with it. Well, suddenly it's like okay, it's annoying.

00:31:23.390 --> 00:31:27.470
<v Brad Causey>Like you still need to fix it, but but you can't really do a lot.

00:31:27.680 --> 00:31:48.250
<v Jordan Natter>Well, yeah, it's like take for example, you have a reflected cross site scripting, right? But there's so many other controls in place that it doesn't affect any user other than yourself. Cool. So I'm just saying alert cross site scripting found. Like show up because I put like literally alert cross-site scripting. The only person that's affecting is me because that there's other like mitigation factors in place.

00:31:48.519 --> 00:31:53.200
<v Brad Causey>Yeah, it makes perfect sense. Yeah. All right, so let's talk about prevention.

00:31:50.740 --> 00:32:02.640
<v Brad Causey>How do we prevent injection attacks? And and so I'm going to make this contrary to how I normally do things very simple.

00:31:58.089 --> 00:33:40.160
<v Brad Causey>We first of all we never trust user input, right? User input, and and I would take it a step further. We don't trust anything that comes from the user's browser, even because ultimately the browser is under the control of the user, which means it could be malicious. Yes. All right. So, so you know, we can kind of combine like the input validation concept with we don't trust the browser, we don't trust the user. So when we start looking, we want to look at things like even headers, headers that come back, any value that can be tampered with, and and I'm not I don't mean tampered with like in a form field. I mean tampered with at all because that is probably the most common confusion that we see when we deliver these reports, and that is you know the the developers like yeah but I don't I won't I don't let you put anything but numbers in the zip code field, and I'm like yeah you're doing that with JavaScript bro right you're doing that in the browser the problem is I'm not even using the browser, right? Like I'm tampering with with this using Burp Suite, and so the browser never sees it. And I can just not. I can also, by the way, pro tip: you just turn JavaScript off. Like you can just disable it in the DOM. Like it's not a big. Yeah. So so you know it, and so we call that client side validation. Client side validation is not a security measure. Like, let me just be clear: client-side validation is a usability feature. It is nice for the user to have because it will tell you, "Hey, you didn't input this field, or if you've ever like filled out a form and you missed a checkbox, it's like, "Hey, you have to approve.

00:33:37.549 --> 00:34:29.059
<v Brad Causey>You know, you accept the fact that you're giving up your entire life to to submit this form, and so that that's not security in any stretch of the imagination, right? That that's a feature that's nice. Where that should be validated is on the server side, and you can do both. That's totally fine. We're going to turn off the user the user validation side, but but yeah, so so input validation, as it reaches the server, the server should be critiquing the values against what it knows to be valid, right? So and I love using zip code because it's the easiest thing in the world. It's a five, you know, for the for in the U.S. It's it's it's five numbers, right? Or at most, it's nine numbers if it's five dash four, and so in in some countries there are numerical values, but you know what?

00:34:26.389 --> 00:34:38.300
<v Brad Causey>There's not apostrophes, semicolons, probably. I don't know. You know what? There's probably a country. Somebody's going to correct me on that. But but the point is this, right?

00:34:35.059 --> 00:34:48.039
<v Brad Causey>It's a known structure. There are also a a finite number of zip codes that exist. Period on planet Earth, and so if you wanted to, you could have a database full of them or an array within the application. So

00:34:48.099 --> 00:34:57.340
<v I say all that to say this>you know what values you're expecting, so you should block values that you're not expecting. Yes, and there are two ways to accomplish that.

00:34:57.400 --> 00:35:00.960
<v I say all that to say this>Number one is through a blacklist. Which is the wrong answer?

00:35:01.469 --> 00:35:03.599
<v Jordan Natter>I like how you stole exactly what I wanted to mention.

00:35:03.750 --> 00:35:06.869
<v Brad Causey>No, are you serious? Go, go, go! Talk, talk about it. So,

00:35:07.170 --> 00:35:25.699
<v Jordan Natter>like what he was saying, right? That there's two ways to do it. You can either have a blacklist, as he mentioned. Don't suggest because, by the way, who wants to sit there and come up with every possible value you don't want, right? So, like, am I going to sit here going, okay, cool, this is a zip code. It should be only numerical values.

00:35:25.820 --> 00:35:34.789
<v Jordan Natter>Am I going to sit here and do sit through sit through the entire alphabet and every special character that there is to add to the blacklist?

00:35:31.159 --> 00:36:08.670
<v Jordan Natter>Probably not. And if you do do that, you're probably going to miss some things. So with that in mind, you could also do a whitelist, which is way better, because now I just say what I want you to do, and that's the only thing that I allow. That way, anything that I didn't put on that whitelist is automatically disallowed. So again, I'm only going to include numerical values. So now I'm just going to do one through or zero through nine. Right, those numbers are allowed. Now everything else is disallowed, so they can't put like apostrophe or a single quote or whatever it may be. Right?

00:36:09.809 --> 00:37:12.360
<v Brad Causey>That's exactly right, and and that that's the right answer. Now, I've I've seen some blacklists work relatively well, but to your point, the the problem that blacklists don't take into account are are concepts like encoding, double encoding, so like a space is what percent 20 or percent 22 in HTML entity encoding. Yeah, okay. So so now I drop that in and it gets interpreted on the server side as a different character. So there are ways to bypass blacklist filters, which is why we encourage people to use whitelists And and so we could do an entire episode just on this, but that that's one piece, right? So the data is inbound to the server. We need to filter that. We're going to filter that based on what we know to be valid and safe. Okay. And by the way, check out OWASP's input validation cheat sheet. Pro tip: absolutely amazing resource. It will tell you how to do it correctly. And I would even encourage you to go check out the libraries that exist. So rather than you inventing a way to solve the problem that has existed for 30 years, go grab an OWASP input validation library.

00:37:09.840 --> 00:38:26.690
<v Brad Causey>There are many of them available, and use that. All right. So moving along, the data goes to the server, and and there there's one other thing I want to mention before because what we've been talking about mainly for things like OS commanding and SQL cross-site scripting. We didn't talk about SQL injection. All right, for SQL injection, it's a little bit different. We still want to do input validation, but we also need to use parameterized queries, right? Because the the issue in in SQL injection is that we're putting reserved SQL characters in the request that gets interpreted then as code on the SQL data layer itself. So, parameterized queries and stored procedures are your two best defense mechanisms for that. And these are basically just strict structures that you can't break out of. Okay, and and and you can do them wrong, but that that's the answer, Right now, data reaches the server. Now, data has to come back from the server. This is where output encoding comes into play. There are always going to be scenarios where you can't restrict the characters that go into a request. What you can do is control how it comes out of the server, how the server pushes it either to the data layer or back to the browser, and that's where output encoding comes into play.

00:38:22.730 --> 00:38:36.559
<v Brad Causey>So that is where you're going to encode the characters to make them inert, to make them safe for the browser to display.

00:38:31.699 --> 00:39:11.190
<v Brad Causey>Right. So, so yeah. I mean, that's it in a nutshell. It's that. It sounds so simple because we just covered remediation in like four minutes. It's not. It's not always that easy. But what I would encourage you guys to do is go check out some of the OWASP resources. Maybe we'll grab some of them in the show notes for you guys. But yeah, yeah, absolutely. And and the cheat sheets are like a category of project that OWASP has. I've actually written a couple of them, and and I'm a huge fan of those because they cut straight to it, right? It's not like the OWASP Web Testing Guide, which is like 250 pages. You know, it's like, oh, cool, there goes my entire weekend. No, no, no.

00:39:11.280 --> 00:39:18.360
<v Brad Causey>Your cheat sheet is like four pages, and it tells you exactly how to solve the problem that you have. So there are some really good resources out there.

00:39:16.380 --> 00:39:18.960
<v Brad Causey>All right, anything to add before we close out?

00:39:19.380 --> 00:39:20.159
<v Jordan Natter>No, that's all I got.

00:39:20.789 --> 00:39:23.179
<v Brad Causey>Awesome. Well, thanks for being with us today.

00:39:24.409 --> 00:39:48.639
<v Brad Causey>More to come. We have five more of the OWASP Top 10 to cover, so we're going to try to get to those as quickly as we can. If you enjoyed the show, like, subscribe, share this with your friends, and most importantly, if you need a web app pen test, I know a cat with a keyboard that will hook you up. So reach out to us if you need a web app pen test, or you just have general questions about web application security. We can definitely hook you up. So we'll see you guys next week.
