Summary
DB-GPT contains a critical unauthenticated path traversal vulnerability in its Python file-upload endpoint. A remote attacker may manipulate the upload destination through the user_id HTTP header and write attacker-controlled files outside the intended directory, potentially enabling remote code execution.
Affected context
The vulnerability occurs in DB-GPT deployments where the Python file-upload endpoint is reachable over the network and uses the user_id HTTP header to construct an upload path without sufficiently restricting or canonicalizing it. The risk is highest when the service is exposed without authentication and the process can write to executable, startup, scheduled-task, or agent-related locations.
Exploit preconditions
- Attack surface: Network-accessible Python file-upload HTTP endpoint
- Required access: No authentication may be required when the endpoint is exposed as described
- Trigger point: Multipart file upload handling that derives a destination path from the user_id HTTP header
- Why exploitation is possible: Insufficient path canonicalization and containment checks may allow attacker-controlled paths to escape the designated upload directory
Why this happens
The underlying bug is an unsafe file path construction pattern. User-controlled header data is incorporated into a filesystem path without reliably normalizing the result and verifying that the resolved path remains within the intended upload root.
This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). When attacker-influenced path components are trusted as directory or filename data, the application may perform writes in unintended filesystem locations.
Potential impact
- Attackers may write arbitrary content to locations permitted by the service account
- The application process may execute attacker-controlled code during startup or task processing
- Scheduled jobs, agent scripts, or application behavior could be altered
- Sensitive files may be overwritten or corrupted
- The host or surrounding services could be compromised if higher-privilege write locations are reachable
General mitigation guidance
Mitigation generally focuses on removing user-controlled filesystem paths and enforcing a strict storage boundary.
Common defensive patterns include:
- Derive storage paths from server-generated identifiers rather than request headers
- Treat upload names and identity values as data, not directory paths
- Canonicalize candidate paths and verify they remain beneath an approved upload root
- Use allowlisted filenames, extensions, and content types where appropriate
- Store uploads in isolated, non-executable locations with restrictive permissions
- Require authentication and authorization for upload operations
- Run the service with the minimum filesystem privileges needed
- Apply resource limits, audit logging, and malware or content inspection for uploaded files
How teams detect issues like this
Organizations can detect path traversal risks through:
- Static analysis rules for filesystem APIs receiving HTTP headers, parameters, or multipart metadata
- Code review checks for string concatenation or interpolation used to construct file paths
- Tests that verify canonical path containment and reject unexpected path components
- Runtime monitoring for file creation outside approved upload directories
- Web application firewall or gateway policies that restrict anomalous upload metadata
- File integrity monitoring for startup hooks, scheduled-task directories, and agent scripts
- Automated security review tools that flag untrusted input flowing into file-write operations

