0

Top 10 Ways to Bypass a WAF

In today's evolving cybersecurity landscape, attackers are constantly looking for ways to bypass security systems, and Web Application Firewalls (WAF) are no exception. As a crucial defense layer, WAFs analyze incoming traffic to block potentially harmful requests from reaching web applications. However, like all security mechanisms, WAFs are not impenetrable. This blog post delves into the top 10 ways attackers bypass WAFs, helping security professionals and hackers stay ahead of these techniques and ensuring CISOs remain vigilant about potential vulnerabilities.
WAFExploitVulnerability
Kathan Desai
October 17th 2024.
Top 10 Ways to Bypass a WAF

What is a Web Application Firewall (WAF)?

A Web Application Firewall (WAF) is a security mechanism that monitors, filters, and blocks HTTP/HTTPS traffic to and from a web application. Its primary purpose is to protect web applications from common cyber threats like cross-site scripting (XSS), SQL injection (SQLi), file inclusion attacks, and other types of malicious payloads. WAFs analyze the data that flows between the internet and a web application, looking for patterns of attack and preventing potentially harmful traffic from reaching the application.

Purpose of a WAF

The role of a WAF in a security strategy is critical because web applications are increasingly targeted by hackers. As more organizations move services online, they become prime targets for attackers looking to steal data, disrupt services, or gain unauthorized access to sensitive systems.

A WAF provides several key functions:

  1. Traffic Filtering: It inspects incoming HTTP requests and blocks malicious traffic based on predefined rules.
  2. Attack Prevention: It actively mitigates the risk of common web vulnerabilities, including XSS, SQL injection, remote file inclusion (RFI), and others.
  3. Access Control: WAFs can be configured to restrict access to certain parts of a web application, ensuring only authorized users can access sensitive data.
  4. DDoS Mitigation: Some WAFs provide built-in protection against distributed denial of service (DDoS) attacks, preventing attackers from overwhelming a web application with excessive requests.

How Does a WAF Work?

WAFs typically operate at the application layer (Layer 7) of the OSI model, monitoring HTTP/HTTPS requests. They are placed in front of a web application to inspect traffic before it reaches the application server. WAFs rely on various detection mechanisms, including:

  • Signature-based Detection: It compares traffic against known attack patterns.
  • Behavioral Analysis: It identifies abnormal behavior that deviates from the norm.
  • Rule-based Detection: Administrators can define custom rules for specific attack patterns.

Famous WAF Services

Several companies offer Web Application Firewall services, some of the most notable include:

  • AWS Web Application Firewall (AWS WAF): A cloud-native service that works with AWS services to protect applications.
  • Cloudflare WAF: Part of Cloudflare’s suite of performance and security products, offering protection for web applications on their CDN.
  • Imperva WAF: A highly regarded enterprise-grade WAF solution that provides robust protection against a range of threats.
  • F5 Advanced WAF: A solution aimed at preventing attacks at both the application and API levels.
  • Azure Web Application Firewall: Part of Microsoft’s Azure security services, designed to protect cloud applications hosted on their platform.

The Importance of a WAF in Vulnerability Protection

A properly configured WAF plays a vital role in securing applications. However, it's important to understand that WAFs are not foolproof. Despite their ability to block many common attacks, they can often be bypassed by skilled attackers. For cybersecurity professionals, particularly penetration testers and red teams, understanding how WAFs function and the weaknesses in their detection systems is key to finding vulnerabilities.

Now that we’ve established the purpose and functionality of a WAF, let's delve into the top 10 ways attackers bypass WAFs, helping security experts and hackers alike to understand these weaknesses and improve their security measures.


Top 10 Ways to Bypass a WAF

1. Payload Encoding and Obfuscation

One of the simplest yet most effective methods to bypass a WAF is through payload encoding. Encoding alters the representation of the attack payload, making it harder for the WAF to detect malicious patterns. Common encoding techniques include:

  • Hex encoding: Replacing characters with their hexadecimal equivalent.
  • Base64 encoding: Converting the entire payload into a Base64 string.
  • URL encoding: Encoding certain characters as %xx (where xx is the hexadecimal representation).

Example:
Instead of submitting:

1SELECT * FROM users WHERE id = 1; 2 3

An attacker could encode the payload in hexadecimal:

1%53%45%4C%45%43%54%20%2A%20%46%52%4F%4D%20%75%73%65%72%73%20%57%48%45%52%45%20%69%64%20%3D%201; 2 3

Although the server might process this as valid SQL, a WAF that doesn’t decode the payload correctly could miss the attack.

2. HTTP Parameter Pollution

HTTP Parameter Pollution (HPP) involves sending multiple parameters with the same name in a single request. Many WAFs expect only one occurrence of each parameter, so they may overlook the second or subsequent parameters. Attackers can exploit this by inserting malicious values in the additional parameters.

Example:
A request like:

GET /login?username=admin&password=admin123&password=malicious_payload

could bypass a WAF if it only inspects the first password parameter. The server may still process the second password value.

3. Case Transformation

Some WAFs rely on pattern matching based on specific case-sensitive keywords. Attackers can bypass detection by changing the case of the characters in their payload, rendering the WAF unable to recognize the threat.

Example:
Instead of:

1SELECT * FROM users WHERE username = 'admin'; 2 3

An attacker could send:

1SeLeCt * FrOm users WhErE username = 'admin'; 2 3

The WAF might not detect the query as malicious due to its failure to normalize case. This tactic is particularly effective against less sophisticated WAFs that rely on exact pattern matching.

4. IP Fragmentation

IP fragmentation is a technique that takes advantage of how data is transmitted over networks. By breaking up the payload into multiple smaller fragments, attackers can bypass WAFs that fail to reassemble packets before inspection.

Example:
Instead of sending a single complete HTTP request, an attacker might break it into multiple IP packets:

GET /fragments/part1
GET /fragments/part2

Each fragment contains a portion of the malicious payload. The WAF may inspect each fragment in isolation and fail to identify the full attack, allowing it to pass through once the server reassembles the fragments.

5. JSON and XML Payloads

Modern web applications often use REST APIs and SOAP-based services that transmit data in JSON or XML formats. Many WAFs are designed to protect traditional web applications and may not fully inspect the content of JSON or XML payloads.

Example:

1{ 2 "username": "admin", 3 "password": "<script>alert('XSS')</script>" 4} 5 6

Attackers can inject malicious code into these formats, bypassing detection by a WAF that doesn’t inspect the payload contents deeply enough.

6. Session Awareness Bypassing

Some WAFs are stateless and treat each request independently. Attackers can bypass these systems by spreading their attack across multiple requests, sending innocuous payloads first, followed by the malicious one.

Example:

  1. Request 1: GET /login
  2. Request 2: POST /login (valid credentials)
  3. Request 3: POST /profile?id=1'; DROP TABLE users;--

If the WAF only inspects each request independently, it may not detect the SQL injection attack in request 3. A state-aware WAF would recognize the sequence of events leading to the attack.

7. 404 Bypassing

When a resource on a web application doesn’t exist (resulting in a 404 Not Found response), some WAFs apply less scrutiny. Attackers can exploit this by intentionally targeting non-existent pages, which may lead to reduced security checks by the WAF.

Example:

GET /nonexistentpage?payload=<script>alert('XSS')</script>

The WAF might ignore the request since the target page does not exist, but the server could still process the payload.

8. DNS-Based Attacks

Many WAFs are domain-specific, meaning they analyze traffic based on domain names. However, attackers can bypass this by sending requests directly to the server's IP address, avoiding the WAF’s domain-based filters.

Example:
Instead of sending a request to:

GET <http://example.com/login>

The attacker sends:

GET <http://192.168.1.1/login>

This tactic circumvents domain-based rules that may be configured on the WAF, allowing the attacker to reach the application directly.

9. Rate Limiting Bypass

WAFs often employ rate-limiting to prevent brute-force and automated attacks. Attackers can bypass this by distributing their requests across a botnet or slowing down their request rates to fly under the radar.

Example:
Instead of sending a burst of login attempts, attackers could distribute their requests across hundreds of IP addresses or spread them out over an extended period, effectively bypassing rate-limiting rules.

10. Exploiting Zero-Day Vulnerabilities

A zero-day vulnerability is an unpatched flaw in software that is unknown to the vendor at the time of the attack. Since WAFs rely on known attack patterns or rulesets, they may not recognize or block zero-day exploits. Attackers who discover such vulnerabilities can bypass WAF protection entirely.

Example:
A vulnerability in a commonly used library or framework like Apache Struts might be exploited without a corresponding WAF rule to block it. Until the WAF vendor releases an update, these

attacks can go undetected.


Tools to Bypass Web Application Firewalls (WAF) and How to Use Them

Bypassing a Web Application Firewall (WAF) is a critical skill for penetration testers and security researchers, especially when it comes to finding hidden vulnerabilities that a WAF might obscure. Various tools are available to help researchers test the effectiveness of WAFs and identify bypass opportunities. This section highlights some of the most effective tools that can be used to bypass WAFs, along with practical advice on setting up and using these tools for maximum impact.

1. SQLMap

SQLMap is an open-source penetration testing tool that automates the process of detecting and exploiting SQL injection vulnerabilities. It comes with various features to bypass WAFs by encoding payloads, adjusting attack vectors, and manipulating requests.

Features for WAF Bypass:

  • Payload encoding (e.g., base64, hexadecimal)
  • Randomized case transformation
  • HTTP parameter pollution

Setup:

  1. Install SQLMap:

    1git clone <https://github.com/sqlmapproject/sqlmap.git> 2cd sqlmap 3 4
  2. Use SQLMap with WAF evasion techniques:

    1python sqlmap.py -u "<http://target.com/page.php?id=1>" --level=5 --risk=3 --random-agent --tamper=between,randomcase 2 3
    • -random-agent: Randomizes the user agent to avoid detection.
    • -tamper: Allows you to apply encoding or transformation functions to evade WAF rules.

You can also chain multiple tamper scripts (between, randomcase, space2comment, etc.) to obfuscate the payload further and bypass signature-based detection in WAFs.

Recommendation:

Start with the tamper scripts that modify the most common SQL injection patterns, as many WAFs rely on detecting standard attack signatures.

2. WAFNinja

WAFNinja is a dedicated tool designed to bypass WAFs and test their resilience. It automates various attack techniques to evade WAF detection and provides easy-to-use modules for testing web application firewalls.

Features for WAF Bypass:

  • Payload obfuscation
  • Bypassing using encodings and HTTP parameter pollution
  • Payload fragmentation

Setup:

  1. Install WAFNinja:

    1git clone <https://github.com/khalilbijjou/WAFNinja.git> 2cd WAFNinja 3pip install -r requirements.txt 4 5
  2. Use WAFNinja to test WAF evasion:

    1python wafninja.py -u "<http://target.com/page>" --method get --payloads sql_injection.txt 2 3

    This will send SQL injection payloads while applying various obfuscation techniques to test the WAF.

Recommendation:

Test the tool’s payload obfuscation features on a variety of application endpoints. WAFNinja’s ability to test multiple attack vectors simultaneously makes it a powerful tool for WAF bypass testing.

3. Nmap with NSE Scripts

Nmap is a widely used network scanning tool that also includes scripts specifically designed for security testing. The Nmap Scripting Engine (NSE) provides a framework for creating and executing scripts that can be used for WAF evasion.

Features for WAF Bypass:

  • HTTP fragmentation
  • Custom user-agent injection
  • Manipulation of request headers and parameters

Setup:

  1. Install Nmap:

    1sudo apt-get install nmap 2 3
  2. Use Nmap with WAF evasion scripts:

    1nmap --script http-waf-detect --script-args="http-waf-detect.detectBodyContent" -p 80,443 target.com 2 3

This script checks if a WAF is active and then uses different techniques to attempt to bypass it.

Recommendation:

Nmap is best used in conjunction with other tools as a reconnaissance tool to first identify the presence of a WAF. From there, you can fine-tune attacks using SQLMap or other payload manipulation tools.

4. Burp Suite with Extensions

Burp Suite is one of the most versatile web vulnerability scanners and proxy tools used by penetration testers. With its robust extension store, you can integrate several WAF-bypass tools directly into Burp Suite for enhanced evasion techniques.

Features for WAF Bypass:

  • Encodes payloads in various formats
  • Custom fuzzing attacks via Burp Intruder
  • Extensions like Bypass WAF and Turbo Intruder for high-speed fuzzing and payload delivery

Setup:

  1. Install Burp Suite (Community or Professional Edition).
  2. Add the Bypass WAF extension from the Burp Suite BApp store:
    • Go to the Extender tab.
    • Click BApp Store and search for "Bypass WAF."
    • Install the extension.
  3. Start Burp Suite, intercept traffic, and use Burp Intruder for WAF bypass:
    • Set up Burp Intruder to launch attacks with customized payloads.
    • Use encoded payloads to test bypass mechanisms:
    1GET /page.php?query=SeLeCt%20*%20FrOm%20users 2 3

Recommendation:

Burp Suite’s combination of manual and automated testing, with an extensible platform via extensions, makes it a valuable asset for WAF testing. Ensure to rotate payload encoding strategies to maximize chances of bypass.

5. Commix

Commix (Command Injection Exploiter) is a tool specifically designed to test for command injection vulnerabilities. Many WAFs fail to adequately protect against command injection attacks due to improper sanitization of inputs.

Features for WAF Bypass:

  • Encodes and obfuscates command injection payloads
  • Custom payload splitting and fragmentation
  • URL encoding and random case transformation

Setup:

  1. Install Commix:

    1git clone <https://github.com/commixproject/commix.git> 2cd commix 3 4
  2. Use Commix to exploit command injection vulnerabilities:

    1python commix.py --url="<http://target.com/page.php?id=1>" --waf-bypass 2 3

Recommendation:

Commix can be particularly effective against WAFs that fail to adequately sanitize command injection vectors. Use the --waf-bypass flag to apply advanced obfuscation techniques.

6. OWASP ZAP with Scripts

OWASP ZAP (Zed Attack Proxy) is an open-source web application security scanner and is considered a strong alternative to Burp Suite. ZAP allows for heavy customization through scripts and fuzzing, which can be effective for bypassing WAFs.

Features for WAF Bypass:

  • Payload fuzzing
  • Support for tampering HTTP request headers
  • Obfuscating attack vectors via custom scripting

Setup:

  1. Install OWASP ZAP:

    1sudo apt-get install zaproxy 2 3
  2. Add scripts for WAF bypass:

    • Go to the Script Console tab.
    • Create a new HTTP sender script that modifies request payloads.
  3. Run an attack with customized payloads to test WAF evasion.

Recommendation:

OWASP ZAP is a highly flexible tool that can be extended through community scripts. It’s an excellent choice for pentesters who want to create custom WAF evasion scenarios or automate fuzzing with unique payloads.

7. Metasploit Framework

Metasploit is widely used by penetration testers and offers modules to bypass WAFs by using techniques such as encoding and fragmentation.

Features for WAF Bypass:

  • Payload encoding and transformation (e.g., Base64, XOR)
  • Fragmented payloads
  • HTTP request manipulation

Setup:

  1. Install Metasploit:

    1curl <https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb> 2 3
  2. Use Metasploit to test WAF evasion:

    1use auxiliary/scanner/http/waf_bypass 2set RHOSTS target.com 3exploit 4 5

Recommendation:

Metasploit’s built-in WAF bypass modules work well in conjunction with other tools for a full testing suite, including SQLMap or Commix for advanced payload customization.


Tips for Bypassing WAFs with These Tools

1. Experiment with Different Encodings

Tools like SQLMap and Commix allow you to encode payloads in different formats. Test with Base64, URL encoding, and hexadecimal encoding to bypass signature-based detections.

2. Use Fragmentation Techniques

Using tools like Burp Suite and Nmap, you can split payloads across multiple HTTP requests or IP fragments, making it difficult for the WAF to detect the attack.

3. Fuzzing for Vulnerability Detection

Fuzzing tools like Burp Intruder, OWASP ZAP, and Metasploit can be configured to automatically test various payloads and attack vectors to discover WAF bypass opportunities.

4. Combine Multiple Techniques

By combining multiple bypass techniques—such as obfuscation, encoding, and fragmentation—you can increase the chances of successfully bypassing even advanced WAFs.

5. Leverage Timing Attacks

Many WAFs block requests based on traffic rate and volume. Distributed attacks, delayed payload delivery, or slow requests can evade rate-limiting mechanisms on some WAFs.


Final Thoughts

WAFs are powerful tools for defending web applications, but they are not invulnerable. Attackers constantly develop new methods to bypass these defenses, and the tools discussed above are instrumental in identifying vulnerabilities that may be missed by a WAF. For security professionals, it’s essential to stay informed about the latest bypass techniques and ensure WAF configurations are up to date.


FAQs

1. What is the primary purpose of a Web Application Firewall (WAF)?

A Web Application Firewall (WAF) is designed to monitor, filter, and block malicious HTTP/HTTPS traffic to and from web applications. It helps protect web applications from common attacks like SQL injection, cross-site scripting (XSS), and file inclusion attacks by analyzing traffic and blocking suspicious activity.


2. Can a WAF prevent all types of attacks?

While WAFs are highly effective at mitigating many common web-based attacks, they are not foolproof. Skilled attackers can bypass WAFs using techniques such as encoding, fragmentation, or exploiting zero-day vulnerabilities. WAFs should be part of a broader security strategy that includes regular penetration testing, code reviews, and vulnerability assessments.


3. What are some common techniques attackers use to bypass a WAF?

Attackers often use techniques like payload encoding (Base64, hexadecimal), HTTP parameter pollution, IP fragmentation, altering case sensitivity, and zero-day exploits to bypass WAFs. These methods exploit weaknesses in how the WAF interprets or processes requests.


4. Which tools are commonly used by security researchers to bypass WAFs?

Popular tools used to test and bypass WAFs include SQLMap, WAFNinja, Nmap (with NSE scripts), Burp Suite (with extensions), and Commix. These tools offer features like payload encoding, HTTP parameter pollution, fuzzing, and obfuscation, making them effective for identifying WAF bypass opportunities.


5. How can I improve my WAF configuration to prevent bypass attempts?

To improve your WAF configuration:

  • Ensure it inspects and decodes all incoming payloads (Base64, hex, URL-encoded).
  • Enable session awareness so that multiple requests from the same session are evaluated collectively.
  • Regularly update WAF rules to detect and block new attack patterns.
  • Integrate behavioral and heuristic analysis for more adaptive threat detection.

Conclusion: Strengthening Your WAF Defense

While WAFs play an essential role in defending web applications, they are not foolproof. As attackers continue to evolve their techniques, it’s critical for security professionals to stay ahead of the curve. From encoding and obfuscation to exploiting zero-day vulnerabilities, the methods we’ve covered show that a determined attacker can often find ways to bypass a WAF.

To stay protected, ensure that your WAF is regularly updated, configure custom rules to address specific threats, and use a layered security approach, including code reviews, penetration testing, and continuous monitoring.

Table of Contents

  • What is a Web Application Firewall (WAF)?

  • Top 10 Ways to Bypass a WAF

  • Tips for Bypassing WAFs with These Tools

  • FAQs

  • Conclusion: Strengthening Your WAF Defense

Let's take your security
to the next level

security