Summary
Music Assistant versions 2.6.3 and below contain an arbitrary file write flaw in the music/playlists/update API that lets network-adjacent, unauthenticated attackers bypass .m3u extension checks and write files anywhere on the container filesystem.
By placing a crafted .pth file into Python's site-packages directory, an attacker can achieve remote code execution when Python loads the malicious file.
Affected context
This vulnerability affects Music Assistant deployments up to and including 2.6.3, particularly when:
- The application is exposed on a network where untrusted clients can reach the
music/playlists/updateAPI - The container or host process runs with elevated privileges (e.g., as root), giving broad filesystem write access
- Python's standard
site-packagesdirectory is writable by the Music Assistant process
In these contexts, playlist updates supplied over the network can be turned into arbitrary file writes beyond the expected playlist directory.
Exploit preconditions
- Attack surface: HTTP endpoint
music/playlists/updateaccessible over the local network or other adjacent network segments - Required access: No authentication required; attacker must be able to send crafted requests to the API
- Trigger point: Server-side handling of playlist update operations that construct and write playlist files
- Why exploitation is possible:
- Insufficient validation of file paths and locations (CWE-22: Path Traversal)
- Insecure handling of file creation/modification based on client-controlled input (CWE-73: External Control of File Name or Path)
- Inadequate enforcement of output location and allowed file types, enabling the write of executable
.pthfiles (CWE-434: Unrestricted File Upload / File Type Issues)
Why this happens
The root cause lies in trusting user-controlled data to determine where and how files are written on disk.
The music/playlists/update API accepts playlist information and constructs filesystem paths without adequately constraining them to a safe directory or strictly enforcing the expected .m3u extension.
This aligns with CWE-22 (Path Traversal) and CWE-73 (External Control of File Name or Path), where an external actor can influence filesystem targets, and CWE-434 (Unrestricted File Upload), where uploaded or generated files are not limited to non-executable formats.
Because the service runs as root in many containerized deployments, the process can write into sensitive directories such as Python's site-packages, where .pth files are automatically interpreted at interpreter startup, turning a file write bug into reliable code execution.
Potential impact
- Remote execution of arbitrary commands within the Music Assistant container
- Full compromise of the Music Assistant application and its data
- Lateral movement to other services or infrastructure reachable from the compromised container
- Persistent backdoor installation via malicious files in Python's runtime environment
- Modification or deletion of arbitrary files on the container filesystem, possibly impacting other co-located services
General mitigation guidance
Mitigation for this bug class focuses on restricting filesystem influence from user input and reducing the impact of a compromise:
- Constrain playlist and other user-generated files to a dedicated, non-sensitive directory with strict path normalization and rejection of any traversal sequences or absolute paths.
- Enforce a strict allowlist of file extensions and disallow the creation of any files outside of expected, non-executable formats.
- Use the principle of least privilege for the runtime: avoid running the container as root, and ensure the application user cannot write into interpreter or system directories.
- Separate storage for content and code so that user-controlled paths can never overlap with locations that influence interpreter startup or executable search paths.
- Introduce centralized helpers or APIs for safe file handling, encapsulating validation logic rather than constructing paths ad hoc throughout the codebase.
How teams detect issues like this
Detection typically involves both code-centric and operational approaches:
- Static analysis rules that flag:
- Direct concatenation of user-controlled values into filesystem paths
- Use of relative path segments such as
../derived from request parameters - Writes to generic or high-privilege directories (e.g., Python
site-packages, system paths) based on non-constant input - Manual code review checklists that require:
- Verifying that all user-influenced file paths are normalized and validated against an allowlist of directories and extensions
- Confirming that upload or generated content paths cannot reach executable or configuration directories
- Runtime monitoring for:
- Unexpected creation of
.pthor other executable-related files during playlist operations - File integrity checks on interpreter and library directories to detect unauthorized modifications
- Integration of automated security scanning into CI/CD to catch path traversal and arbitrary file write patterns before deployment.

