Skip to content

bug(messaging): harden upload content validation across web and remote channels #112

@lidge-jun

Description

@lidge-jun

Summary

Upload validation is still inconsistent across /api/upload, /api/voice, and Telegram/Discord attachment flows. Avatar uploads now have a basic validator, but the common save path still trusts headers and extensions too much.

Current Review Status

  • Partial after the 2026-04-18 pull audit
  • src/routes/avatar.ts validates content-type/ext/body basics
  • /api/upload, /api/voice, Telegram voice/photo/document, and Discord attachments still flow into saveUpload() without magic-byte checks

Why This Matters

Malformed or mislabeled payloads can still be stored first and fail only later.

Suggested Scope

  • Add lightweight content validation helpers in lib/upload.ts
  • Use category-specific allowlists (avatar / voice / generic upload)
  • Add image/audio signature checks before storage

Evidence

  • src/routes/avatar.ts:59-116
  • src/routes/messaging.ts:76-80,125-130
  • src/telegram/voice.ts:21-22
  • src/telegram/bot.ts:535-551
  • src/discord/bot.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:messagingCross-channel messaging runtime and adaptersbugSomething isn't workingpriority:P1Next up after stabilization

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions