← All projects
Project record1 mention
Originally shared on Hacker News

Uploader with binary-header MIME validation

This app implements a file uploader that hardens upload validation: it detects the true MIME type from the file's binary header rather than the file name, rejecting disguised files such as a sample.jpg that is actually a ZIP or EXE under the hood. It also enforces max file sizes and improves error messages.

Last shared
01 / The problem

What it addresses

File name-based MIME detection can be spoofed, letting dodgy files pass with innocent extensions.

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. Uploader with binary-header MIME validation

    This app implements a file uploader that hardens upload validation: it detects the true MIME type from the file's binary header rather than the file name, rejecting disguised files such as a sample.jpg that is actually a ZIP or EXE under the hood. It also enforces max file sizes and improves error messages.

    Problem: File name-based MIME detection can be spoofed, letting dodgy files pass with innocent extensions.

    Posted by @eliseumds · Original source ↗

    Source text · @eliseumds · · Source ↗

    I'm dealing with mime types and max file sizes for an uploader, and improving error messages. Instead of relying on the file name to detect the mime type, I'm using the file binary header instead to reject dodgy files (for ex a `sample.jpg` file that is actually a ZIP or EXE under the hood).