Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper MIME Type Validation Based on File Extensions #576

Closed
2 tasks done
ratnaraj7 opened this issue Oct 24, 2024 · 0 comments
Closed
2 tasks done

Improper MIME Type Validation Based on File Extensions #576

ratnaraj7 opened this issue Oct 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ratnaraj7
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The current implementation of the validateMimeType function validates MIME types solely based on file extensions. This allows users to bypass restrictions by renaming files (e.g., uploading a .pdf as video.mp4), leading to unexpected behavior.

To Reproduce

  1. Rename a .pdf file to have a .mp4 extension.
  2. Upload the renamed file.
  3. Observe that the upload is successful despite the file being a PDF.

Expected behavior

The upload should fail with an invalid MIME type error since the actual file content does not match the allowed types.

Screenshots

N/A

System information

N/A

Additional context

Proposed Solution:

Update the validateMimeType function to detect the MIME type using the magic number with libraries like file-type, though file-type does not support detecting all kinds of file types.

For more context, see GitHub issue #27120.

@ratnaraj7 ratnaraj7 added the bug Something isn't working label Oct 24, 2024
@ratnaraj7 ratnaraj7 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant