File uploads with no type, size or name checks
Last updated November 9, 2026
Steps
- List every upload feature: avatars, attachments, imports, AI document or image uploads. Note where each file is stored and who can read it afterward.
- Allow only the file types the feature needs (for example jpg, png and webp for avatars, or pdf and docx for documents) and check on the server, not just in the file picker.
- Don't trust the Content-Type header or the extension alone. Check the file's signature too, and for images, decode and re-encode them with an up-to-date image library.
- Rename every file to an ID your app generates (such as a UUID) and keep the original name only as data, if you need it.
- Set a size limit per feature. On Supabase Storage you can set allowed MIME types and a maximum file size per bucket, plus a global limit.
- Only let signed-in users upload, store files away from your web root or app domain, and serve private files through short-lived signed URLs.
Why it matters
OWASP's File Upload Cheat Sheet lists the risks: malicious files that exploit parsers, phishing files, ZIP bombs or simply huge files that fill your storage, overwriting existing files, and active content that can attack other users if files are publicly retrievable. It says the Content-Type header is provided by the user and is trivial to spoof, that file signature checks shouldn't be used on their own, and that you should generate filenames yourself, limit file size and only allow authorized users to upload.
OWASP says there's no silver bullet: use several of these checks together. If uploads are public, review the bucket settings too (see User uploads in a public bucket).
Sources
OWASP File Upload Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html
OWASP: Unrestricted File Upload — https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload
Supabase Docs: Creating buckets (restricting uploads) — https://supabase.com/docs/guides/storage/buckets/creating-buckets
Supabase Docs: Storage file limits — https://supabase.com/docs/guides/storage/uploads/file-limits
Related patterns
Found a problem you'd rather not fix yourself?
Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.
Get it fixed by StorenTechVibe Security Weekly
One email a week with new failure patterns and how to fix them.
By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.