Summary
DB-GPT's skill-upload endpoint uses a multipart filename directly when constructing the destination path, allowing the requested location to escape the intended upload directory. Because the route may be reachable without authentication, a remote attacker could write files wherever the server process has permission, potentially leading to code execution when an affected Python module is imported.
Affected context
The vulnerability occurs in deployments that expose DB-GPT's skill-upload API and derive filesystem paths from client-controlled multipart filenames. Risk is higher when the service process can write to application directories or other locations that influence module loading, and when the endpoint's authentication dependency does not reliably require an authenticated user.
Exploit preconditions
- Attack surface: Network-accessible DB-GPT skill-upload API
- Required access: No valid account may be required if the route accepts the default administrative request context
- Trigger point: Processing an uploaded skill and writing its request body to the computed destination path
- Why exploitation is possible: The filename is treated as a filesystem path without canonicalization, containment checks, or restrictions on sensitive file types
- Additional condition for code execution: The server process must be able to write to a location that is later imported or executed by the application
Why this happens
The underlying bug is path traversal caused by combining an upload directory with an untrusted filename without enforcing filesystem containment. Absolute paths can replace the intended base path, while parent-directory components can resolve outside the upload root. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where external input controls filesystem resolution beyond the intended boundary. The absence of reliable authentication enforcement further expands the reachable attack surface.
Potential impact
- An attacker may write or overwrite files accessible to the server process.
- Application configuration, source, or runtime data could be modified.
- A malicious Python module could be placed where the application later imports it.
- The server process could execute attacker-controlled code.
- Sensitive data could be altered, destroyed, or exposed.
- The host or connected services could be affected if the process has excessive privileges.
General mitigation guidance
Mitigation generally focuses on treating uploaded filenames as untrusted metadata rather than filesystem paths.
Common defensive patterns include:
- Generate server-side filenames and store uploads beneath a dedicated, non-executable directory.
- Canonicalize candidate paths and require them to remain within the configured upload root.
- Reject absolute paths, parent-directory components, and other path-separator variants before file creation.
- Apply strict allowlists for file types and avoid permitting uploads that can be imported or executed.
- Enforce authentication and authorization independently of user-supplied headers or default request objects.
- Run the service with least-privilege filesystem permissions and isolate writable directories from application code.
- Use atomic file creation and avoid overwriting existing files where possible.
How teams detect issues like this
High-level detection can combine:
- Static analysis for filesystem writes that concatenate or join user-controlled filenames without canonicalization and containment validation.
- Code review checks for direct use of multipart filename properties in path-construction APIs.
- Tests covering absolute paths, parent-directory components, alternate separators, symlinks, and unusual filename encodings.
- API policy checks verifying that upload routes require explicit authentication and role authorization.
- Runtime monitoring for unexpected writes outside the designated upload directory, especially to application packages or configuration locations.
- File-integrity monitoring for changes to imported modules and other executable application assets.
Automated security review tools may help identify unsafe path handling and missing authorization checks, but findings should be validated against deployment permissions and import behavior.

