mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2523] [Issue]: .charx import/inspect decompresses with no size or entry-count cap (zip-bomb OOM) #1250
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#1250
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 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2523
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: High — security / crash (uncapped decompression DoS). The
.charxcharacter-card import and inspect paths decompress zip entries into memory with no uncompressed-size or entry-count cap, so a small, highly compressible upload can expand to multiple GB and OOM-kill the shared server for every user. The sibling/marinara-packageimport already caps both.Expected behavior
.charximport should bound decompression cost before paying it: cap the entry count and check each entry's uncompressed size (from the zip central directory) before callinggetData(), exactly as/marinara-packagedoes.Actual behavior
importCharX/inspectCharXbuild anAdmZipand callgetData()on entries with no bounds.card.jsonis read viaJSON.parse(cardEntry.getData()...)and assets viaentry.getData()with no size guard:The 256 MB multipart
fileSizecap (app.ts:44,app.ts:66-68) limits only the compressed upload. DEFLATE reaches ~1000:1 on repetitive data, so a few-MB.charxexpands to multiple GB in a singlegetData()Buffer, exhausting the Node heap. The path is reachable post-basicAuth with no privileged gate viaPOST /st-character,POST /st-character/inspect, andPOST /st-character/batch(packages/server/src/routes/import.routes.ts:654/695/722).Steps to reproduce
.charx(a zip) whosecard.jsonor an embedded asset is a few MB compressed but decompresses to multiple GB (a long run of repeated bytes compresses extremely well).POST /st-character(orPOST /st-character/inspect).Environment
staging @ a9fdae8)Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
Fix: mirror the in-repo reference at
import.routes.ts:599-627(/marinara-package), which capszip.getEntries().length(MAX_PACKAGE_ENTRIES = 8) and checks eachentry.header.size(uncompressed size from the central directory) before anygetData(). The bounded-decompress pattern is also modeled inutils/security.ts:506-523(maxOutputLengthon gunzip/brotli/zstd) andbackup.routes.ts:1424(inflateRawSync(..., { maxOutputLength })). Add the same entry-count + per-entryheader.sizegate insideimportCharX/inspectCharX, covering all unguardedgetData()sites:readCharXCardJson(:339), the asset fallback loop (:299), andresolveCharXAsset(~:473).Regression notes: found via static audit. This code is byte-identical on
main(65a0395) —importCharX/inspectCharX/readCharXCardJsonare unbounded on both branches — so it is a long-standing shared-engine bug, not amain→stagingregression. The/marinara-packagecap also predates the fork, so this is a fix-pattern-already-in-repo inconsistency rather than a fork-introduced gap.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: