fix(server): sniff avatar magic bytes instead of trusting Content-Type #141
Reference in New Issue
Block a user
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?
Review finding L3 (2026-07-06).
upload_avatar(auth.rs) derives the stored file extension from the request's Content-Type header without checking the bytes. SVG is excluded and a 1MB cap + rate limiting exist, so impact is low — but any bytes can currently be stored as .png/.jpg/.webp/.gif and served back under that type. Fix: check magic bytes (PNG/JPEG/WebP/GIF signatures are all trivial prefixes) and reject mismatches.Principle: never trust client-declared metadata about content you will re-serve; derive it from the content itself.
🤖 Generated with Claude Code