Proxy / WAF Protections Bypass
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Techniques from this research.
Nginx rule example:
In order to prevent bypasses Nginx performs path normalization before checking it. However, if the backend server performs a different normalization (removing characters that nginx doesn't remove) it might be possible to bypass this defense.
Nginx Version | Node.js Bypass Characters |
1.22.0 |
|
1.21.6 |
|
1.20.2 |
|
1.18.0 |
|
1.16.1 |
|
Nginx Version | Flask Bypass Characters |
1.22.0 |
|
1.21.6 |
|
1.20.2 |
|
1.18.0 |
|
1.16.1 |
|
Nginx Version | Spring Boot Bypass Characters |
1.22.0 |
|
1.21.6 |
|
1.20.2 |
|
1.18.0 |
|
1.16.1 |
|
Nginx FPM configuration:
Nginx is configured to block access to /admin.php
but it's possible to bypass this by accessing /admin.php/index.php
.
In this post is explained that ModSecurity v3 (until 3.0.12), improperly implemented the REQUEST_FILENAME
variable which was supposed to contain the accessed path (until the start of the parameters). This is because it performed an URL decode to get the path.
Therefore, a request like http://example.com/foo%3f';alert(1);foo=
in mod security will suppose that the path is just /foo
because %3f
is transformed into ?
ending the URL path, but actually the path that a server will receive will be /foo%3f';alert(1);foo=
.
The variables REQUEST_BASENAME
and PATH_INFO
were also affected by this bug.
Something similar ocurred in version 2 of Mod Security that allowed to bypass a protection that prevented user accessing files with specific extensions related to backup files (such as .bak
) simply by sending the dot URL encoded in %2e
, for example: https://example.com/backup%2ebak
.
This research mentions that it was possible to bypass AWS WAF rules applied over HTTP headers by sending a "malformed" header that wasn't properly parsed by AWS but it was by the backend server.
For example, sending the following request with a SQL injection in the header X-Query:
It was possible to bypass AWS WAF because it wouldn't understand that the next line is part of the value of the header while the NODEJS server did (this was fixed).
Commonly WAFs have a certain length limit of requests to check and if a POST/PUT/PATCH request is over it, the WAF won't check the request.
For AWS WAF, you can check the documentation:
Maximum size of a web request body that can be inspected for Application Load Balancer and AWS AppSync protections | 8 KB |
Maximum size of a web request body that can be inspected for CloudFront, API Gateway, Amazon Cognito, App Runner, and Verified Access protections** | 64 KB |
From Azure docs:
Older Web Application Firewalls with Core Rule Set 3.1 (or lower) allow messages larger than 128 KB by turning off request body inspection, but these messages won't be checked for vulnerabilities. For newer versions (Core Rule Set 3.2 or newer), the same can be done by disabling the maximum request body limit. When a request exceeds the size limit:
If prevention mode: Logs and blocks the request.
If detection mode: Inspects up to the limit, ignores the rest, and logs if the Content-Length
exceeds the limit.
From Akamai:
By default, the WAF inspects only the first 8KB of a request. It can increase the limit up to 128KB by adding Advanced Metadata.
From Cloudflare:
Up to 128KB.
Depending on the implementation of Unicode normalization (more info here), characters that share Unicode compatability may be able to bypass the WAF and execute as the intended payload. Compatible characters can be found here.
https://github.com/ustayready/fireprox: Generate an API gateway URL to by used with ffuf
https://github.com/rootcathacking/catspin: Similar to fireprox
https://github.com/PortSwigger/ip-rotate: Burp Suite plugin that uses API gateway IPs
https://github.com/fyoorer/ShadowClone: A dynamically determined number of container instances are activated based on the input file size and split factor, with the input split into chunks for parallel execution, such as 100 instances processing 100 chunks from a 10,000-line input file with a split factor of 100 lines.
Different techniques can be used to bypass the regex filters on the firewalls. Examples include alternating case, adding line breaks, and encoding payloads. Resources for the various bypasses can be found at PayloadsAllTheThings and OWASP. The examples below were pulled from this article.
nowafpls: Burp plugin to add junk data to requests to bypass WAFs by length
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)