# Proxy / WAF Protections Bypass
{% hint style="success" %}
Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** π¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** π¦ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
{% embed url="https://websec.nl/" %}
## Nginx ACL κ·μΉ μ°ννκΈ° μν κ²½λ‘ μ‘°μ
κΈ°μ [μ΄ μ°κ΅¬μμ](https://rafa.hashnode.dev/exploiting-http-parsers-inconsistencies).
Nginx κ·μΉ μ:
```plaintext
location = /admin {
deny all;
}
location = /admin/ {
deny all;
}
```
Nginxλ μ°ν λ°©μ§λ₯Ό μν΄ κ²½λ‘ μ κ·νλ₯Ό μνν©λλ€. κ·Έλ¬λ λ°±μλ μλ²κ° Nginxκ° μ κ±°νμ§ μλ λ¬Έμλ₯Ό μ κ±°νλ λ€λ₯Έ μ κ·νλ₯Ό μννλ κ²½μ° μ΄ λ°©μ΄λ₯Ό μ°νν μ μμ΅λλ€.
### **NodeJS - Express**
| Nginx Version | **Node.js Bypass Characters** |
| ------------- | ----------------------------- |
| 1.22.0 | `\xA0` |
| 1.21.6 | `\xA0` |
| 1.20.2 | `\xA0`, `\x09`, `\x0C` |
| 1.18.0 | `\xA0`, `\x09`, `\x0C` |
| 1.16.1 | `\xA0`, `\x09`, `\x0C` |
### **Flask**
| Nginx Version | **Flask Bypass Characters** |
| ------------- | -------------------------------------------------------------- |
| 1.22.0 | `\x85`, `\xA0` |
| 1.21.6 | `\x85`, `\xA0` |
| 1.20.2 | `\x85`, `\xA0`, `\x1F`, `\x1E`, `\x1D`, `\x1C`, `\x0C`, `\x0B` |
| 1.18.0 | `\x85`, `\xA0`, `\x1F`, `\x1E`, `\x1D`, `\x1C`, `\x0C`, `\x0B` |
| 1.16.1 | `\x85`, `\xA0`, `\x1F`, `\x1E`, `\x1D`, `\x1C`, `\x0C`, `\x0B` |
### **Spring Boot**
| Nginx Version | **Spring Boot Bypass Characters** |
| ------------- | --------------------------------- |
| 1.22.0 | `;` |
| 1.21.6 | `;` |
| 1.20.2 | `\x09`, `;` |
| 1.18.0 | `\x09`, `;` |
| 1.16.1 | `\x09`, `;` |
### **PHP-FPM**
Nginx FPM ꡬμ±:
```plaintext
location = /admin.php {
deny all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
```
Nginxλ `/admin.php`μ λν μ κ·Όμ μ°¨λ¨νλλ‘ κ΅¬μ±λμ΄ μμ§λ§, `/admin.php/index.php`μ μ κ·Όν¨μΌλ‘μ¨ μ΄λ₯Ό μ°νν μ μμ΅λλ€.
### λ°©μ§ λ°©λ²
```plaintext
location ~* ^/admin {
deny all;
}
```
## Mod Security κ·μΉ μ°ν
### κ²½λ‘ νΌλ
[**μ΄ κ²μλ¬Ό**](https://blog.sicuranext.com/modsecurity-path-confusion-bugs-bypass/)μμλ ModSecurity v3(3.0.12κΉμ§)κ° μ κ·Όλ κ²½λ‘(맀κ°λ³μ μμ μ )λ₯Ό ν¬ν¨ν΄μΌ νλ `REQUEST_FILENAME` λ³μλ₯Ό **λΆμ μ νκ² κ΅¬ννλ€**κ³ μ€λͺ
ν©λλ€. μ΄λ κ²½λ‘λ₯Ό μ»κΈ° μν΄ URL λμ½λλ₯Ό μννκΈ° λλ¬Έμ
λλ€.\
λ°λΌμ mod securityμμ `http://example.com/foo%3f';alert(1);foo=`μ κ°μ μμ²μ `%3f`κ° `?`λ‘ λ³νλμ΄ URL κ²½λ‘κ° λλκΈ° λλ¬Έμ κ²½λ‘κ° λ¨μ§ `/foo`λΌκ³ κ°μ νμ§λ§, μ€μ λ‘ μλ²κ° λ°μ κ²½λ‘λ `/foo%3f';alert(1);foo=`μ
λλ€.
λ³μ `REQUEST_BASENAME`κ³Ό `PATH_INFO`λ μ΄ λ²κ·Έμ μν₯μ λ°μμ΅λλ€.
Mod Security λ²μ 2μμλ λΉμ·ν μΌμ΄ λ°μνμ¬ νΉμ νμ₯μμ κ΄λ ¨λ λ°±μ
νμΌ(μ: `.bak`)μ λν μ¬μ©μ μ κ·Όμ λ°©μ§νλ 보νΈλ₯Ό μ°νν μ μμμ΅λλ€. μ΄λ λ¨μν μ μ `%2e`λ‘ URL μΈμ½λ©νμ¬ μ μ‘ν¨μΌλ‘μ¨ κ°λ₯νμ΅λλ€. μλ₯Ό λ€μ΄: `https://example.com/backup%2ebak`.
## AWS WAF ACL μ°ν
### μλͺ»λ ν€λ
[μ΄ μ°κ΅¬](https://rafa.hashnode.dev/exploiting-http-parsers-inconsistencies)μμλ AWSκ° μ λλ‘ νμ±νμ§ λͺ»ν "μλͺ»λ" ν€λλ₯Ό μ μ‘ν¨μΌλ‘μ¨ HTTP ν€λμ μ μ©λ AWS WAF κ·μΉμ μ°νν μ μμλ€κ³ μΈκΈν©λλ€. κ·Έλ¬λ λ°±μλ μλ²λ μ΄λ₯Ό νμ±ν μ μμμ΅λλ€.
μλ₯Ό λ€μ΄, X-Query ν€λμ SQL μΈμ μ
μ΄ ν¬ν¨λ λ€μ μμ²μ μ μ‘νλ κ²μ
λλ€:
```http
GET / HTTP/1.1\r\n
Host: target.com\r\n
X-Query: Value\r\n
\t' or '1'='1' -- \r\n
Connection: close\r\n
\r\n
```
AWS WAFλ₯Ό μ°νν μ μμλ μ΄μ λ NODEJS μλ²λ λ€μ μ€μ΄ ν€λ κ°μ μΌλΆμμ μ΄ν΄νμ§λ§ WAFλ μ΄ν΄νμ§ λͺ»νκΈ° λλ¬Έμ
λλ€(μ΄ λ¬Έμ λ μμ λμμ΅λλ€).
## μΌλ°μ μΈ WAF μ°ν
### μμ² ν¬κΈ° μ ν
μΌλ°μ μΌλ‘ WAFλ μμ²μ νμΈνκΈ° μν νΉμ κΈΈμ΄ μ νμ΄ μμΌλ©°, POST/PUT/PATCH μμ²μ΄ μ΄λ₯Ό μ΄κ³Όνλ©΄ WAFλ μμ²μ νμΈνμ§ μμ΅λλ€.
* AWS WAFμ κ²½μ° [**λ¬Έμλ₯Ό νμΈν μ μμ΅λλ€**](https://docs.aws.amazon.com/waf/latest/developerguide/limits.html)**:**
| |
---|
Application Load Balancer λ° AWS AppSync 보νΈλ₯Ό μν΄ κ²μ¬ν μ μλ μΉ μμ² λ³Έλ¬Έμ μ΅λ ν¬κΈ° | 8 KB |
CloudFront, API Gateway, Amazon Cognito, App Runner λ° Verified Access 보νΈλ₯Ό μν΄ κ²μ¬ν μ μλ μΉ μμ² λ³Έλ¬Έμ μ΅λ ν¬κΈ°** | 64 KB |
* [**Azure λ¬Έμ**](https://learn.microsoft.com/en-us/azure/web-application-firewall/ag/application-gateway-waf-request-size-limits)**μμ λ°μ·:**
Core Rule Set 3.1(λλ κ·Έ μ΄ν)μ μ€λλ μΉ μ ν리μΌμ΄μ
λ°©νλ²½μ μμ² λ³Έλ¬Έ κ²μ¬λ₯Ό λμΌλ‘μ¨ **128 KB**λ³΄λ€ ν° λ©μμ§λ₯Ό νμ©νμ§λ§, μ΄λ¬ν λ©μμ§λ μ·¨μ½μ κ²μ¬λ₯Ό λ°μ§ μμ΅λλ€. μ΅μ λ²μ (Core Rule Set 3.2 μ΄μ)μμλ μ΅λ μμ² λ³Έν μ νμ λΉνμ±ννμ¬ λμΌν μμ
μ μνν μ μμ΅λλ€. μμ²μ΄ ν¬κΈ° μ νμ μ΄κ³Όνλ©΄:
**μ°¨λ¨ λͺ¨λ**: μμ²μ κΈ°λ‘νκ³ μ°¨λ¨ν©λλ€.\
**νμ§ λͺ¨λ**: μ νκΉμ§ κ²μ¬νκ³ λλ¨Έμ§λ 무μνλ©°, `Content-Length`κ° μ νμ μ΄κ³Όνλ©΄ κΈ°λ‘ν©λλ€.
* [**Akamai**](https://community.akamai.com/customers/s/article/Can-WAF-inspect-all-arguments-and-values-in-request-body?language=en_US)**μμ λ°μ·:**
κΈ°λ³Έμ μΌλ‘ WAFλ μμ²μ 첫 8KBλ§ κ²μ¬ν©λλ€. κ³ κΈ λ©νλ°μ΄ν°λ₯Ό μΆκ°νμ¬ μ΅λ 128KBκΉμ§ μ νμ λ릴 μ μμ΅λλ€.
* [**Cloudflare**](https://developers.cloudflare.com/ruleset-engine/rules-language/fields/#http-request-body-fields)**μμ λ°μ·:**
μ΅λ 128KB.
### λλ
ν
```bash
# IIS, ASP Clasic
<%s%cr%u0131pt> == #changing the case of the tag
< #prepending an additional "<"
#using backticks instead of parenetheses
java%0ascript:alert(1) #using encoded newline characters