#3256·DB-GPT

Unauthenticated file read via GET /api/v1/agent/files/download

Author: AvAl4nchCreated Sep 20, 2026Updated Sep 21, 2026

GET /api/v1/agent/files/download has no authentication, and its allow-list covers the whole install directory, so anyone who can reach the API reads .env and configs/*.toml.

Two things combine.

No auth. The router is declared and mounted with no dependency, and dbgpt_server.py adds only CORSMiddleware:

python
router = APIRouter()                       # no dependencies=[...]

@router.get("/v1/agent/files/download")
async def download_agent_file(file_path: str = Query(...)):

agentic_data_api.py never references check_api_key, so setting api_keys in the config does not protect this route either. The next endpoint in the same file does authenticate:

python
@router.get("/v1/agent/skills/download")
async def download_skill_package(..., user_token: UserRequest = Depends(get_user_from_headers)):

Allow-list is wider than the docstring. The traversal check itself is fine, but ROOT_PATH is in the list:

python
allowed_dirs = [
    os.path.realpath("/tmp"),
    os.path.realpath(os.path.join(PILOT_PATH, "tmp")),
    os.path.realpath(ROOT_PATH),           # the whole install
]

ROOT_PATH is the install root, which holds .env and configs/. The docstring says only /tmp and PILOT_PATH/tmp/ are allowed. Relative paths are joined onto ROOT_PATH, so the layout doesn't need to be known.

Confirmed on a real install (v0.8.2, uv sync --all-packages, dbgpt start webserver), no credentials sent: .env and configs/dbgpt-proxy-openai.toml both return 200, /etc/passwd correctly returns 403.

Fix: add the dependency the neighbouring route uses, and drop ROOT_PATH from allowed_dirs.

Unrelated but nearby: POST /api/v1/dbgpts/my/uninstall is also unauthenticated and passes name unvalidated into inner_uninstall, which does shutil.rmtree(INSTALL_DIR / name). It doesn't fire on current pip, because check=True on the preceding pip uninstall raises for any name containing a path separator. Worth validating name anyway.