mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2303] [Issue]: Decompression bomb in .charx / .marinara import — read_zip_entry has no decompressed-size cap #1138
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#1138
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 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2303
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Medium — Security (decompression bomb / DoS). The shared zip-entry helper
read_zip_entrycallsread_to_end()with no cap on the decompressed size. A small crafted.charxor.marinarafile (a few KB/MB) can declare a DEFLATE entry that inflates to many GB, exhausting memory and crashing the process. The sibling profile-zip extractor is properly hardened; these import paths are not.Expected behavior
Zip entry reads should enforce a per-entry decompressed-size cap during decompression (e.g.
reader.take(limit + 1)then reject if the limit is hit), and pre-checkentry.size()against the cap before reading — mirroring the profile-zip path. A total-extracted-bytes budget across the entries of an archive is also warranted.Actual behavior
read_zip_entry(src-tauri/src/commands/storage/imports/payloads.rs:87-103) fully materializes the decompressed entry with no bound:Two reachable entry points share this helper:
.charx—extract_charx(payloads.rs:178) andresolve_charx_asset(142, fallback loop214) callread_zip_entry, then base64-encode the result (adds ~1.33×). Reached viaparse_character_file -> extract_charxfrom the/import/st-character,/import/st-character/batch,/import/st-character/inspectroutes, and from the folder/batch import path (bulk_imports.rs:1287-1289doesfs::read(&path)with no size limit)..marinara—import_marinara_file(imports/marinara.rs:41-49fordata.json,67-74for the avatar) checksdata_bytes.len()/avatar.len()againstMAX_DATA_JSON_BYTES(5 MB) /MAX_AVATAR_BYTES(20 MB) only afterread_zip_entryhas already decompressed the whole entry into aVec<u8>:MAX_PACKAGE_ENTRIES = 8bounds entry count, not per-entry decompressed size. In server mode the request body is capped atMAX_API_BODY_BYTES = 256 MB, but DEFLATE's ~1000:1 ratio means a sub-256 MB compressed body inflates to hundreds of GB, so the body cap does not protect either path.Steps to reproduce
.charx(or.marinara) whosecard.json/data.json/ avatar entry is a DEFLATE bomb (small compressed, multi-GB decompressed).Impact area
Environment
47b16701Logs, screenshots, or video
Static source audit; claims cited to file:line above. Do not attach a real bomb file.
Regression notes
Found via static audit of the refactor branch; not verified against main. The fix pattern already exists in-repo:
commands/storage/profile/assets.rsdefinesMAX_PROFILE_ASSET_BYTES(256 MB, line 22),validate_profile_zip_asset_declared_sizechecksentry.size()(466/496/568), andcopy_limited_profile_zip_asset_with_limitstreams viareader.take(limit + 1)(588). The charx/marinara paths do neither.Additional context
Impact is a crash / OOM DoS (no RCE, no data loss, recoverable on restart). Desktop is largely self-inflicted (single-user importing an attacker-supplied file); the bigger risk is server mode, where a single 256 MB request can OOM-kill the shared process and per-IP rate limiting does not help. Suggested fix: make
read_zip_entrysize-bounded (take an explicit per-entry limit, stream withtake(limit + 1), reject on overflow), pre-checkfile.size()against the relevant cap before reading, and apply a total-extracted-bytes budget across the entries iterated inextract_charx.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (Jun 6, 2026):
Fixed by #2376, merged into
refactor(squash09268c5d).