WEBVTT

00:08.460 --> 00:10.760
Alright, this is our agenda for today.

00:10.760 --> 00:13.240
First, we'll be going over what WAFs are.

00:13.240 --> 00:15.140
I think many of you already know what they are.

00:15.140 --> 00:17.100
Otherwise, you probably wouldn't be here.

00:17.400 --> 00:20.180
Just so we start with an even play for everyone.

00:20.460 --> 00:26.920
Then, we'll go over what we've learned at Datadog operating a very large-scale WAF and the struggle that comes with it.

00:27.340 --> 00:32.260
We'll try to address a bit how we deal with false positives and false negatives.

00:32.580 --> 00:38.040
And then, we'll finish by sharing how we try to make them a bit better.

00:38.600 --> 00:40.880
Alright, who are we first?

00:41.460 --> 00:42.260
I'm Emmanuelle.

00:42.260 --> 00:43.760
I'm a software engineer at Datadog.

00:43.760 --> 00:44.760
I'm based in Paris.

00:44.760 --> 00:47.420
And I've worked on machine learning models for the past four years.

00:47.420 --> 00:49.300
So, not a security background at all.

00:49.460 --> 00:53.940
And actually, last year, I decided to join Datadog to work on our application security product.

00:54.440 --> 00:56.220
And this is my co-presenter, Emile.

00:56.860 --> 00:58.500
So, I'm Emile Gospier.

00:58.500 --> 01:02.780
I'm a security researcher at Datadog, also based in Paris.

01:02.780 --> 01:06.460
I've been working on a WAF and a RASP solution for the last five years.

01:06.560 --> 01:09.940
First, at Screen, then Datadog, following an acquisition in 2021.

01:10.500 --> 01:12.300
And, yeah, let's talk about WAFs.

01:12.300 --> 01:13.660
You may know about them.

01:14.020 --> 01:26.600
If you don't, that's a security tool that was created in the mid-90s, when web applications started to become more complex, more useful, and thus, a more enticing target.

01:27.120 --> 01:32.160
We didn't really have anything to do to help protect them.

01:32.160 --> 01:36.160
So, we looked at other tools, and a promising one was firewalls.

01:36.160 --> 01:38.060
They're working really great at the network level.

01:38.060 --> 01:42.720
So, the idea was, let's take them and bring them to the application layer.

01:43.080 --> 01:54.280
And instead of running on specific rules, like this IP, this port, this whatever, it was more, yeah, let's run regexes or dictionaries to find suspicious patterns in that.

01:54.280 --> 01:57.540
And if you find them in the incoming request, that's probably because it's bad.

01:58.460 --> 02:00.920
And, yeah, that's pretty much it.

02:03.080 --> 02:07.180
WAFs today are pretty much the backbone of runtime application security.

02:07.180 --> 02:08.760
And that's for a few reasons.

02:08.760 --> 02:11.460
First, they are super easy to explain.

02:11.500 --> 02:15.320
In just a few words, I was able to give you a good view of what they are.

02:16.180 --> 02:18.440
They're also incredibly easy to customize.

02:18.440 --> 02:26.380
Because they're based on regexes and dictionaries, you have an entire industry of rulesets that you can use, or you can even customize them yourself.

02:26.860 --> 02:28.640
They're also really easy to demo.

02:28.640 --> 02:34.220
All you need to do to show that your WAF works is plug it on the Internet.

02:34.500 --> 02:41.160
And just the noise from the Internet is going to create a bunch of alerts, and, hey, you have a great security tool, you're protecting everyone.

02:42.580 --> 02:45.660
And finally, it never hurts, it's actually recorded by compliance.

02:45.800 --> 02:51.800
So if you're dealing with credit cards, yeah, you need a WAF, basically.

02:51.940 --> 02:56.860
So, yeah, all of that came together to make WAF an incredibly popular product.

02:58.840 --> 03:03.400
However, WAF tends to give a bit of a false sense of security.

03:03.440 --> 03:08.400
Because what a WAF does is that it looks for suspicious requests.

03:08.400 --> 03:11.240
It's running regexes, dictionaries, that's what it does.

03:11.540 --> 03:19.040
But then it means that if you can make your malicious attack look unsuspicious, then it's going to go through.

03:19.560 --> 03:27.900
And if you happen to have a user that sends another request that happens to look suspicious, they need to be matched.

03:28.340 --> 03:31.760
And there is not really anything you can do about it.

03:31.760 --> 03:33.340
That's WAF working as design.

03:34.200 --> 03:40.640
So, yeah, a few alternatives were tried over time, like RASP, IASP, but they never really went anywhere.

03:40.960 --> 03:43.460
No solution really got anywhere as popular as WAF.

03:45.160 --> 03:46.680
We talked about what they are.

03:46.980 --> 03:49.300
Emmanuel is going to tell you about how to make one.

03:49.300 --> 03:50.800
Yeah, how do we build a WAF?

03:50.800 --> 03:54.240
Well, first, of course, you need a web application because that's what you want to protect.

03:54.240 --> 03:59.600
In front of that, most of the time, you're going to put a reverse proxy to route all the incoming traffic to your web application.

04:00.020 --> 04:00.680
All right.

04:00.900 --> 04:02.500
Now, let's build a WAF.

04:02.600 --> 04:05.160
First element that we need is a rule engine, of course.

04:05.160 --> 04:07.760
We're going to put it on the reverse proxy because it's very convenient.

04:07.760 --> 04:12.960
It's where we're going to be able to see all the incoming traffic and filter out the malicious request if we need to.

04:13.800 --> 04:15.960
Second element we need, a rule set.

04:16.360 --> 04:21.020
Here, we're mentioning the OWASP core rule set because it's a very popular one across the industry.

04:21.020 --> 04:25.240
It's open source, so you can also use it to build your own rule set on top of it.

04:25.240 --> 04:29.080
Here, you can see we mentioned PL1 for Paranoia Level 1.

04:29.580 --> 04:36.140
What it means is it's supposed to be not too noisy, so it's supposed to be a set of rules that shouldn't trigger too many alerts for us.

04:36.160 --> 04:36.580
Okay.

04:36.580 --> 04:37.160
All right.

04:37.160 --> 04:37.740
Well, good.

04:37.740 --> 04:39.620
Last element we need, the monitoring.

04:40.200 --> 04:46.660
It can be just a text file where you push all of your alerts, or it can be a super fancy dashboard that you've built.

04:48.220 --> 04:48.940
Okay.

04:49.200 --> 04:49.880
We're all set.

04:49.880 --> 04:51.240
I think we can activate the WAF.

04:51.240 --> 04:53.900
And this is more or less what happened the first time we did it.

04:53.900 --> 04:55.480
We started crying.

04:55.740 --> 04:57.600
We got a bunch of alerts.

04:57.640 --> 04:59.880
And we were like, okay, what do we do with this?

05:00.360 --> 05:04.640
And we took a step back and were like, okay, this is actually a great learning experiment.

05:05.080 --> 05:06.560
So what did we learn, Emil?

05:08.640 --> 05:14.240
So the learnings we are going to share are based on us operating a WAF at a pretty large scale.

05:14.240 --> 05:18.840
We are talking around a billion requests per second across hundreds of thousands of organizations.

05:20.060 --> 05:28.420
And the first and most important learning we took away from that is that the accuracy of a WAF rule is totally unpredictable at scale.

05:28.620 --> 05:30.800
You can think that your rule is perfect.

05:30.960 --> 05:33.380
Until it's tested, you have no idea.

05:35.600 --> 05:38.560
So they will tend to converge quite fast.

05:38.780 --> 05:45.060
So if you can test them on a broad enough set of data, within a few hours you will have a good idea of how it's going to behave.

05:45.060 --> 05:59.640
But if you only tested them on WordPress or CMS, and you deployed them on an e-commerce website, I mean, you can have a French customer going to share their address, which has a quote and OR, and then the WAF is going to freak out.

05:59.640 --> 06:02.320
I mean, of course, this is a SQL injection, no?

06:03.020 --> 06:03.880
Yeah.

06:05.580 --> 06:19.780
The other important consequence from that is that even if you do very simple modifications, like you just expand it a little bit further, like you add a couple of duplication steps, you need to test them again because you don't know what you are missing before.

06:20.720 --> 06:30.120
The other side of this coin, however, is that even if you have a crazy rule that shouldn't work, it's usually worth testing them just in case.

06:30.460 --> 06:40.820
To illustrate that, we're going to go back like to late 2021, when AppSec just caught fire, and we had log4j drop on us a few weeks before Christmas.

06:41.440 --> 06:48.760
And for those of you who don't know, it was an RCE in the log4j library, which is used by Java application to log.

06:48.760 --> 06:52.220
And if you don't know, Java applications love to log.

06:53.340 --> 07:03.740
So when it came out, the initial PLC was something like that, where if you could get log4j to log this, you had an RCE.

07:04.780 --> 07:07.160
So yeah, everyone started scanning all over the place.

07:07.860 --> 07:13.680
Pretty much every WAF vendor or user set up their own pattern, and we did too.

07:13.720 --> 07:15.560
The first version was something like that.

07:15.560 --> 07:24.200
So, okay, we just match gndi, which is the entry point of the bug in log4j, and then pretty much everything that follows.

07:24.440 --> 07:25.720
We test it.

07:25.840 --> 07:26.600
Okay, it's fine.

07:26.600 --> 07:28.000
It triggers a little bit.

07:28.400 --> 07:30.400
No obvious pattern of false positive.

07:30.400 --> 07:31.440
Okay, good to go.

07:31.440 --> 07:32.300
We can ship it.

07:33.200 --> 07:34.960
And yeah, it worked well.

07:35.200 --> 07:39.760
Very quickly, however, the attackers tried to find bypasses for that.

07:39.760 --> 07:42.280
So the first one they found was they could use a different schema.

07:42.320 --> 07:48.720
The initial PLC used LDAP to perform the RCE, but actually you could use another schema, so they just did.

07:49.300 --> 07:53.960
In our case, we were not really looking at LDAP, so we didn't really care.

07:54.020 --> 07:58.340
But then they decided to step things up.

07:58.340 --> 08:05.440
So they started to use the string interpolation features of log4j to obfuscate their pattern further.

08:06.300 --> 08:09.580
So, okay, we need to complexify quite a bit the pattern.

08:09.580 --> 08:16.960
So every single character we had before became this whole mess to support some amount of obfuscation.

08:17.080 --> 08:19.460
Then attackers decided to step things up further.

08:19.460 --> 08:23.080
So, okay, now you have completely spurious blocks that are just going to disappear.

08:23.720 --> 08:26.300
Okay, we can expand the pattern further.

08:26.300 --> 08:28.460
This is becoming a bit unwieldy.

08:28.460 --> 08:33.060
For each character you have in the initial pattern, you have this whole mess there.

08:33.600 --> 08:36.120
And attackers just got crazy.

08:38.640 --> 08:43.660
This could either be the most complex waffle ever, or we need a different type strategy.

08:43.660 --> 08:48.160
So when we saw that, we basically tested two rules.

08:48.200 --> 08:53.700
One monstrosity that could deal with that, or something much simpler.

08:55.080 --> 08:59.760
And we are shocked, but this never triggered the false positive.

09:00.840 --> 09:06.720
Like, that's why we're telling you that you need to test rules, because this shouldn't work.

09:08.160 --> 09:14.720
And, yeah, the last bypasses we found at the end were attempts to use non-ASCII characters.

09:14.820 --> 09:18.280
So here, like, log4j would do some kind of unicode normalization.

09:18.860 --> 09:20.560
Yeah, at this point you need to do the same.

09:20.560 --> 09:21.900
And that's expensive.

09:24.660 --> 09:30.340
Yeah, and when we put this in production, it triggered roughly half a million triggers in a week.

09:30.340 --> 09:33.640
And that was before the acquisition of Datadog, so at a much smaller scale.

09:35.700 --> 09:42.700
We told you about how you design a rule, but there is a greater framework behind it and some constraints.

09:42.700 --> 09:45.860
So let Emmanuel tell you about the dilemma of building a WAF rule.

09:45.860 --> 09:52.200
Yes, so when you build a WAF rule, we try to kind of display this into a graph.

09:53.300 --> 09:59.620
On the horizontal axis, you can have a very broad rule that will catch everything, or a very specific rule.

09:59.880 --> 10:10.160
And on the vertical axis, you can have either a rule that's very easy to bypass, but doesn't give you too many false positives, or here on the top, it triggers a lot of false positives, but it's hard to bypass.

10:10.880 --> 10:25.280
All right, based on that, we try to define a max amount of noise that we're willing to accept, meaning if a rule starts triggering more false positives than this threshold, we're not even going to put it into prediction because it's not worth the hassle.

10:26.180 --> 10:33.840
Okay, now an ideal rule we could try to build would be something very broad that's going to catch every XSS attack that we're getting.

10:34.360 --> 10:34.940
Dope.

10:34.940 --> 10:38.380
And it doesn't trigger too many false positives and it's not too easy to bypass.

10:38.380 --> 10:40.140
All right, it's right in there in the middle.

10:40.140 --> 10:50.180
On the other side, you could also try to build a rule that's very, very specific, meaning it could only target a very specific XSS vulnerability for Jupyter notebooks.

10:51.160 --> 10:54.560
And same, not too easy to bypass and not too many false positives.

10:54.820 --> 10:55.380
Dope.

10:55.420 --> 11:02.660
Well, that would be an ideal rule because actually what happens most of the time when you try to build this rule is you end up right there.

11:02.860 --> 11:09.440
If you do a very broad rule, you're going to have a lot of false positives and if you do a very specific rule, you're going to be bypassed very easily.

11:11.020 --> 11:12.220
So what happens?

11:12.540 --> 11:16.900
Most of the time, you're going to be in this yellow area right there, the space of operation.

11:16.920 --> 11:20.120
And what you want to do, ideally, is to be right there in the middle.

11:20.120 --> 11:24.140
So you are doing, kind of, having the best of both worlds, so to speak.

11:25.300 --> 11:30.160
All right, so we've talked about how we don't want too many false positives because they are nasty.

11:30.520 --> 11:34.000
Well, let me tell you or kind of remind you why we don't want them.

11:34.080 --> 11:36.300
First, they are going to create an alert fatigue.

11:36.300 --> 11:40.260
So, yeah, there is nothing worse than you come into work and you see 10,000 plus alerts.

11:40.260 --> 11:41.380
What do I do with this?

11:41.680 --> 11:45.020
It's not worth looking at it and it's not actionable.

11:45.840 --> 11:47.260
Second reason why.

11:47.260 --> 11:49.280
Well, it can have a business impact.

11:49.560 --> 11:56.180
If you have rules in blocking mode, you might be blocking legitimate customers with a wrong setup.

11:56.460 --> 11:58.760
And if you're blocking customers, you're losing business.

11:58.760 --> 12:00.260
If you're losing business, you're losing money.

12:00.260 --> 12:01.640
So you don't want that either.

12:01.860 --> 12:06.740
And the last reason why you don't want false positives is because you might end up collecting PII by accident.

12:06.740 --> 12:11.940
Meaning you might collect some private information like addresses, emails, phone numbers.

12:11.940 --> 12:14.080
And this might end up in your log triggers.

12:14.920 --> 12:17.920
And because of that, you're going to have a security issue on your hands.

12:17.920 --> 12:19.580
So , yeah, you don't want that either.

12:20.720 --> 12:24.520
Overall, what you need to keep in mind is that it's all about finding this compromise.

12:24.520 --> 12:28.900
You want a rule that doesn't have too many false positives but still brings you value.

12:30.420 --> 12:31.380
All right.

12:31.820 --> 12:38.980
In all this time working on false positives, at Datadog, we've been able to see a bunch of them and we've tried to classify them into different types of families.

12:39.400 --> 12:44.500
The first family we've encountered most of the time is based on what they are.

12:44.600 --> 12:48.440
Meaning you get a bunch of triggers coming from free text.

12:48.760 --> 12:51.680
For example, you're running an application like Stack Overflow.

12:51.680 --> 12:56.080
You have a bunch of people pasting SQL injection all the time because they're asking questions about it.

12:56.080 --> 13:00.420
And this will trigger your WAF if it's set up in a way where it looks at free text.

13:01.380 --> 13:12.680
Second family you can have is if you're running any type of infrastructure that's having an admin panel, running SQL queries against your DB.

13:12.680 --> 13:15.400
This is going to look like SQL injection to your WAF.

13:15.400 --> 13:19.100
So let's say you're running phpMyAdmin that could happen most of the time.

13:19.960 --> 13:27.660
And also, if your application is relying on some concept like you're doing a lot of queries all over the place.

13:27.660 --> 13:29.920
For example, at Datadog, that's an issue that we have.

13:29.920 --> 13:34.400
We're running a ton of queries everywhere and it looks like SQL injection a lot of the time.

13:34.400 --> 13:35.820
So what do we do with that?

13:36.300 --> 13:42.000
Most of the time, when we run these queries, they have the keyword query in them.

13:42.000 --> 13:46.100
So we decided to pass list the word query to get rid of those false positives.

13:47.780 --> 13:52.620
And different type of rules are going to be sensitive to different type of false positive families.

13:52.660 --> 13:54.460
So you have to kind of look for them.

13:54.700 --> 14:06.980
For example, if you manage to detect some false positive based on the free text, what you can do is just pass list free text for some of the rules that trigger on them.

14:09.720 --> 14:11.320
We've talked about families.

14:11.320 --> 14:13.120
So now, how do we catch them?

14:13.300 --> 14:19.620
Because it's all good and fun, but how do we actually find them in our application when we have 10 plus thousand triggers?

14:20.000 --> 14:21.700
Well, you can do a bunch of statistics.

14:21.700 --> 14:27.100
So yeah, that's where the ML engineer comes into the room and tell you you should do statistics on your triggers.

14:28.540 --> 14:31.800
You can look at application or trigger trends.

14:31.800 --> 14:34.480
So what I mean is, let's say you're...

14:34.480 --> 14:39.100
you can look at your global traffic trends and see how many queries you're getting.

14:39.220 --> 14:42.080
And then what you can do is look at your trigger trends.

14:42.080 --> 14:50.360
If you have a rule that has a traffic that follows a lot your global application traffic, then it's probably a false positive here.

14:50.580 --> 14:53.580
We took an example of something with your data dog here.

14:54.340 --> 14:57.520
Yeah, you have a rule here, the yellow rule, that's triggering a lot of the time.

14:57.520 --> 15:06.420
It's like, I don't know, you cannot really see it here, but 250k triggers most of the time and across all days, every day.

15:06.440 --> 15:09.420
So that's where we're like, okay, we have a false positive on our hands.

15:09.900 --> 15:13.280
And here, on the other side, you can see here a purple bump.

15:13.280 --> 15:16.320
It's actually a security scanner and this is a rule that works perfectly fine.

15:16.320 --> 15:18.340
You can see it's not spread all over the place.

15:19.000 --> 15:29.240
If you're in doubt and you don't know if the trends that you're seeing are actually kind of matching the trends of your traffic, you can also look at the IPs that are triggering your alerts.

15:29.240 --> 15:37.700
If you have a very broad range, meaning everyone that's coming into your application is actually triggering your rule, you also have a rule that's having a false positive issue.

15:38.380 --> 15:43.920
And on this side here, I decided to kind of show you what a Nelfy-ish traffic would look like.

15:43.920 --> 15:45.880
So you have a bunch of bumps, ups and downs.

15:45.880 --> 15:54.380
It's not super regular, so this is typically what Nelfy rules would be outputting in terms of number of triggers.

15:54.720 --> 15:55.760
All right.

15:56.240 --> 16:02.620
Now let's take it a step further and let's see if we can actually do any kind of machine learning path processing.

16:03.720 --> 16:05.880
Yeah, you can start with embeddings.

16:05.880 --> 16:10.800
So I don't know if any of you are familiar with embeddings, but they are used, for example, in LLMs.

16:10.800 --> 16:14.800
So it's very trendy at the moment and you can use them to...

16:14.800 --> 16:16.880
basically use them as a hash function.

16:16.880 --> 16:22.120
You give it a payload, so it could be any type of string, and then it will give you back a vector of numbers.

16:22.520 --> 16:28.580
Here, it's going to be much larger than a 2D vector, but for the sake of this example, I kept a 2D vector.

16:29.000 --> 16:31.940
And what you can do is, you put it in some kind of graph.

16:32.700 --> 16:34.600
Here, okay, we put it there.

16:34.600 --> 16:43.820
Then, as we have a new payload coming in, that we know is also a false positive, we also put it through the embedding function and we get a new representation.

16:44.140 --> 16:50.020
And they are kind of clustered together, so we can kind of define a false positive area, a false positive cluster.

16:50.680 --> 17:00.100
And what this means is that when you have a new payload coming in and it's actually a real trigger, you're able to see it, because it's further away from all the false positive clusters you've been able to build.

17:00.240 --> 17:06.340
So you can kind of deduce false positives or new false positives based on what you already know.

17:07.120 --> 17:16.040
All right, old fun games, but if you're lazy and you don't want to do all this manual clustering, it's very cumbersome, you can do some more fancy things.

17:16.040 --> 17:18.100
So you can do classification, for example.

17:19.020 --> 17:26.600
You can use machine learning models like the classic old-school ones, or you can even use OpenAI LLMs, if you feel like it.

17:28.460 --> 17:37.000
If you do that, some of them will work out of the box, so it's super nice, and some others, if you want it really tailored to your use case, it's not going to work, so you will need to fine-tune them.

17:38.320 --> 17:42.760
And let me tell you, this is a hassle, like we've tried, and this is very tricky to do.

17:43.340 --> 17:50.380
You need to build a legit data set, so a lot of real triggers and a lot of false positives to actually make it make sense.

17:50.620 --> 17:54.020
And here, I took a plain example that we had when we did a trial.

17:54.080 --> 18:04.400
So we gave it an embedding, a bunch of payloads, and we picked an OpenAI LLMs, we fine-tuned it, and we gave it an actual SQL injection payload, and we were like, OK, what is this?

18:04.400 --> 18:06.360
And it replied, it's a true attack.

18:06.400 --> 18:07.820
Dope, OK, it's working.

18:08.000 --> 18:18.360
And then we did the same thing, but we just put a comment after, and it was like, oh no, no, this is not an attack, this is actually just someone randomly coming to your application and pasting that.

18:18.860 --> 18:22.660
So yeah, this is a blatant case of false negatives, and this can happen a lot.

18:22.660 --> 18:30.740
So if you're going the route of doing some fancy machine learning to deal with your false positives, just try to build a good data set.

18:30.940 --> 18:33.760
And yeah, it's just fancy statistics, basically.

18:34.280 --> 18:35.040
All right.

18:36.260 --> 18:39.340
What if we talk about the blind spots of the WAF now?

18:40.160 --> 18:44.460
So that's the part of the talk where the security vendor tells you it's totally fine, the product doesn't work.

18:44.460 --> 18:50.080
No , more seriously, WAFs have a problem with obfuscation.

18:50.240 --> 18:53.100
If you hide your payload, it's going to go through.

18:53.100 --> 19:03.620
And this is mostly because of what the internet is, which is a bunch of RFCs from the late 80s, early 90s, and all of the weird implementation bugs we had since then.

19:03.740 --> 19:08.260
And as a vendor, you can only really easily find the first ones.

19:08.580 --> 19:11.740
What are we talking about with, like, those weird bugs?

19:11.840 --> 19:21.540
You have a web server that I'm not going to name that happens to perform recursive decoding of URLs and support non-serial syntax.

19:21.740 --> 19:27.060
What this means is that you have this monstrosity here and it's going to be converted into an open bracket.

19:27.060 --> 19:27.520
Why?

19:27.520 --> 19:30.260
Because, I guess, some engineers hate us.

19:31.620 --> 19:32.300
SQL.

19:32.300 --> 19:33.240
That's great.

19:33.240 --> 19:34.040
It's a language.

19:34.040 --> 19:34.900
It's standardized.

19:34.980 --> 19:37.540
Every database engine is using the same.

19:37.580 --> 19:37.960
Right?

19:37.960 --> 19:38.280
No.

19:38.280 --> 19:39.080
No, of course not.

19:39.080 --> 19:41.460
MySQL decided to make some commands conditional.

19:41.460 --> 19:46.800
You have this command and in specific version of MySQL, it's not going to be a command anymore.

19:48.680 --> 19:49.800
Thank you.

19:50.920 --> 19:57.000
Last but not least, you can't define a list of value in a URL parameter.

19:57.180 --> 19:59.060
Like, it's just not supported by the other specs.

19:59.060 --> 20:03.160
So, if a developer wants to do it, of course, they only send it in the body.

20:03.160 --> 20:04.860
That's what it's there for.

20:05.240 --> 20:06.180
No, of course not.

20:06.180 --> 20:10.980
Every single web server does something different and passes, like, turns an array of parameters into a list.

20:10.980 --> 20:19.750
The best way to deal with this kind of obfuscation is to work around it completely.

20:19.750 --> 20:27.050
We have one advantage as defenders, which is that we know what the application on the other side of the WAF is.

20:27.050 --> 20:28.170
We have some insight.

20:28.170 --> 20:32.050
We know that we could know the language, the framework, what it's expecting.

20:32.370 --> 20:40.350
And using that, you could tell the WAF to decode the incoming parameter just like the application would do it.

20:40.350 --> 20:42.910
It does not mean that we would be able to decode everything.

20:43.110 --> 20:44.450
But in practice, you don't care.

20:44.450 --> 20:49.450
Because if the application can't decode a parameter, then the parameter can't harm it.

20:50.090 --> 20:51.350
It's not perfect.

20:51.350 --> 20:58.510
Specifically, it won't work if the parameter is integrated by something else, so specifically XSS, where the final target is a browser.

20:58.510 --> 21:04.230
But it's very effective against all kinds of URL encoding, HTTP shenanigans.

21:04.230 --> 21:09.510
Like, if you can just extract what the application is going to see, then you're golden.

21:09.510 --> 21:14.610
Moreover, another problem WAFs need to deal with is performance.

21:14.650 --> 21:19.550
The way most WAFs are set up is they add their latency to the response time of your application.

21:19.610 --> 21:32.510
Meaning, if your application answers in, like, two milliseconds, and you spent a lot of resources to optimize it, and the WAF just barges in and adds, like, 100 milliseconds of latency, that's unacceptable.

21:32.790 --> 21:36.150
So WAFs need to be able to fit within those constraints.

21:36.330 --> 21:45.790
Moreover, even if you're not under attack, we notice that even a small minority of long payload is enough to tank the performance.

21:45.950 --> 21:48.130
Like, surprisingly little.

21:49.670 --> 21:56.390
What this means is that you have a few constraints that WAFs are never really going to be able to work around of.

21:56.390 --> 22:07.230
So, for instance, if your WAF is not passing the body, and the application is expecting a large JSON payload, then all the attacker has to do is to put the attack at the end of the payload, and they're in.

22:09.010 --> 22:12.930
Some WAFs also have some constraints on the time they are allowed to take.

22:12.930 --> 22:18.470
And if they start taking, like, let's say more than five milliseconds, all right, they disconnect, they are like, there's too much impact.

22:19.310 --> 22:27.650
And all an attacker has to do is to increase the load on the WAF just by sending a bunch of requests, and, yeah, they're in.

22:28.670 --> 22:31.850
And, yeah, finally, the obfuscation, the WAF can do it.

22:31.910 --> 22:36.250
It can try to parse the parameter as a browser would do it, but it's expensive.

22:36.250 --> 22:39.250
So you need to figure out how do you want to spend your budget.

22:39.250 --> 22:49.150
And you might decide, okay, this decoding would be very effective, but actually if I use it on all of my rules, I'm, like, spending half my time just doing decoding and not actually running rules.

22:50.250 --> 22:54.590
There are a few solutions to that, such as running the WAF async.

22:55.130 --> 23:07.110
They all have, like, terrible problems, from not being able to block to you could direct all of your traffic to some kind of cloud infrastructure, but then you're adding latency, you're saying all of your traffic don't know where.

23:07.390 --> 23:09.310
So, yeah, that's kind of terrible.

23:11.570 --> 23:16.170
Finally, WAF, and I'm going to blow your mind, don't know what they don't see.

23:16.190 --> 23:21.670
So if you have an attack that the WAF don't catch, the WAF won't be able to tell you that you are under attack.

23:22.070 --> 23:26.450
What this means is that to be effective with WAF, you kind of need to do threat intel.

23:26.450 --> 23:33.510
You need to be able to do quick and quiet deploy of rules to be able to know what's happening in the wild.

23:33.510 --> 23:35.330
Doing some kind of shadow deployments.

23:36.050 --> 23:39.350
The scale at which you do that depends on what you can do.

23:39.350 --> 23:43.570
Like, it can be an only pot, but then you're mostly going to catch against the noise of the internet.

23:43.870 --> 23:52.690
You may be able to do it on your internal services, but, yeah, you'll get a better idea of what an actual attacker is going to do for your kind of application.

23:52.950 --> 23:59.290
And if you're a vendor and can work with it with your customers, you can even deploy it in customer environments.

23:59.290 --> 24:04.830
And that's amazing, because then you see a very broad diversity of attacks.

24:04.830 --> 24:07.910
Like, you see what the actual threat landscape is like.

24:08.290 --> 24:15.430
And when you do and you catch someone, WAFs are really good at leveraging mistakes.

24:15.430 --> 24:20.690
If you find any identifying pattern in an attacker, you can leverage it.

24:20.690 --> 24:23.910
Be it user agent, they're using this old version of Firefox.

24:23.930 --> 24:25.910
All right, I'm just going to match everything from that.

24:25.910 --> 24:27.990
It could be the IP or the range of IPs.

24:27.990 --> 24:30.670
It could be the domain they're fetching their attacks from.

24:30.670 --> 24:36.490
It's very common for accesses to load the payload from some given domain.

24:36.670 --> 24:38.330
Or, and that's the best one, typos.

24:38.550 --> 24:39.510
The attacker does a typo.

24:39.510 --> 24:44.670
All right, I just want to match all of the typo headers.

24:44.730 --> 24:50.910
And then once you have all of that, you dump all of the attacker traffic and you burn it all at once.

24:51.170 --> 24:53.270
And yeah, destroy that toolkit.

24:55.750 --> 25:03.110
So, we talked a bit about what WAFs are, what their issues are, what the false positive, false negative, what they're good at.

25:03.110 --> 25:06.050
Let's talk about making them better for end users.

25:06.950 --> 25:19.010
The first and most important point is you need to embrace the strength of the WAF and stop seeing a WAF as a protection tool.

25:19.610 --> 25:21.330
It won't be very good at that.

25:21.330 --> 25:28.950
If you want something to catch every single exploit going to your application, there are things, there are products that do that.

25:28.950 --> 25:30.250
There are RAS, there are IAS.

25:30.370 --> 25:32.750
There are some solutions, but WAFs are not it.

25:32.750 --> 25:34.810
What a WAF is, is a monitoring tool.

25:34.810 --> 25:40.310
A WAF will tell you that you're under attack and give you a feeling for the kind of attacks that the attacker is sending.

25:40.310 --> 25:42.110
It won't give you everything.

25:42.250 --> 25:44.270
If you wanted to do it, you can.

25:44.290 --> 25:47.230
It's called, like, here, this rule, trade secret.

25:47.270 --> 25:48.710
You just match that star.

25:49.210 --> 25:50.490
You can get everything.

25:50.730 --> 25:52.330
It will be totally unusable.

25:54.910 --> 25:57.130
Next one, rule testing.

25:57.890 --> 26:01.850
You can have a good turnkey experience in a WAF.

26:01.850 --> 26:07.110
But for that, rules need to have been tested on every single kind of workloads.

26:07.150 --> 26:10.130
And this requires massive scale.

26:10.130 --> 26:17.750
On top of it, whoever is doing the rule qualification will need to decide how much noise is good enough.

26:17.750 --> 26:24.470
And that's going to depend from a deployment perspective, from a company perspective, from a... yeah.

26:24.470 --> 26:27.230
It even changes on an engineer basis.

26:29.090 --> 26:36.690
The best way for someone to guarantee that the rule is going to work is to do some kind of shadow deployment, meaning running the rules on your environment without blocking.

26:37.630 --> 26:38.890
And, yeah.

26:39.170 --> 26:43.050
Doing all of that, you need to make sure not to catch any PII because otherwise you're in trouble.

26:45.050 --> 26:45.890
All right.

26:45.890 --> 26:49.090
Next up, you can try to leverage your application context.

26:49.090 --> 27:00.410
Meaning, if you're able to give data about your application to your WAF, like, telling it which language you're running, telling it which framework you're using, then, in that case, you'll be able to increase the precision.

27:00.410 --> 27:01.590
Let me give you an example.

27:01.610 --> 27:03.650
You're running a JavaScript application.

27:03.650 --> 27:05.410
You're receiving a bunch of PHP attacks.

27:05.410 --> 27:07.490
Well, you don't really care about those.

27:07.490 --> 27:09.090
They're not going to hurt your application.

27:09.090 --> 27:12.090
So, what you need to do is just discard those.

27:12.330 --> 27:20.030
If you're running some kind of PHP, for example, the SilverStripe framework, it was vulnerable to XSS in older versions.

27:20.710 --> 27:26.310
Well, if you're not running, if you're running up to the latest version, you also don't care about the alerts that are targeting the older version.

27:26.310 --> 27:27.570
So, yeah.

27:27.570 --> 27:29.990
If you're able to do that, you'll increase your accuracy.

27:30.110 --> 27:46.390
And one other side effect that can be good for you is you're also able to detect threat actors that will be sending, for example, Java attacks to your app when you're not running any Java, and you can kind of increase the attention that you're giving to this malicious IP and gather a bunch of threat intel on top of that.

27:46.810 --> 27:56.150
The only downside is it's going to be a bit challenging, meaning you have to have your security team work with your engineering team, and God knows it can be tricky to do sometimes.

27:56.310 --> 28:04.210
So, if you're able to do that, you can build this feedback loop that will be improving greatly your experience with the WAF.

28:05.790 --> 28:20.770
And the last element that you can try is to tune the response to the attack, meaning if you're able to catch a specific IP that's been targeting your application for a while, you could dynamically roll out a new rule set for this specific IP and catch more attacks coming from it,

28:20.770 --> 28:23.750
and you could catch everything and see what's coming up.

28:23.770 --> 28:36.270
And , yeah, if you're able to do that, and on top of that, what you could try, if you're unsure if the actor is actually malicious, we should be able to enable different types of responses.

28:36.270 --> 28:40.930
First, we should be able to have a capture and then only block after.

28:41.910 --> 28:46.410
Remember, we talked a bit about how we can do some analysis of false positives.

28:46.410 --> 28:55.570
If we're also able to leverage that to feed that back to the WAF and build dynamically a bunch of passive rules so we don't have as many false positives, it's even better.

28:55.570 --> 29:00.250
We could be even more confident when we actually enable the WAF in blocking mode on some rules.

29:01.190 --> 29:04.210
All right, this is our final takeaways.

29:04.830 --> 29:11.030
If you're a defender, look at your WAF more as a monitoring system than as a protection system.

29:11.250 --> 29:17.350
You should try to launch your false positives because this way you will be able to leverage the actual alerts that you get.

29:17.350 --> 29:22.330
And if you're building some kind of rule set, make sure that you keep in some flexibility for your engineering team.

29:22.330 --> 29:30.050
Meaning if you do very restrictive type of rule set and as soon as your engineers are changing the app, they're breaking everything, it's not worth it.

29:30.470 --> 29:39.870
If you are a vendor, well, I think it should be our collective mission to propose to our users a very low noise rule set.

29:40.110 --> 29:46.770
And then also support them in their efforts to actually analyze their triggers and the trends that they have.

29:47.530 --> 29:53.230
And if you're collecting any type of threat intelligence, please share it across all of your customers so everyone can benefit from it.

29:54.070 --> 29:59.070
And last, if you're an attacker, well, you're in luck because there will always be bypasses to the WAF.

29:59.070 --> 30:02.270
We've talked about them because of the WAF's nature.

30:02.570 --> 30:11.270
So keep in mind that you should probably rotate your infrastructure because we will leverage all the mistakes that you make and if you don't rotate, we'll catch you and we'll thank you for that.

30:11.270 --> 30:18.270
And then if you have to invest in one type of application, please only invest in ambiguous interpreted obfuscation.

30:18.270 --> 30:20.790
HTTP is worthless.

30:21.130 --> 30:24.050
Alright, we're at the end.

30:24.170 --> 30:25.890
Thank you for listening to us.

30:25.890 --> 30:31.690
applause music music music music

