Use case · 25 files

Test file-type validation

Extensions and Content-Type headers are chosen by the uploader, so file-type checks have to look at the bytes. Each file here has a real format and a misleading or awkward name. A validator that sniffs content should identify every one correctly; one that trusts the name will not.

Download all with curl
Download 25 files (8.5 MB)Shell
# 25 files, 8.5 MB in total
while read -r url; do curl -LO --fail "$url"; done <<'EOF'
https://files.samplefiles.com/edge-cases/mislabeled/png-named.jpg
https://files.samplefiles.com/edge-cases/mislabeled/jpg-named.png
https://files.samplefiles.com/edge-cases/mislabeled/gif-named.png
https://files.samplefiles.com/edge-cases/mislabeled/webm-named.mp4
https://files.samplefiles.com/edge-cases/mislabeled/mp3-named.wav
https://files.samplefiles.com/edge-cases/mislabeled/json-named.csv
https://files.samplefiles.com/edge-cases/mislabeled/html-named.jpg
https://files.samplefiles.com/edge-cases/mislabeled/svg-named.png
https://files.samplefiles.com/edge-cases/mislabeled/zip-named.docx
https://files.samplefiles.com/edge-cases/mislabeled/docx-named.xlsx
https://files.samplefiles.com/edge-cases/mislabeled/pdf-named.docx
https://files.samplefiles.com/edge-cases/mislabeled/text-named.pdf
https://files.samplefiles.com/edge-cases/mislabeled/document
https://files.samplefiles.com/edge-cases/mislabeled/sample.php.jpg
https://files.samplefiles.com/edge-cases/mislabeled/UPPERCASE.JPG
https://files.samplefiles.com/image/jfif/sample-640x480.jfif
https://files.samplefiles.com/edge-cases/corrupt/bad-signature.png
https://files.samplefiles.com/edge-cases/corrupt/bad-header.jpg
https://files.samplefiles.com/image/png/sample-640x480.png
https://files.samplefiles.com/image/jpg/sample-640x480.jpg
https://files.samplefiles.com/image/webp/sample-640x480.webp
https://files.samplefiles.com/image/heic/sample-640x480.heic
https://files.samplefiles.com/document/pdf/sample-1-page.pdf
https://files.samplefiles.com/archive/zip/sample-mixed.zip
https://files.samplefiles.com/video/mp4/sample-720p-10s.mp4
EOF

Wrong extension

Real image, audio, video and data files saved under another format’s extension.

FileSizeDetailsDownload
PNG file named .jpgpng-named.jpg323 KBDownload
JPG file named .pngjpg-named.png41.8 KBDownload
GIF file named .pnggif-named.png108 KBDownload
WebM video named .mp4webm-named.mp41.7 MBDownload
MP3 file named .wavmp3-named.wav469 KBDownload
JSON file named .csvjson-named.csv35.8 KBDownload

Active content with an image name

HTML and SVG can run script in a browser. They must be rejected, or served with a safe Content-Type and nosniff.

FileSizeDetailsDownload
HTML file named .jpghtml-named.jpg107 BDownload
SVG file named .pngsvg-named.png651 BDownload

Document and container lookalikes

DOCX and XLSX are ZIP files, so a signature check alone only says “ZIP”.

FileSizeDetailsDownload
Plain ZIP named .docxzip-named.docx524 KBDownload
DOCX file named .xlsxdocx-named.xlsx37 KBDownload
PDF file named .docxpdf-named.docx3.1 KBDownload
Text file named .pdftext-named.pdf31 BDownload

Tricky names

No extension, a double extension, an uppercase extension and the .jfif name Windows gives some JPEGs.

FileSizeDetailsDownload
PDF with no file extensiondocument3.1 KBDownload
Double extension (.php.jpg)sample.php.jpg41.8 KBDownload
Uppercase extension (.JPG)UPPERCASE.JPG41.8 KBDownload
JFIF image (640×480)sample-640x480.jfif40.7 KB640×480Download

Damaged signatures

Valid content whose magic bytes have been overwritten, so detection must fail cleanly.

FileSizeDetailsDownload
PNG with a damaged signaturebad-signature.png323 KBDownload
JPG with a damaged headerbad-header.jpg41.8 KBDownload

Correctly named baselines

The same kinds of files with honest names, to confirm your validator accepts them.

FileSizeDetailsDownload
PNG 640×480sample-640x480.png323 KB640×480Download
JPG 640×480sample-640x480.jpg41.8 KB640×480Download
WEBP 640×480sample-640x480.webp19.7 KB640×480Download
HEIC 640×480sample-640x480.heic35.7 KB640×480Download
PDF, 1 pagesample-1-page.pdf3.1 KB1 pageDownload
ZIP with 6 mixed filessample-mixed.zip524 KB6 entriesDownload
MP4 720p HD, 10 seconds (H.264)sample-720p-10s.mp43.8 MB1280×720 · 10s · H.264Download