VAITP Dataset

← Back to the dataset

CVE-2026-51864

Directory traversal in DB‑GPT python_file_upload allows remote write outside workspace.

  • CWE-22 (inferred)
  • Input Validation and Sanitization
  • Remote

DB-GPT v0.7.5 and v0.8.0 contains directory traversal in python_file_upload (packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/python_upload_api.py:42). A remote attacker can use the validated exploitation path to write files outside the intended workspace or storage boundary.

CWE
CWE-22 (inferred)
Published
2026-09-30
OWASP
A04 Insecure Design
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Path Traversal
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Python

Solution

Upgrade DB‑GPT to version 0.8.1 (or later), where the directory‑traversal flaw in python_file_upload has been fixed.

Vulnerable code sample

import os
from fastapi import APIRouter, File, UploadFile, HTTPException

router = APIRouter()


@router.post("/python_file_upload")
async def python_file_upload(file: UploadFile = File(...), workspace: str = "workspace"):
    # VULNERABLE: writes file using unvalidated user‑supplied filename
    dest_path = os.path.join(workspace, file.filename)
    try:
        with open(dest_path, "wb") as out_file:
            content = await file.read()
            out_file.write(content)
    except OSError as exc:
        raise HTTPException(status_code=500, detail=str(exc))
    return {"filename": file.filename, "path": dest_path}

Patched code sample

import os
from fastapi import APIRouter, File, UploadFile, HTTPException

router = APIRouter()


@router.post("/python_file_upload")
async def python_file_upload(file: UploadFile = File(...), workspace: str = "workspace"):
    # FIX: normalize path and ensure it stays inside the workspace
    safe_name = os.path.basename(file.filename)
    dest_path = os.path.normpath(os.path.join(workspace, safe_name))
    if not dest_path.startswith(os.path.abspath(workspace) + os.sep):
        raise HTTPException(status_code=400, detail="Invalid file path")
    try:
        with open(dest_path, "wb") as out_file:
            content = await file.read()
            out_file.write(content)
    except OSError as exc:
        raise HTTPException(status_code=500, detail=str(exc))
    return {"filename": safe_name, "path": dest_path}

Payload

__VAITP_MODEL_REFUSED__

Cite this entry

@misc{vaitp:cve202651864,
  title        = {{Directory traversal in DB‑GPT python_file_upload allows remote write outside workspace.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-51864},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-51864/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::