[GH-ISSUE #1476] Slurp: validate media restored from a backup #748

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

Originally created by @SpicyMarinara on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1476

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Restoring a Slurp backup writes each media/ file back under the name it has in the archive, after checking only its first bytes. The file's extension is never compared with the image type those bytes show, and the Slurp media routes then serve the stored file with a type taken from its name. Restore and serving should both hold Slurp media to verified pictures.

Affected package

slurp2 (Slurp) 0.3.48

Expected behavior

  • A restore writes back only PNG, JPEG, WebP, GIF and AVIF pictures whose file extension matches the type their bytes show. Anything else is skipped and listed among the skipped entries, so rows that named it point at no file.
  • Every Slurp route that sends a stored picture checks the file first and sends it only as the image type its bytes show, with X-Content-Type-Options: nosniff.

Actual behavior

  • restoreCreatorMediaFile (packages/slurp2/src/engine/packages/server/src/slp/base/media/slp-media.ts) accepts any name under media/ and calls isAllowedImageBuffer(data) without the extension, so the name and the bytes can disagree. It also never passes the AVIF hint, so AVIF pictures are dropped on restore.
  • The post, message, avatar, banner, Engine avatar and ad picture routes call reply.sendFile, which names the type from the file extension.

Steps to reproduce

  1. Read restoreCreatorMediaFile in slp-media.ts and the restore job in features/maintenance/slp-backup-jobs.ts.
  2. Read the sendFile calls in features/feed/slp-feed-post-routes.ts, features/messages/slp-messages-media-routes.ts, features/media/slp-media-routes.ts and features/ads/slp-ads-routes.ts.
  3. Note that no step compares a stored file's extension with its contents.

Environment

  • Marinara Engine version: staging (2.4.x)
  • Package version: slurp2 0.3.48
  • Install type: source
  • OS + version: any
  • Browser or app shell: any

Logs, screenshots, or video

None; found by code review.

Additional context

Fix branch: fix/slurp-restore-media.

Template check

Please uncheck (untick) 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 @SpicyMarinara on GitHub (Oct 19, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1476 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Restoring a Slurp backup writes each `media/` file back under the name it has in the archive, after checking only its first bytes. The file's extension is never compared with the image type those bytes show, and the Slurp media routes then serve the stored file with a type taken from its name. Restore and serving should both hold Slurp media to verified pictures. ## Affected package `slurp2` (Slurp) 0.3.48 ## Expected behavior - A restore writes back only PNG, JPEG, WebP, GIF and AVIF pictures whose file extension matches the type their bytes show. Anything else is skipped and listed among the skipped entries, so rows that named it point at no file. - Every Slurp route that sends a stored picture checks the file first and sends it only as the image type its bytes show, with `X-Content-Type-Options: nosniff`. ## Actual behavior - `restoreCreatorMediaFile` (`packages/slurp2/src/engine/packages/server/src/slp/base/media/slp-media.ts`) accepts any name under `media/` and calls `isAllowedImageBuffer(data)` without the extension, so the name and the bytes can disagree. It also never passes the AVIF hint, so AVIF pictures are dropped on restore. - The post, message, avatar, banner, Engine avatar and ad picture routes call `reply.sendFile`, which names the type from the file extension. ## Steps to reproduce 1. Read `restoreCreatorMediaFile` in `slp-media.ts` and the restore job in `features/maintenance/slp-backup-jobs.ts`. 2. Read the `sendFile` calls in `features/feed/slp-feed-post-routes.ts`, `features/messages/slp-messages-media-routes.ts`, `features/media/slp-media-routes.ts` and `features/ads/slp-ads-routes.ts`. 3. Note that no step compares a stored file's extension with its contents. ## Environment - Marinara Engine version: staging (2.4.x) - Package version: slurp2 0.3.48 - Install type: source - OS + version: any - Browser or app shell: any ## Logs, screenshots, or video None; found by code review. ## Additional context Fix branch: `fix/slurp-restore-media`. ## Template check Please **uncheck (untick)** 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:30:22 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Oct 19, 2026):

Fixed on staging by #1477.

<!-- gh-comment-id:6270650470 --> @SpicyMarinara commented on GitHub (Oct 19, 2026): Fixed on staging by #1477.
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-Agents#748
No description provided.