[GH-ISSUE #2477] [Issue]: Profile zip import has no aggregate or entry-count size cap (only a per-entry limit) #1220

Closed
opened 2026-10-21 05:29:14 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Romuromylus on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2477

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Severity: Low — data-loss / resource exhaustion regression. Profile zip/JSON asset restore enforces only a per-entry 256MB cap; there is no aggregate (total-uncompressed) cap and no entry-count cap. A crafted profile archive with many entries can exhaust local disk during staging. Main enforces a 1GB total cap.

Expected behavior

Thread a running total through the restore loop and reject once cumulative bytes exceed a total limit (main uses 1GB), and/or cap the number of asset entries — in addition to the per-entry limit.

Actual behavior

// src-tauri/src/commands/storage/profile/assets.rs:434 (restore_profile_zip_assets); loop ~451
validate_profile_zip_asset_declared_size(&entry_name, entry.size())?;   // 466 — per-entry only (256MB)
copy_limited_profile_zip_asset(&entry_name, &mut entry, &mut output)?;   // 468 — per-entry only; returned size discarded

The restore loop iterates every manifest/zip entry with only the per-entry MAX_PROFILE_ASSET_BYTES = 256MB guard. A repo-wide grep for any aggregate cap (total/uncompressed/ARCHIVE_TOTAL/restoredFileBytes/entry_count) returns nothing in the refactor restore paths. A malicious profile .zip declaring many ~256MB (or numerous high-ratio) entries is staged in full, filling the disk before the per-entry cap helps.

Steps to reproduce

  1. Craft a profile backup .zip whose manifest lists many large/numerous asset entries under managed dirs.
  2. Import it — restore_profile_zip_assets stages all of them with no cumulative ceiling, exhausting disk.

Impact area

  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime

Environment

  • Branch or commit: refactor @ 1fae2c42
  • Run mode: Tauri desktop
  • OS + version: found via static source audit (not runtime-reproduced)
  • Node + pnpm versions: n/a (static audit)
  • Rust version, if relevant: n/a (static audit)
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: n/a

Logs, screenshots, or video

Static trace: profile/assets.rs:434 (fn), per-entry validate :466, per-entry copy :468; no aggregate accumulator anywhere in the restore path.

Regression notes

Regression vs main. packages/server/src/routes/backup.routes.ts defines PROFILE_ARCHIVE_TOTAL_UNCOMPRESSED_LIMIT_BYTES = 1GB, accumulates restoredFileBytes across the restore loop, and calls assertProfileArchiveTotalLimit to reject once cumulative bytes exceed it. The refactor dropped the aggregate guard, keeping only the per-entry one.

Additional context

Low: desktop is single-user, the archive is a self-inflicted import, and the staging transaction rolls back on write error (transient disk pressure, no persistent corruption). Fix is cheap: the per-entry helper already returns the copied byte count — thread a running total through restore_profile_zip_assets/restore_profile_json_assets_in_root/preview_* and reject once it exceeds a 1GB PROFILE_ARCHIVE_TOTAL constant, mirroring main; optionally cap entry count.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2477 Originally assigned to: @SpicyMarinara on GitHub. ## Summary **Severity: Low — data-loss / resource exhaustion regression.** Profile zip/JSON asset restore enforces only a per-entry 256MB cap; there is no aggregate (total-uncompressed) cap and no entry-count cap. A crafted profile archive with many entries can exhaust local disk during staging. Main enforces a 1GB total cap. ## Expected behavior Thread a running total through the restore loop and reject once cumulative bytes exceed a total limit (main uses 1GB), and/or cap the number of asset entries — in addition to the per-entry limit. ## Actual behavior ```rust // src-tauri/src/commands/storage/profile/assets.rs:434 (restore_profile_zip_assets); loop ~451 validate_profile_zip_asset_declared_size(&entry_name, entry.size())?; // 466 — per-entry only (256MB) copy_limited_profile_zip_asset(&entry_name, &mut entry, &mut output)?; // 468 — per-entry only; returned size discarded ``` The restore loop iterates every manifest/zip entry with only the per-entry `MAX_PROFILE_ASSET_BYTES = 256MB` guard. A repo-wide grep for any aggregate cap (`total`/`uncompressed`/`ARCHIVE_TOTAL`/`restoredFileBytes`/`entry_count`) returns nothing in the refactor restore paths. A malicious profile `.zip` declaring many ~256MB (or numerous high-ratio) entries is staged in full, filling the disk before the per-entry cap helps. ## Steps to reproduce 1. Craft a profile backup `.zip` whose manifest lists many large/numerous asset entries under managed dirs. 2. Import it — `restore_profile_zip_assets` stages all of them with no cumulative ceiling, exhausting disk. ## Impact area - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime ## Environment - Branch or commit: refactor @ 1fae2c42 - Run mode: Tauri desktop - OS + version: found via static source audit (not runtime-reproduced) - Node + pnpm versions: n/a (static audit) - Rust version, if relevant: n/a (static audit) - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: n/a ## Logs, screenshots, or video Static trace: `profile/assets.rs:434` (fn), per-entry validate `:466`, per-entry copy `:468`; no aggregate accumulator anywhere in the restore path. ## Regression notes Regression vs main. `packages/server/src/routes/backup.routes.ts` defines `PROFILE_ARCHIVE_TOTAL_UNCOMPRESSED_LIMIT_BYTES = 1GB`, accumulates `restoredFileBytes` across the restore loop, and calls `assertProfileArchiveTotalLimit` to reject once cumulative bytes exceed it. The refactor dropped the aggregate guard, keeping only the per-entry one. ## Additional context Low: desktop is single-user, the archive is a self-inflicted import, and the staging transaction rolls back on write error (transient disk pressure, no persistent corruption). Fix is cheap: the per-entry helper already returns the copied byte count — thread a running total through `restore_profile_zip_assets`/`restore_profile_json_assets_in_root`/`preview_*` and reject once it exceeds a 1GB `PROFILE_ARCHIVE_TOTAL` constant, mirroring main; optionally cap entry count. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:29:14 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jun 6, 2026):

Fixed on refactor in 038b7220.

Profile JSON/ZIP asset restore and preview now track aggregate restored asset bytes and reject once the 1GB total uncompressed cap is exceeded, while keeping the per-entry cap.

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.

<!-- gh-comment-id:4638719382 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Fixed on refactor in 038b7220. Profile JSON/ZIP asset restore and preview now track aggregate restored asset bytes and reject once the 1GB total uncompressed cap is exceeded, while keeping the per-entry cap. 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1220
No description provided.