Summary
Gonic's playlist handling contains a path traversal and insecure direct object reference flaw that allows authenticated users to bypass an ownership check derived from an attacker-controlled playlist ID.
Under typical multi-user Subsonic deployments, any logged-in user can access or delete other users' playlists and probe arbitrary filesystem paths for existence or readability.
Affected context
The issue affects Gonic instances exposing the Subsonic-compatible API where:
- Playlists are stored on disk and referenced by an ID derived from path segments
- The application infers ownership from
playlist.UserID, derived from the first user-controllable path segment in the playlist ID - No strict path containment or canonicalization is enforced on resolved playlist file paths
- Multiple authenticated users share the same Gonic instance for music streaming and playlist management
In these conditions, the trust boundary around playlist ownership and filesystem exposure becomes weak and can be bypassed by crafted ID values.
Exploit preconditions
- Attack surface: Subsonic API endpoints that operate on playlists (e.g., read, delete, or manipulate playlists).
- Required access: Any valid authenticated Subsonic user account on the affected Gonic instance.
- Trigger point: Supplying a crafted
idparameter that manipulates the first path segment and/or introduces traversal elements when calling playlist-related endpoints. - Why exploitation is possible: The server derives
playlist.UserIDdirectly from the attacker-controlled playlist ID and resolves file paths without robust path containment, allowing an attacker to: - Impersonate another user in ownership checks, and
- Traverse or probe filesystem paths outside the intended playlist directory.
Why this happens
The vulnerability stems from conflating user-controlled identifiers with trusted authorization and filesystem boundaries.
Gonic uses the first path segment of the playlist ID, supplied by the client, to populate playlist.UserID and drive ownership checks, while also resolving this ID into a file path without ensuring it remains within an allowed directory.
This maps to:
- CWE-22 (Improper Limitation of a Pathname to a Restricted Directory): The application fails to enforce strict path canonicalization and containment, allowing traversal-based probing of arbitrary paths.
- CWE-639 (Authorization Bypass Through User-Controlled Key): The authorization decision (playlist ownership) relies on an identifier that an attacker can fully control and manipulate.
Conceptually, the bug arises from using untrusted input both as an authorization token and as a filesystem locator without independent verification or normalization.
Potential impact
- Any authenticated user may read other users' playlists, exposing listening habits and curated content.
- Any authenticated user may delete or tamper with other users' playlists, causing loss or alteration of user data.
- Attackers can probe arbitrary file paths on the host system for existence and sometimes readability, aiding reconnaissance.
- Information gleaned from filesystem probing can facilitate further attacks, such as identifying configuration files or sensitive directories.
General mitigation guidance
Effective mitigation focuses on decoupling user identity from user-controlled identifiers and enforcing strict filesystem constraints:
- Harden path handling:
- Resolve playlist IDs to canonical, absolute paths.
- Enforce that all playlist files reside under a single, configured base directory.
- Reject any ID that yields a path outside the allowed directory (e.g., after cleaning and resolving
..segments). - Use server-trusted identifiers for authorization:
- Store ownership metadata in a backend data store keyed by internal, non-guessable IDs.
- Derive
UserIDfrom the authenticated session or token, not from request parameters or path segments. - Perform authorization checks using server-side mappings, never trusting client-supplied IDs for access control.
- Constrain filesystem exposure:
- Limit the directories that API operations can touch to known-safe locations.
- Avoid exposing low-level filesystem errors that reveal path existence; use generic error messages instead.
- Apply least privilege and defense in depth:
- Run the service under an account with minimal filesystem permissions needed for normal operation.
- Segregate user data from system and configuration directories to reduce the impact of path probing.
How teams detect issues like this
Organizations can detect similar flaws by combining code-centric and operational approaches:
- Static analysis and linters:
- Flag any use of user-controlled input in filesystem operations (
open,os.File,os.Stat, path join/resolve helpers) without explicit normalization and containment checks. - Detect patterns where authorization decisions depend on request parameters such as
id,user, or path segments rather than authenticated session context. - Code review practices:
- Explicitly trace how resource IDs (playlist IDs, file paths) are constructed and validated before access.
- Review all authorization logic to ensure it is based on server-trusted user identity and object ownership metadata, not on client-supplied keys.
- Check that error handling for I/O operations does not leak information about the underlying filesystem structure.
- Automated testing and fuzzing:
- Introduce tests that attempt to access cross-user resources via manipulated IDs and relative path segments.
- Use API fuzzers or security testing tools to inject traversal payloads (
../,%2e%2e/, nested paths) into parameters that influence file access. - Runtime monitoring:
- Log playlist access patterns including authenticated user ID and target resource ID.
- Alert on suspicious behavior such as a single user attempting to access many distinct playlist paths or unusual directory patterns.

