mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3055] [Issue]: GET /local-music-file serves any audio-extension file on the host with no folder containment and without the privileged gate the folder picker requires #1623
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1623
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3055
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The folder-picker route
POST /pick-local-music-folderis protected byrequirePrivilegedAccess(...), but the route that actually serves the selected files,GET /local-music-file/:encoded, is not gated at all. It base64url-decodes a fully client-controlled absolute filesystem path, checks only the file extension (must be a known audio type) and that the file exists, then streams it back. There is noassertInsideDir, no check that the path is inside the previously picked folder (the picked folder is never persisted server-side), and no privileged-access check.An authenticated non-loopback client — a LAN device when
ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK=true, or anyone with the configured Basic Auth password but no admin secret — can read ANY audio-extension file anywhere on the host by supplying its absolute path base64url-encoded, even though that same client is refused the privileged folder picker.How to reproduce (try it yourself)
POST /api/game-assets/pick-local-music-folder.GET /api/game-assets/local-music-file/<base64url of e.g. /home/user/private/secret-recording.wav>.You'll see: step 1 returns 403 from
requirePrivilegedAccess, but step 2 streams the arbitrary.wavback with an audio MIME type — exfiltrating any audio file on the host.Expected: the serving route should be no less protected than the picker; a client refused the picker should not be able to read arbitrary host files through it.
Where it is
packages/server/src/routes/game-assets.routes.ts:GET /local-music-file/:encodedlines 543-574 — unguarded; only validatesextname(filePath)againstMUSIC_FILE_EXTENSIONSplusexistsSync/isFile, thencreateReadStream(filePath).POST /pick-local-music-folderlines 727-728 — gated byrequirePrivilegedAccess.Gate semantics:
packages/server/src/middleware/privileged-gate.tslines 15-59. Global auth:packages/server/src/middleware/basic-auth.tslines 313-375. Registration:packages/server/src/routes/index.tsline 102.What's happening
The serving route trusts the client-supplied decoded absolute path entirely. The folder picker only opens a native dialog and returns the chosen path to the client; that folder is never persisted server-side, so the serving route has nothing to bound the path against. The only restriction is the audio extension, which does not limit which files can be read. The global Basic-Auth hook does not require the admin secret, so a non-loopback client passes the global hook and reaches the serving route while still being denied the privileged picker.
Suggested fix
Gate the serving route with the SAME privileged check the picker uses. In
game-assets.routes.ts, as the first line inside theGET /local-music-file/:encodedhandler (~line 543), mirroring the picker at line 728:requirePrivilegedAccessis already imported (line 28). For loopback desktop deployments this passes (isLoopbackIp+ admin-secret not required on loopback), so legitimate playback keeps working; only non-privileged non-loopback clients (exactly the vulnerable population) are denied.Regression avoided: do NOT add
assertInsideDir(GAME_ASSETS_DIR, decodedPath)and do NOT attempt a picked-folder containment check. The legitimate feature deliberately serves absolute paths OUTSIDEGAME_ASSETS_DIR(the user-selected external music folder — seecollectExternalLocalMusicTracksin agent-executor.ts:1407-1447 andLocalMusicPlayer.tsx), and the picked folder is not persisted server-side, so a containment check would break external-folder playback. One pre-existing limitation remains (not a new hole): externally-picked tracks load via an HTMLaudioelement, which cannot send theX-Admin-Secretheader, so a LAN user even with a valid admin secret still cannot play them — a fail-closed deny, which is acceptable.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Claiming this for the current staging sweep in draft PR #3064: https://github.com/Pasta-Devs/Marinara-Engine/pull/3064
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in PR #3064 on branch
codex/issue-sweep-3054-3063(commit3ae8ca37). Closing this issue as addressed; the PR remains open for staging review/merge.