Summary
MoviePilot's AliPan, U115, and Rclone download handlers build local file paths by concatenating a configured download directory with filenames taken directly from cloud storage metadata, without normalization or validation.
If an attacker can control the filename returned by a cloud storage API, they can inject directory traversal sequences (such as ../) to write files outside the intended download directory and potentially overwrite sensitive application files.
Affected context
This vulnerability arises in MoviePilot deployments that use AliPan, U115, or Rclone integrations to download content from remote cloud storage.
The issue is present where the application constructs destination paths by directly concatenating the configured download directory with filenames derived from remote API metadata, without applying basename extraction, canonicalization, or directory boundary checks.
It becomes relevant when remote or multi-tenant storage can return attacker-controlled filenames for download.
Exploit preconditions
- Attack surface: Cloud storage download endpoints using AliPan, U115, or Rclone handlers.
- Required access: Ability to influence or control filenames within the connected cloud storage account or API responses (for example, through file uploads, shared folders, or compromised credentials).
- Trigger point: Initiation of a download operation in MoviePilot that retrieves metadata from the cloud provider and constructs a local path from the remote filename.
- Why exploitation is possible: The handler trusts the remote filename, concatenates it with the download directory, and does not normalize or validate the resulting path, allowing traversal segments (../) to escape the intended directory.
Why this happens
The core issue is a failure to validate and normalize user-influenced path components before using them in filesystem operations.
By directly concatenating the configured download directory with a filename taken from remote metadata, the code implicitly trusts that the filename is safe and relative, which violates the assumptions behind CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
Without stripping directory separators, rejecting traversal tokens, or enforcing that the final resolved path remains within the intended download directory, attacker-controlled filenames can redirect writes to arbitrary locations accessible by the application process.
Potential impact
- Overwriting arbitrary files that the MoviePilot process can write to, including configuration files.
- Modifying plugin or script files that may later be executed, potentially leading to remote code execution.
- Planting malicious content in web-servable directories, which could enable web-based attacks depending on deployment.
- Corrupting application data or user media files stored on the same filesystem.
- Facilitating privilege escalation within the application's runtime context if critical files are overwritten.
General mitigation guidance
Effective mitigation focuses on ensuring all filesystem operations respect directory boundaries and treat filenames as untrusted data:
- Normalize and sanitize filenames derived from remote or user-controlled sources, removing path separators and traversal tokens, and using only the basename component.
- Construct paths using path-joining utilities that operate on trusted base directories and then canonicalize the result, verifying that the resolved path still resides inside the allowed download directory.
- Enforce an allowlist of valid characters and patterns for filenames, rejecting unexpected or malformed inputs at the API boundary.
- Apply least-privilege principles to the MoviePilot process, reducing its ability to overwrite sensitive system or application files even if a traversal is attempted.
- Separate writable media directories from configuration, executable, and plugin directories to minimize the blast radius of any file write logic.
How teams detect issues like this
Organizations can detect and monitor for this class of issue using a combination of review and tooling:
- Perform static code analysis to flag direct string concatenation when building filesystem paths from remote or user-controlled values, particularly when using cloud storage metadata.
- During code review, look for path construction that does not use canonicalization, basename extraction, or post-join boundary checks, and for any acceptance of ../ sequences or absolute paths in filenames.
- Define secure coding guidelines or linting rules that prohibit raw concatenation of directory paths and filenames, requiring path-joining utilities and post-resolution validation instead.
- Use runtime monitoring or file integrity checks on critical configuration and plugin directories to detect unexpected modifications originating from download handlers.

