Security Review Pattern for File Upload Endpoints

CATEGORY: TUTORIALS DATE: 2026-01-17

Research by badjuju - Red Orca

A practical review sequence for extension filtering, MIME validation, content sniffing, and asynchronous malware scanning.

Summary

File upload features fail in predictable ways. This guide presents a repeatable review pattern that surfaces dangerous parser paths early.

Review Sequence

  1. Map upload entry points and storage destinations.
  2. Test extension allowlist bypasses (.jpg.php, double extensions, Unicode tricks).
  3. Compare declared MIME type, sniffed MIME type, and storage metadata.
  4. Validate post-upload processing jobs for command injection risks.

Minimal Validation Snippet

allowed = {"image/png", "image/jpeg"}
if detected_mime not in allowed:
    raise ValidationError("Unsupported file type")

Always validate content, not just extension strings.