[GH-ISSUE #1534] [Issue]: Image uploads trust declared MIME type without validating bytes #780

Closed
opened 2026-10-20 17:33:18 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Xelvanis on GitHub (May 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1534

Originally assigned to: @Romuromylus on GitHub.

Summary

Shared Rust upload decoding rejects empty payloads, oversized payloads, and non-image declared content types, but it still trusts a declared image/* MIME type without validating the decoded bytes.

Expected behavior

Image upload decoding should validate actual image bytes with magic-byte and/or decoder checks before accepting the payload.

Actual behavior

A payload can declare an image/* content type and pass the shared decoder without a byte-level image validation step.

Steps to reproduce

  1. Send an upload payload through an image/background path with an image/* content type.
  2. Use decoded bytes that are not actually an image.
  3. Confirm whether decode_uploaded_image_file rejects the payload before storage/use.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor; code-audit finding in src-tauri/src/commands/storage/shared.rs
  • Run mode: Tauri/storage upload path
  • OS + version: not verified
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not verified
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

No screenshot. Existing evidence: decode_uploaded_image_file validates empty/non-image declared content types and size limits, but still trusts declared image/* type for the actual bytes.

Regression notes

Unknown.

Additional context

Keep existing size/content-type tests as regression coverage and add invalid-byte/magic-byte tests.

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 @Xelvanis on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1534 Originally assigned to: @Romuromylus on GitHub. ## Summary Shared Rust upload decoding rejects empty payloads, oversized payloads, and non-image declared content types, but it still trusts a declared `image/*` MIME type without validating the decoded bytes. ## Expected behavior Image upload decoding should validate actual image bytes with magic-byte and/or decoder checks before accepting the payload. ## Actual behavior A payload can declare an `image/*` content type and pass the shared decoder without a byte-level image validation step. ## Steps to reproduce 1. Send an upload payload through an image/background path with an `image/*` content type. 2. Use decoded bytes that are not actually an image. 3. Confirm whether `decode_uploaded_image_file` rejects the payload before storage/use. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor; code-audit finding in `src-tauri/src/commands/storage/shared.rs` - Run mode: Tauri/storage upload path - OS + version: not verified - Node + pnpm versions: not relevant - Rust version, if relevant: not verified - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video No screenshot. Existing evidence: `decode_uploaded_image_file` validates empty/non-image declared content types and size limits, but still trusts declared `image/*` type for the actual bytes. ## Regression notes Unknown. ## Additional context Keep existing size/content-type tests as regression coverage and add invalid-byte/magic-byte tests. ## 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-20 17:33:18 +07:00
Author
Owner

@Romuromylus commented on GitHub (May 30, 2026):

Fixed by #1636, merged into refactor.

<!-- gh-comment-id:4582246817 --> @Romuromylus commented on GitHub (May 30, 2026): Fixed by #1636, merged into `refactor`.
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#780
No description provided.