Skip to content

Extension checks vs MIME sniffing vs content inspection

These checks sit at different depths.

  • Fast and useful as a first filter.
  • Easy to bypass because filenames are user-controlled.
  • Looks at bytes or signatures instead of trusting the request header.
  • Better than extension checks, but still only answers what the file appears to be.
  • Looks for risky structures or matches inside the file.
  • Needed for PDFs, archives, macro containers, SVG, and more nuanced threat patterns.

Use all three in the right order:

  1. Extension allowlist.
  2. MIME or magic-byte validation.
  3. Structural inspection or optional signature scanning.