Hi all. Sorry for the delay to start. I have some problems in the laptop with the web application file we should use to the demonstration. Well, who am I? My name is Wendel. I work in information technology more than 10 years. I work for a company in Brazil called Security Labs. We work for a credit card company, government, and other big companies in Brazil. I'm affiliated to Hockeyaholic, which is an international group of security research. I had been working with penetration testing the last three years. I had discovered some vulnerabilities in web mails, like OpenWebMail, WebMeow, and the others. Access points, like deletion, etc. Link, Citrix Metaframe, and the other softwares. I wrote some tools that was used in some magazines famous around the world, like Hacking9, and the PC World. I also spoke to some conference very famous in Brazil, like Hackers to Hackers Conference, Code Breakers, and was invited to speak to others, like IT Underground in Italy, and the It One Take One Mexico. Well, I am from Brazil. I am from Brazil. I am from Brazil. I am from Brazil. I am from Brazil. When I arrived here, everybody spoke to me about Brazil. Soccer, what do you think about the next games, holiday stuff. So yes, I'm from Brazil, the city of Pelé, and the slides again speak by itself. What do you see in this presentation? What is the WAF we are speaking about, type of operations, common topology, passive and reactive modes, tricks to detect WAF systems, tricks to fingerprint WAF systems, genetic evasion techniques, specific techniques to evade WAF systems, and what they fail to protect. Well, we have a small description retrieved from the web application security consourcing glossary that basically say that web application firewalls are a kind of firewalls specific to layer 7 applications, in the case to the web application, that try to protect the application from hostility attacks in this specific layer. Well, they are also called deep impact inspection firewalls because they look at every request and they are able to look at response, looking for problems in HTTP, HTTPS, SOAP, XML, services, web services, and the others. Some web application firewalls look to signature attacks, like you see in many firewalls. And also, uh, abnormal content behavior problems that, basically, are the same we see in EDS and EPS technology. The web application firewalls can be either softer, harder, or appliance. And, basically, uh, they try to protect a web server. Well, some notes about the definition. Uh, some new web application firewalls can work both with attack signatures and abnormal behavior. Some systems not necessarily need to be in front of a web server, as most, uh, where in most places we're accustomed to see. They can be directly putted in the machine where the web server is running. There is not only, as described in some older documentation, There is not only, as described in some older documentation, that are really used as reference, able to detect only attacks in the incoming packets. It's able to detect attacks in inbound and the outbound packets. Basically, there are three types of operation modes. There are negative modes, that are based in a kind of black list. There are positive modes, which are a kind of white list based. And mixed mode, and mixed mode, that's what the modes are based on. The most famous web application nowadays uses a kind of negative mode and a kind of positive mode. Negative security model recognizes attack by relaying a database of expected attack signatures, like most of the EDS and EPS that we have today on the market. For example, look for any page or any argument with the user input matching any potential cross-site scripting strings. This can be, for example, strings, string.fronsharkode, and a combination of all these strings. The good point of this kind of operation mode is that it's very fast to install and use. Basically, you have a pre-built group of rules that try to detect the most common attacks. So you basically get an appliance or a software, install, and this is running. The bad point is it's so generic, so in general you have a high number of false positives, more time to process, and also a small number of protection. Positive security model also... Basically, it's a kind of enforcement of the application logic. For example, if you have a script called the news.jsp, and it has a field called the ID of identification, that only accepts numbers from number 0 to number 10, and always starting from number 0 and going to 65534. Basically, they construct a kind of rule that only allows this kind of data, this kind of digit, start from this number to this number, and all other data will be exceptions and not be processed. Well, by the nature of the rule that's much more small, and it's much more fast and have better performance, and they also provide less false positives when you have good rules. The bads are it takes much more time to implement. Some web application files in the market provide some tools to automatically generate this kind of rules. What they call, in general, automatic learning mode, or similar name. This kind of stuff is good, and they are helping a lot in generating these rules. The big problem is that this rule is never perfect, and it should work automatically. They need basic to have human reviews, else they will also be so leaked in a fashion that it doesn't generate a lot of false positives. And it makes the attacker's life much more easy. Well, the mixed mode is basically the use of positive and negative models together, which is happening most of the time. It's the result of the today's web application file. However, in general, all have one that is predominant. Negative or positive model. Well. In general, WAF systems can be used in three different network topologies. Between a web server and a web client. This is the most common that we see in the internet. Also, which people call, like, reverse proxy. We have a web application file in a reverse proxy. Appliance, or a machine that is seated between the web client and the web server. The second is integrated in the all web server, which is more common in small companies. And the third option that's not so common, that's directly connected in the switch, in part mirror, span, or HAP that are other asynchronous names to the same, that basically get a copy of all the data that a network, that a port get. It's replied to another one when it's running the WAF system. Passive or reactive. Most WAF systems work both passive and reactive mode. In general, in the first days, they are running in passive mode to identify false positives, and in special when you are using some kind of automatic learning mode technology to detect this kind of problems, and fix before putting it in a production environment. In general, when it's running very well with .generate false positives, it starts to run in reactive mode. A little back from Brazil. Here we have some famous guys from Brazil that probably all should be. The second thing that everybody asked me when I arrived here, Hey, and Brazilian Jiu-Jitsu? What happened? It really works? Blah, blah, blah. That's the answer. Brazilian Jiu-Jitsu really works. We can see Anderson Silva, Royce Grace, Rodrigo Minotaur, and many others. Well, here we have some tricks to the fat WAF systems. Well, WAF systems. Leave several points that can be used that permit us to detect them. Example. Cooks. We have example of Citrix Net Scholar. Citrix Net Scholar, some case that on cook in the application that allow us to detect it's running. As we can see in the cook field, we have NES that is a a synchron of Net Scholar underline AF, and the other names. This kind of cook allow us to identify this kind of system. We can see in a in a real life site. Here. This site is a real site on the internet using Net Scholar from Citrix. We can see the cooks. It's added. To the application. And consequently, allow us to detect the presence of the web application file. It's a common example of single pointing that the the web application files add and should never happen since it should be stealth to the attackers. Well. Header rewrite. Some WAF products allow rewriting of HTTP readers. The most common is the server field. What happen? Sometimes, some web application files, when you request a normal and valid URI or URL, they respond with a valid 200 code. And the server field is set for the name of the web server or Apache, Internet Information Service, whatever. However, some products, when we request a invalid or a still URL or URI, it is simple. Removing the server field. So, it's a thing that we can identify that there are some systems that can be a WAF that is protecting the site. And also some others WAF applications only override or allow the reader rewrite when we send some bad content. For example, requesting a hostility content. Below we have an example. A valid and non-hostility request should return a 200 OK status code and with the server that is the real server content. Apache 2.2.9 running in Unix. Within the same server we request a hostility request. For example, a well-known web exploit that this web application triggered, we can get the following response. The server was changed to Netscape Enterprise 4.0. So, it's another problem in some web application products. They only apply the HTTP the reader rewrite in some circumstances that allow us to identify their presence too. Some WAF vendors return different HTTP response error codes in the same URL. Valid one or not. If you insert a hostility parameter for example just to be more clear it's far away to be good. Suppose we had not in this case for example a page no is index.php dot ID equal 123 For example it's a kind of suppose valid request and is processed. If we put in the same request that always return the code 200 for example it should be processed OK. If we just change the 123 to something like pipeline ID or ID that is hostility content in general people trying to execute operating system command this can return for us a different HTTP response code for example 404 as if the page index.php doesn't exist which is not true. So we can be sure that it's not the content of the web server and the application in the middle like a web application file. Also the same happen if you request parameters that doesn't exist. For example no exist and the same parameters. It will return in general errors 424 423 500 and the other. So this kind of of returns can help us to identify the web application files. Here is a valid example that was used in one of the application files we tested. A valid request with hostility parameter that doesn't exist returned 501 status code method not implemented. For sure it's not valid. And also we could note that the options sorry, the allow was changed because the allow option of this HTTP header in the normal request never returned the trace option. So there are a lot of small points that can be used to detect this kind of systems. Well, back in. Some web some of vendors provide a filter to close connection. You can use it to drop the connection, block users and they also have the possibility to interact with files, external files. Well, ModSecurity is a common example. They have a filter called the drop action that immediately initiate a connection close action. Using a thin packet attackers can launch well-known attacks that mismatch the built-in rules from ModSecurity and analyze the back to the thin packet and try to identify the presence of a web application file possibility ModSecurity. This kind of filter is not available in other versions of ModSecurity. Some of these techniques we are using to identify web application files can be used also to identify intrusion prevention systems that are available on the market. What more about Brazil? Well, back in. Tricks to fingerprint WAF systems. All WAF systems have a built-in group of rules in negative mode that are that rule is based in black list that you spoke on the start of the presentation. These rules are different in each product. These rules can be specific to a well-known vulnerability. For example, the old EES Unicode attack can be a generic rule for a well-known class of vulnerability like SQL injection, cross-site scripting, and the others. And in general, these rules are associated with a action like drop the request, redirect to another page, etc. Attackers can create a set of attacks that test for a range of vulnerabilities that most WAF systems protect against or not. In this way, we are able to identify building rules of a product and consequently what product it is, what it means. We can generate a database of a big variant of web application attacks that some web application files detect and the others not. Based in the detection or not detection, we can identify the software's For example, suppose we send a request with a HTTP method that is different from 1.0 or 1.1 For example, using 0.9 Some web application files detect this and block the contents or return a different HTTP code or can redirect you to another page, etc. Request content language in a method which is different from POST. It's the same. It's not a valid request that all web application files detect but some detect URI with recursive path even invalid. We can request, for example, URI accessing recursive paths even that doesn't exist. Some web application files will detect the recursive path using UNIX notation or Windows notation. Also it can be used to detect the difference between them. Request where cookie matches the CMD name that is also detected by the full by some web application files by old or not. Request where the URI matches the string or the URI itself USER X11R6 being externe. In general, we can create a really big database of this kind of attacks and run against most web application files and we can detect based in what can detect and provide a different response for us or not and in this way identify what web application file it is. More or less like we do probes in operation system. Basically the idea is the same. The attacker can go deeper and create several mutations of the same attack using for example evasion methods. These evasion methods can make a well known rule be bypassed or not and this also can be really useful to identify more precisely systems. Sometimes identify different versions. A new version from an old version. Also some attacks presented on the start on the tricks to detect WAF systems in the first slide can be used and help to identify systems like the example of Citrix Net Scholar. These techniques can be used to generate a big database and as we've spoken to create tools to detect this kind of web application files automatically. Well, generic evasion techniques. Today we have a wide range of techniques to evade EPS and some WAF systems. Most of these attacks works because we have bad normalization for example encoding etc. and the canalization that the implementation in the WAF does not work very well. Weak hulis. The full weak hulis built in the WAF systems. We can see a big number of products in the marketing that have pre-built hulis that are really weak and they allow a big number of possibilities of evasion. Evasion at network transport layer in some EPS and some WAF systems depending when they are running. For example if they are running in port mirroring. Well, here we have some examples of common generic evasion techniques. A very common generic evasion techniques to bypass some WAF systems is adding SQL comments to parameters instead of space to try bypass WAF systems and some EPS systems. I also use putty words in case sensitivity and in case insensitive to try to defect some of these hulis too. This too is very common. SQL query encoding is common. We use resources that the own database provides for us like stored procedures etc. that allows the attacker to encode and decode data. For example to exit the small directly in the database. In this way we can bypass some EPS and the WAF system in some case. Double encoding that basically is the same idea of the original encoding but the sigging itself for example the percent is encoded too. So you add a double encoding. URI encoding like for example unicode forward slash that was possible some time ago don't remember exactly how much for example in the tipping point EPS using this kind of technique also applies to some EPS and some WAF systems. HTTP request smuggling that basically is a technique that some attackers use to create HTTP packet that will be parsed differently in the backend web server and in the web application file or reverse proxy or whatever that is in the middle of the connection. IP packet fragmentation in some case depending on the topology is possible that basically is the question of fragmentation and the reassembly to bypass the same. Brazilian carnival that everyone always ask probability all of you know and who don't know should go to Brazil to the carnival and you appreciate boys, girls, everybody. Specific techniques to evade WAF systems. Similar as attackers can fingerprint WAF system as presented they can use a technique to precisely identify which restriction of a rule applies to a specific class of vulnerability. What I mean. An attacker can insert a hostility SQL injection for example to a parameter and is expected to be detected and the action taken. For example a different HTTP error code be returned a page redirection etc or simply generate error code or the normal page be displayed depending of the web application the big point is we can try a high number of different hostility queries and discover exactly what SQL query is blocked and which is not. What word for example select from where exec XP underlying exec and the others query are used. If we are able to detect these strings that are used by the web application built in Hulus we can try to bypass them. Using try and error it's possible to identify the combinations of these strings which is allowed and which is not. Also it's common we have Hulus that is based on combinations. For example only select is not blacklisted but if we use together select from and where together it starts to be blacklisted. So basically in this information we can try to construct SQL injections in the case to bypass the web application file. Also also this can be used to deny also it can be used to detect how the rule was built. Let's get a real example. It's not can be used only with SQL injection. It can be used with a lot of other attacks like cross-site scripting and the others. Real life. In a penetration test we realized maybe three months ago we had a client in Brazil which is a bank that had we had made a penetration test before and we had we got the access to the system. So they got the solution from Citrix Net Scholar and now we made the penetration test again. All we have to do to bypass the Citrix with the same problem was to identify what strings was blacklisted and what not. What combination was and what not like in the previous slide. And then we identified the same query we used in the last time to retrieve a lot of information from the bank we could use just removing, remolding the query without new words in the query, using some database query encoding and removing all the single quotes. And the Citrix Net Scholar was bypassed. So a lot of the systems that people sell today that are WAF systems are really good but we cannot trust in the built-in rules. They are only, they help but they are really far away from being perfect. In general, what are big pitfalls that web application firewall have to have problems to detect? Cross-site scripting. Cross-site scripting is really hard to effectively detect and block. It's extremely mutable and consequently very hard to detect. In special when we are dealing with outbound traffic. The outbound traffic has rules that in general can't be so enforced like inbound. For example, in general we get a lot of news from third sites and other contents. These other sites or other contents can be hacked and used as a source to infect your site in the outbound connection even if using a web application firewall. File upload. Many web application firewalls do a great job in file upload. However, we have some tricks that's really hard to bypass. For example, when you insert web shells inside images and call it for example via local file inclusions via comments in JPEG and the others. Also, remote command execution based in server response is very hard to detect. Some web application firewalls in the last year maybe tried to detect some remote code execution like for example the return that when we type in a Unix machine the command id, the command uname, ps, ls. They have a kind of standard format and there are rules that try to identify this standard to identify it in the outbound traffic. It's a good idea at last in the start since it could detect a lot of people that had broke into the web server. But if the attacker had the access he's able to execute command on the web server, it's not possible to really detect since he can use a lot of tools that they all encode providing the Linux or even they all shell like bash. You can turn it in Xcode, you can do shift right, shift left and a lot of encoding in the output that will not trigger the rule. So this kind of detection is not always useful and can be easily bypassed. Other problems that is probably one of the most hard to detect is logical and design flaws which is extremely hard by the nature of the problem. Basically, suppose you have a bank and this bank have a place where you can check how much money you have in your account. It's common that this data like agency, account number is passed as parameter. If there are there is not a stronger check in the application to grant that your sessions, your cooks is related with your with this data that's passed this parameter, attackers can manipulate this kind of data and the access information from other users. This kind of problem is very hard to web application files detect and block and the holders in the same idea. Well, our time is finishing. We had 10 minutes. It's over. I would like to thank you, all of you. Also the site is looking for new members. We have a private forum where we share a lot of stuff. If someone is interested, we are looking for new members. Thank you all and sorry for the problems in the laptop and the delay to start.