mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2173] [Issue]: Persona import paths accept unverified image bytes #1085
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#1085
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 @Promansis on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2173
Originally assigned to: @Promansis on GitHub.
Summary
Several persona import/upload paths accept decoded image payloads or copied image files based on base64/extension alone instead of validating image bytes. Legacy native import and persona avatar upload used
isAllowedImageBufferto reject unsupported or invalid image content.Expected behavior
Persona import/upload paths should reject invalid image payloads and skip malformed optional avatar/sprite entries without corrupting storage. Decoded bytes should be validated against allowed image signatures/MIME before writing managed avatar or sprite files.
Actual behavior
Refactor helpers such as
decode_image_payload,decode_image_value,restore_persona_sprites, andpersist_image_file_copydecode base64 or copy files without proving that the bytes are a valid supported image. This can preserve or write non-image bytes under image extensions during persona native import, sprite import/upload, or SillyTavern persona avatar import.Steps to reproduce
refactorat7d4f39f4, inspectsrc-tauri/src/commands/storage/media_uploads.rs,src-tauri/src/commands/storage/sprites.rs, andsrc-tauri/src/commands/storage/imports/marinara_assets.rs.mainat77a30fa4, where native import and persona avatar upload callisAllowedImageBufferbefore accepting image bytes.image/pngheader but base64 payload that is not a valid PNG.Impact area
Environment
refactor7d4f39f4; legacy comparisonmain77a30fa4Logs, screenshots, or video
Static trace evidence:
src-tauri/src/commands/storage/media_uploads.rs:214decodes image payloads but does not verify image magic bytes.src-tauri/src/commands/storage/media_uploads.rs:43copies image files to managed storage based on filename/extension.src-tauri/src/commands/storage/sprites.rs:1599decodes sprite image data without image-byte validation; upload paths call it at:362and:403.src-tauri/src/commands/storage/imports/marinara_assets.rs:86restores imported persona sprites through decoded bytes without magic-byte validation.packages/server/src/services/import/marinara.importer.ts:21/:38validate data URLs withisAllowedImageBuffer; legacy persona avatar upload also validates atpackages/server/src/routes/characters.routes.ts:771.Focused check run during parityscan:
cargo test --manifest-path src-tauri/Cargo.toml personapassed 16 tests, but no invalid-image negative row covered this gap.Regression notes
This is a parity gap against legacy image-import validation for native persona import and persona avatar upload. Refactor has path and base64 checks, but not equivalent content validation on these paths.
Additional context
Found while refreshing issue #2133 row
06-PER-ERROR-import-asset-validation. Related scan also touched06-PER-COMPAT-native-import-avatar-sprites.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: