FileExamples

File Security Demonstrations

Educational demonstrations of file-based security risks. Learn how attackers exploit MIME types, file extensions, and metadata — and how to defend against these attacks with safe handling code examples.

⚠️ These demos are for educational purposes only. All examples run safely in your browser with no real attack payloads.

File Security Checklist

Upload Validation

  • ✓ Verify magic bytes, not just extension
  • ✓ Check for double/multiple extensions
  • ✓ Strip Unicode control characters from filenames
  • ✓ Enforce file size limits
  • ✓ Whitelist allowed MIME types

Content Processing

  • ✓ Sanitize SVG files (strip scripts)
  • ✓ Strip EXIF metadata from images
  • ✓ Escape CSV formula characters
  • ✓ Serve user files with Content-Disposition: attachment
  • ✓ Use CSP headers to prevent inline execution