/

CVE-2025-68472

Severity:

HIGH RISK

(8.1)

Path Traversal in MindsDB File Upload API

CVE-2025-68472

Modified

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22, CWE-23, CWE-36

Impact:

Arbitrary File Read / Sensitive Data Exposure

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An unauthenticated path traversal vulnerability in the MindsDB file upload API allows arbitrary file reads from the server filesystem when using JSON-based uploads with a non-url source_type.

Because user-controlled path components are joined directly into filesystem paths without sanitization, an attacker can cause the server to ingest and expose sensitive files by moving them into MindsDB's internal storage.

Affected context

The issue arises in MindsDB deployments that expose the file upload API and accept JSON request bodies for uploads where source_type is not "url".

In this code path, the PUT handler in file.py directly concatenates user-provided values into a filesystem path and then reads from that path, moving files into MindsDB's storage layer.

Only multipart uploads and URL-based uploads are sanitized; JSON uploads bypass filename cleaning and normalization checks, creating a path traversal condition when combined with an accessible filesystem.

Exploit preconditions

  • Attack surface: Public or internal MindsDB HTTP endpoint handling file upload requests.
  • Required access: No authentication required; any network client that can reach the upload API can attempt exploitation.
  • Trigger point: A JSON-based PUT upload request with source_type set to a non-url value, containing crafted path segments in user-controlled fields.
  • Why exploitation is possible: The handler joins user input directly into filesystem paths without applying clear_filename or equivalent sanitization and without restricting path normalization, allowing traversal sequences (such as parent directory references) to resolve to files outside the intended upload directory.

Why this happens

The root cause is improper neutralization of user-controlled path input before it is used to construct filesystem locations, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

The file upload implementation applies validation and cleanup only to multipart and URL-based upload flows but omits these protections for JSON-based uploads.

As a result, the JSON code path effectively trusts the provided filename or path fragments and joins them directly into server-side paths.

This inconsistent input handling across different content types leads to a condition where directory traversal sequences can escape the intended upload directory and access arbitrary files.

Potential impact

  • Access to sensitive configuration files that may contain credentials, API keys, or connection strings.
  • Exposure of application logs revealing internal topology, queries, or user behavior.
  • Disclosure of environment-specific secrets (e.g., cloud metadata, environment variables written to disk).
  • Partial mapping of the server filesystem structure through trial-and-error requests.
  • Potential pivot to other attacks if sensitive data (such as database passwords or signing keys) is obtained.

General mitigation guidance

Effective mitigation centers on consistent, strict path handling and defensive file access patterns across all upload flows:

  • Apply the same filename sanitization and canonicalization routines (e.g., stripping directory separators, normalizing paths) to all upload variants, including JSON-based uploads.
  • Enforce a dedicated, fixed base directory for user-controlled files and validate that all resolved filesystem paths remain within that directory after normalization.
  • Treat any user-supplied path or name as untrusted data; operate on server-generated identifiers rather than directly trusting user filenames when constructing storage paths.
  • Separate privileges so that the component handling uploads runs with minimal filesystem permissions, limiting what files it can read or move even if input validation fails.
  • Centralize file access utilities so that developers cannot bypass safety checks by calling low-level filesystem APIs directly.

How teams detect issues like this

Detection typically involves both code-centric and operational approaches:

  • Static analysis: Configure rules to flag direct concatenation of user input into filesystem paths and to require normalization and base-directory checks for all file operations.
  • Code review: Examine file upload and import handlers for divergent code paths where some request types (e.g., JSON vs multipart) bypass shared sanitization helpers such as clear_filename.
  • Logging and monitoring: Enable detailed, privacy-conscious logging of upload paths and reject logs for paths containing suspicious traversal patterns; monitor for repeated access attempts to common sensitive files.
  • Security testing: Incorporate path traversal test cases into API security tests and CI pipelines, including tests that exercise each content type and source option for the upload API.
  • Policy enforcement: Use automated review tools or pre-commit checks to enforce patterns like "no raw os.path.join with request-derived values" without passing through a validation utility.

Sources

SourceLink
github.comgithub.com/mindsdb/mindsdb/security/advisories/GHSA-qqhf-pm3j-96g7
bluerock.iobluerock.io/post/cve-2025-68472-mindsdb-file-upload-path-traversal

Frequently asked

questions

Yes. Any client that can reach the MindsDB file upload endpoint can attempt to exploit the path traversal using crafted JSON-based upload requests, without needing local access to the server.

No. The vulnerable upload handler is described as unauthenticated, so exploitation does not require valid credentials as long as the endpoint is exposed to the attacker's network.

The safest pattern is to centralize filename and path handling in a single utility that performs strict sanitization, normalizes paths, and enforces a confined base directory, and then ensure all upload code paths—including JSON uploads—use that utility instead of building paths directly from user input.

Treat all user-controlled path fragments as untrusted, avoid exposing server filesystem structure, use server-generated identifiers for stored files, and enforce automated checks (static analysis, code review guidelines, and security tests) that forbid direct filesystem access with unsanitized input across the codebase.

Find out what's already
exploitable in your codebase.