Summary
Music Player Daemon (MPD) before 0.24.11 contains a path traversal flaw in the local storage plugin where user-supplied URIs are concatenated with the storage root without proper canonicalization.
An unauthenticated attacker can abuse the listfiles and albumart commands to traverse outside the configured music_directory and enumerate or read files in arbitrary directories accessible to the MPD process.
Affected context
This vulnerability appears in MPD deployments that enable the local storage plugin and expose MPD's control interface (e.g., TCP socket, networked clients) to users that are not fully trusted.
The bug resides in LocalStorage::MapFSOrThrow and LocalStorage::MapUTF8, where paths are computed by joining a configured storage root with user-provided URIs.
When these URIs contain .. segments, the resulting on-disk path can escape the intended music_directory, allowing access to any file or directory readable by the MPD process account.
Exploit preconditions
- Attack surface: MPD control interface using commands such as
listfilesandalbumart. - Required access: Ability to issue MPD protocol commands (often unauthenticated or weakly controlled in some setups).
- Trigger point: Submission of crafted URIs containing
..path segments that are passed to LocalStorage::MapFSOrThrow / MapUTF8. - Why exploitation is possible: The code constructs file system paths via string concatenation without normalizing or validating the resulting path, allowing the kernel's path resolution at
openat()time to flatten..and escape the configured root directory.
Why this happens
The core issue is improper handling of user-controlled path components, a classic CWE-22: Path Traversal scenario.
Instead of canonicalizing the user-supplied URI and enforcing that the resolved path remains within the configured music_directory, the implementation simply concatenates strings and relies on the filesystem to process them.
This allows ../ sequences in the URI to remain intact until the operating system resolves them, effectively bypassing the intended directory boundary and granting access to paths outside the designated storage root.
Potential impact
- An attacker may enumerate directory contents (filenames, sizes, modification times) anywhere that the MPD process can read.
- An attacker could read album-art-style image files from arbitrary directories outside the music_directory.
- Sensitive information stored in readable image or media files (e.g., screenshots, document scans) could be exposed.
- Environmental details such as directory layout and file metadata can be used to support further attacks against the host.
General mitigation guidance
Effective mitigation focuses on strict path normalization and enforcing directory boundaries:
- Canonicalize and normalize all user-supplied paths before use, resolving
.and..segments and symbolic links as appropriate. - Enforce that the resolved absolute path remains within the configured music_directory (or other intended root) before opening files.
- Prefer filesystem APIs or utility functions that operate relative to a trusted root and reject traversal attempts instead of manual string concatenation.
- Run the MPD service under a dedicated, least-privileged account with minimal read access outside of the music directory.
- Limit network exposure of the MPD control interface using firewalls, authentication, and access controls to reduce who can send commands.
How teams detect issues like this
Detection typically combines code-level and behavioral approaches:
- Static analysis: Search for patterns where user-controlled path segments are concatenated with root directories or passed directly to file APIs (
openat,fopen, etc.) without validation or canonicalization. - Code review: Flag logic that handles URIs or filenames in the local storage plugin and check for explicit checks against
.., absolute paths, or paths that escape the configured root. - Runtime monitoring: Observe MPD logs and system audit logs for unexpected file access patterns, such as the MPD process reading files outside the configured music_directory.
- Security testing: Use directory traversal test cases (e.g.,
../sequences in URIs) in integration tests to verify that access is properly constrained.

