Summary
A logic error in Gonic's playlist handling allows any authenticated Subsonic user to write playlist M3U data to arbitrary absolute filesystem paths on the server.
When exploited, attackers can create world-writable directories and files outside the intended storage area, increasing the risk of data tampering, privilege abuse, or further compromise.
Affected context
This vulnerability occurs in Gonic deployments that expose the Subsonic-compatible API and allow users to create or update playlists.
The issue lies in the ServeCreateOrUpdatePlaylist logic combined with a storage layer (Store.Write) that does not enforce path containment or normalization.
In such contexts, an authenticated but non-admin user can influence the filesystem path used for playlist storage, and the server will accept absolute paths and create intermediate directories with permissive 0o777 permissions.
The risk is higher when the Gonic process runs with broad filesystem privileges or on shared hosts where other services trust local filesystem integrity.
Exploit preconditions
- Attack surface: HTTP API (Subsonic-compatible endpoints) exposed by the Gonic server.
- Required access: Any authenticated Subsonic user account; administrative privileges are not required.
- Trigger point: Invocation of the playlist creation or update endpoint that ultimately calls
ServeCreateOrUpdatePlaylist, which delegates toStore.Write. - Why exploitation is possible:
- A guard clause intended to constrain paths is unreachable and therefore ineffective (CWE-697: Incorrect Comparison or Logic).
- The storage implementation does not validate that target paths are within an expected base directory nor restrict absolute paths (CWE-22: Path Traversal).
- Directory creation uses overly permissive mode
0o777, granting full access to all users (CWE-732: Incorrect Permission Assignment).
Why this happens
The core issue is a missing and ineffective path containment check combined with lenient filesystem operations.
In ServeCreateOrUpdatePlaylist, logic intended to prevent unsafe paths is structured such that the guard clause is never reached, leaving path inputs effectively unvalidated.
Store.Write then accepts absolute paths and performs file and directory creation without verifying that the final target resides under a designated storage root, nor normalizing or sanitizing the path components.
Additionally, new directories are created with 0o777 permissions, which grants read, write, and execute rights to all users, compounding the damage if arbitrary paths can be chosen.
This pattern maps primarily to CWE-22: Path Traversal, with contributing issues from CWE-697: Incorrect Comparison or Logic and CWE-732: Incorrect Permission Assignment for Critical Resource.
Potential impact
- Attackers can write or overwrite files at attacker-chosen absolute paths within the permissions of the Gonic process.
- Creation of world-writable (
0o777) directories that other local users or processes can abuse. - Potential tampering with application configuration, logs, or data files, leading to denial of service or inconsistent behavior.
- Facilitation of further compromise if file writes impact scripts, cron jobs, or other components that are later executed or parsed.
- Increased lateral movement opportunities on multi-tenant systems where other services rely on filesystem integrity.
General mitigation guidance
Effective mitigation focuses on strict path handling, minimizing filesystem privileges, and robust permission policies:
- Enforce a fixed storage root for playlists and normalize all user-influenced paths against this root; reject absolute paths and any traversal (
..) components. - Centralize path validation logic so that all file writes pass through a function that enforces containment and canonicalization before touching the filesystem.
- Use least privilege for the Gonic process: run under a dedicated, unprivileged account with access only to required directories.
- Avoid world-writable directories; apply conservative directory modes by default and restrict write access to the service account whenever possible.
- Implement defense-in-depth controls such as mounting storage with restricted execute permissions where feasible to reduce the impact of malicious files.
- Adopt secure-by-default configuration where playlist paths are not user-configurable beyond benign, validated identifiers.
How teams detect issues like this
To detect and monitor for this class of issue:
- Apply static analysis or linters configured to flag direct use of filesystem APIs with unvalidated or concatenated user input, especially where absolute paths are accepted.
- During code review, look for:
- File or directory creation based on request parameters or externally supplied identifiers.
- Absence of path normalization and containment checks against a known base directory.
- Overly permissive permission modes such as
0o777on created paths. - Use application-level logging to record playlist operations, including resolved filesystem paths, and monitor for unexpected locations outside the intended storage tree.
- Employ host-based intrusion detection or file integrity monitoring on sensitive directories to spot unexpected M3U files or newly created world-writable directories.
- Integrate security checks into CI/CD pipelines that enforce policies around path handling and permissions (e.g., custom rules in SAST tools or policy-as-code frameworks).

