Summary
Open WebUI versions prior to 0.1.124 contain a path traversal flaw in their file attachment handling, where uploaded filenames from HTTP requests are accepted without validation or sanitization.
By including dot-segments in the filename, a user can traverse out of the intended uploads directory and place files anywhere on the filesystem that the web server process can access.
Affected context
This vulnerability occurs in Open WebUI deployments where users can attach files to prompts and the server stores these files based directly on the client-supplied filename.
The affected logic trusts path components (including .. dot-segments) derived from the original HTTP upload request and uses them to construct filesystem paths.
Any environment where the web server has write permissions outside the designated upload directory is at risk, especially if sensitive application or configuration paths are writable.
Exploit preconditions
- Attack surface: HTTP file upload endpoint used for attaching files to prompts.
- Required access: Ability to authenticate or otherwise reach the upload functionality as a user (depending on deployment configuration).
- Trigger point: Submission of an upload request where the filename includes path traversal sequences such as
../or nested directories. - Why exploitation is possible: The server-side logic constructs output paths using unsanitized, unvalidated filenames from the HTTP request, allowing traversal outside the intended upload directory and arbitrary file placement where permissions permit.
Why this happens
The core issue stems from treating client-controlled filenames as trusted path components when writing files to disk.
Instead of normalizing and constraining the resulting paths to a specific upload directory, the implementation allows dot-segments and directory separators to influence the final filesystem path.
This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), with a contributing aspect of CWE-434: Unrestricted Upload of File with Dangerous Type because uploads are not constrained to a safe location or vetted output path.
The insecure pattern is constructing filesystem locations directly from user input without enforcing an allowed base directory and without removing or rejecting traversal sequences.
Potential impact
- Users may write arbitrary files to locations accessible by the web server account.
- Attackers could overwrite or plant application-related files (logs, temporary files, or other writable assets) and influence application behavior.
- Configuration files, model assets, or script-like resources might be replaced or augmented, potentially enabling further compromise if other components later execute or parse them unsafely.
- Sensitive operational data could be corrupted, causing denial of service or unpredictable system behavior.
General mitigation guidance
Effective mitigation focuses on strictly constraining where uploaded files can be written and decoupling server-side storage paths from raw client-supplied filenames.
Pattern-based defensive measures include:
- Normalizing and validating upload paths against a single, predefined base directory, rejecting any filename that would resolve outside that directory.
- Stripping or rejecting path separators and dot-segments from user-supplied filenames, replacing them with safe characters and enforcing a simple naming policy.
- Generating server-side filenames (e.g., UUIDs) and storing the original name only as metadata, not as part of the filesystem path.
- Applying least-privilege filesystem permissions so the web server account can write only to a dedicated upload directory and not to application or system paths.
- Introducing a central file storage abstraction that enforces path constraints and safe naming rather than letting individual handlers interact with the filesystem directly.
How teams detect issues like this
Detection can target both code-level patterns and runtime behavior:
- Static analysis and code review:
- Flag any code that uses request-derived filenames or paths directly in filesystem operations such as
open,writeFile, or equivalent APIs. - Check that all upload handlers route file writes through a path-constraint utility that enforces a fixed base directory and rejects traversal sequences.
- Look for string concatenation involving user input and directory paths without normalization or boundary checks.
- Security testing and logging:
- Include path traversal payloads (filenames with
../or encoded sequences) in automated integration tests for file upload endpoints. - Monitor logs for upload attempts containing suspicious path components, dot-segments, or unexpected directory hierarchies.
- Use file integrity monitoring on critical directories to detect unexpected files or modifications originating from the web application process.
Organizations may incorporate these checks into CI/CD pipelines using automated review tools configured with rules for path traversal and unsafe file upload handling.

