mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2480] [Issue]: AssetService::rename omits the .. path-containment guard its sibling write paths enforce #1223
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#1223
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 @Romuromylus on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2480
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Severity: Low — security (path-containment) regression.
AssetService::renamevalidatesnew_nameonly against/,\, and emptiness — it never rejects..and never re-runs the joined target throughassert_inside_dir, so it drops the path-containment guard its sibling write paths (and main) enforce.Expected behavior
Mirror main's two-layer guard: reject any
new_namewhose components include..(or\/leading slash), run it throughsanitize_filename, then re-assert the joined target withassert_inside_dir.Actual behavior
A
new_nameof..(no slash) passes the check, andparent.join("..")resolves outside the managed root. This is the lone outlier:sanitize_filename(:711) explicitly rejects./..for uploads, andabsolute_path(:55) /write_upload(:265) both gate joined paths throughassert_inside_dir;renamedoes neither.Steps to reproduce
game_assets_renamecommand (forwardspath+new_nameverbatim) withpath = "music/theme.mp3",new_name = "..".fs::renameonto an existing ancestor dir errors, so the escape currently fails — but the containment guard is missing.)Impact area
Environment
1fae2c42Logs, screenshots, or video
Static trace:
crates/assets/src/lib.rs:190-201(rename), contrastsanitize_filename:711,absolute_path:55,write_upload:265(all assert containment).Regression notes
Regression vs main.
packages/server/src/routes/game-assets.routes.tsPOST/renameguardsnewNamewithisSafePath()(!segment.includes("..")) and re-assertsassertInsideDir(GAME_ASSETS_DIR, join(dir, sanitizeAssetFilename(newName))). The refactor's rewrite dropped both.Additional context
The actual sandbox escape currently fails because
fs::renameonto an existing non-empty ancestor dir errors on every platform, so this is a defense-in-depth/parity gap rather than a live exploit — hence Low. Fix: reject components containing.., runnew_namethroughsanitize_filename, thenassert_inside_dir(&self.root, &target)beforefs::rename, matching the sibling write paths.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 6, 2026):
Fixed on refactor in
038b7220.AssetService::rename now sanitizes the requested destination name and validates the target path remains inside the asset root before renaming.
Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.