mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2589] Harden pre-existing character + chat gallery routes (path traversal, orphaned files) #1276
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#1276
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 16, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2589
Originally assigned to: @SpicyMarinara on GitHub.
Summary
While addressing the CodeRabbit review on #2584 (persona + global galleries), the same path-handling / robustness patterns turned up in the pre-existing character and chat gallery routes. These predate the galleries work and aren't in the #2584 / #2585 diffs, so fixing them there would be out of scope — tracking here instead.
Findings
Path traversal in
DELETE /api/characters/:id(most serious). Inpackages/server/src/routes/characters.routes.ts, the character delete route derivesgalleryDir = join(CHARACTER_GALLERY_ROOT, req.params.id)and callsrmSync(galleryDir, { recursive: true, force: true }). Anidof..resolves todata/galleryand would recursively delete the entire gallery tree. (The persona equivalent was hardened in #2584; the character route has the identical pattern.)Backslash not blocked in gallery file-serve routes. The character gallery file route (
GET /:id/gallery/file/:filename) and the chat gallery file route (gallery.routes.ts) reject..and/but not\, which is a path separator on Windows.No
assertInsideDirbefore unlink in the character gallery image-delete route.join(DATA_DIR, "gallery", image.filePath)is unlinked without a canonical containment check. The chat gallery delete already usesassertInsideDir; the character one does not.No rollback on upload metadata failure. The character (
/:id/gallery/upload) and chat (/:chatId/upload) uploads write bytes, then insert the DB row; a failed insert strands an orphan file on disk. (Fixed for persona + global in #2584.)Silent delete failures (minor UX). The character gallery tab delete (
CharacterEditor.tsx) callsremove.mutatewithout awaiting/handling the result, so a failed delete isn't surfaced to the user. (Fixed for the persona tab in #2584.)Notes
This is a local, CSRF-protected single-user app, so the threat surface is limited — but #1 in particular is a real footgun worth closing (defense in depth). All of these mirror fixes already applied to the new persona/global routes in #2584, so the patches should be straightforward to port across.