mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3056] [Issue]: Bundled "native" game assets can be deleted or moved via bulk and single-file routes, bypassing the protection enforced on folder-delete and single-move #1624
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#1624
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/3056
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
Default bundled game assets (music, sprites, backgrounds shipped with the app) are protected from destructive edits by
.nativemarker files. The folder-DELETE route checkscontainsNativeMarkerand the single/moveroute checksisInsideNativeFolder, both returning 403. But/delete-bulk, singleDELETE /file/*, and/move-bulkperform NO native-marker check. A user can therefore permanently delete or relocate the protected bundled assets just by routing the request through delete-bulk / file-delete / move-bulk instead of folder-delete or single-move. Because the only file-level delete routes both skip the check, the protection is effectively meaningless for individual files. The client UI never marks file nodes as native, so the server guard is the only protection.How to reproduce (try it yourself)
music/exploration/fantasy/calm/<bundled>.mp3, under a directory carrying a.nativemarker.POST /api/game-assets/delete-bulkwith body{ "paths": ["music/exploration/fantasy/calm/<bundled>.mp3"] }.You'll see: the file passes
isSafePath+assertInsideDir+isFile, thenunlinkSync(full)deletes the bundled asset and it is reported insucceeded(200).POST /api/game-assets/move-bulklikewise relocates a native asset.Expected: 403 / a
failedentry, matching the folder-DELETE ("Cannot delete folders containing native assets") and single/move("Cannot move native assets") routes.Where it is
packages/server/src/routes/game-assets.routes.ts:/delete-bulkloop lines 1106-1129 — validates path safety +isFile(), thenunlinkSync(full), no native check.DELETE /file/*lines 691-708 —isSafePath->existsSync->unlinkSync, no native check./move-bulkloop lines 1012-1037 — same validation thenrenameSync(oldFull, newFull), no native check.containsNativeMarker), single/movelines 927-929 (isInsideNativeFolder).Native-marker seeding:
packages/server/src/db/seed-game-assets.ts:75-92,115.What's happening
The
.native-marker protection was added to the folder-DELETE and single-/movehandlers but never to the bulk handlers or the single file-DELETE handler. The bulk loops validate path safety andisFile()but never consult the native marker beforeunlinkSync/renameSync. All routes share prefix/api/game-assetswith no route-level auth, so any client that can reach the guarded routes can reach the unguarded ones.Suggested fix
Add the existing
isInsideNativeFolderguard (file-level walk-up check — NOT the folder-levelcontainsNativeMarker, which would throw on a file path) to the three unprotected sites, mirroring single/move(line 927) and each loop's existing failure convention:DELETE /file/*(after theexistsSynccheck at line 700, beforeunlinkSyncat 702):/delete-bulkloop (after theisFilecheck, beforeunlinkSync(full)at 1127):/move-bulkloop (after theisFilecheck, beforerenameSyncat 1035):Place each guard AFTER the existing
existsSync/isFilechecks so the internalstatSyncnever runs on a missing path. Do NOT add the guard to/copyor/copy-bulk— copying does not remove or relocate the protected originals. The bulk loops already surfacefailedentries as a toast, so no client changes are needed.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.