# 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