Security Testing5 min readSeptember 17, 2025

Security Tester: Checking File Upload Validation

Security Tester: Checking File Upload Validation

Scenario

Setting: Cloud storage platform (composite)
Industry: Software as a Service

Challenge

Verifying that a file upload endpoint validates content, size and metadata safely

This is a composite scenario based on common upload security reviews. It does not describe a specific company, and it contains no measured results. Only test systems you own or are authorized to test.

The Scenario

A security tester is reviewing the file upload endpoint of a cloud storage product before a release. Users can upload images and documents, which are stored, previewed in the browser and shared by link. The review has to answer five questions:

  1. Does the server check the content of a file, or only its name and declared type?
  2. Are size limits enforced on the server, not only in the browser?
  3. Are file names sanitized before they are stored or displayed?
  4. Is metadata handled safely, and stripped where it should be?
  5. Do error messages avoid revealing internal details?

FileMock provides the clean, valid starting files: images, documents and archives of a known format and size. The tester then derives the risky variants from them. FileMock does not generate malicious files, and none are needed for these checks.

Step 1: Generate Clean Baseline Files

From the Image and Document tabs:

  • baseline.jpg, baseline.png (1 MB each)
  • baseline.pdf, baseline.docx, baseline.xlsx (1 MB each)
  • baseline.html (100 KB), to check how active formats are handled

First confirm that each accepted baseline file uploads, previews and downloads correctly. Every later test is a variation of one of these files, so a failure points to the single change you made.

Step 2: Extension and Content Mismatch

The most common upload weakness is trusting the file name or the Content-Type header. Derive mismatched files:

# Real PNG content with a .pdf name
cp baseline.png mismatch.pdf

# HTML content with an image extension
cp baseline.html page.jpg

# Double extension
cp baseline.pdf report.pdf.html

Upload each one, and also send them with a manually changed Content-Type header (for example with an intercepting proxy, or curl -F "file=@mismatch.pdf;type=application/pdf").

What a pass looks like:

  • The server identifies the real type from the file's content and rejects or re-labels the mismatch.
  • Files are served back with the detected content type, plus Content-Disposition: attachment and X-Content-Type-Options: nosniff, so page.jpg can never render as HTML in the browser.
  • HTML uploads, if allowed at all, are served from a separate domain or only as downloads.

Step 3: Size Limits on the Server

Browser-side size checks are a convenience, not a control. Generate files on both sides of the limit (for a 50 MB limit: 49.9 MB and 50.1 MB), then send them directly to the endpoint, bypassing the UI:

curl -s -o /dev/null -w "%{http_code}\n" \
  -F "file=@baseline-50.1mb.pdf" https://staging.example.com/api/upload

What a pass looks like:

  • A clear 413 or 400 response for the oversized file.
  • The request is cut off early, not read completely into memory first.
  • Uploads well beyond the limit (for example 500 MB or 2 GB, both within FileMock's range) don't slow down other users. Coordinate this with the team that runs the environment.

Step 4: File Name Handling

File names are user input. Upload a clean baseline file under names such as:

  • ../../baseline.pdf
  • <b>baseline</b>.pdf
  • a 255-character name
  • names with Unicode, spaces and right-to-left characters

Most of these can be set with curl -F "file=@baseline.pdf;filename=../../baseline.pdf".

What a pass looks like: the server stores files under generated identifiers, never under the raw name, and escapes the original name wherever it is shown.

Step 5: Metadata

Photos carry EXIF metadata such as camera model, date, author and copyright. Using the EXIF options in the Image tab, generate JPG files with camera make, model, artist and copyright filled in, and with different orientation values.

What a pass looks like:

  • If the product promises privacy, metadata is removed from shared and public copies (check with exiftool shared-copy.jpg).
  • Metadata text displayed anywhere in the UI is escaped.
  • Orientation is applied correctly in previews.

Step 6: Archives and Malware Scanning

If ZIP uploads are allowed, check how they are processed: is the archive extracted on the server, and are there limits on extracted size and file count? Create a small archive with your operating system's compress tool to confirm the normal path, and review the extraction code and its limits directly.

If the product scans uploads for malware, verify the scanner is actually in the request path using the industry-standard EICAR test file, a harmless file that antivirus engines detect on purpose. Get it from the EICAR organization's website.

Step 7: Error Messages

Collect every error response from the steps above and check that none of them contain stack traces, file system paths, bucket names or library versions.

Reporting Template

CheckFile usedExpectedResult
Content vs extensionmismatch.pdfRejected or re-labelled
HTML served safelypage.jpgNever rendered as HTML
Server-side size limitbaseline-50.1mb.pdf413/400, request cut off early
Path traversal in name../../baseline.pdfStored under generated ID
Name escaping<b>baseline</b>.pdfDisplayed as text
EXIF stripped when sharedexif-full.jpgNo personal metadata
Malware scanning activeEICAR test fileBlocked
Error message hygieneall of the aboveNo internal details

For validation code examples, see Security Testing: Validating File Types and Content.

Takeaways

  • Start from clean, valid files so each test changes exactly one thing.
  • Test the endpoint directly; the upload UI is not a security boundary.
  • Content checks, safe response headers and generated storage names prevent most upload issues.
  • Use the EICAR test file to check malware scanning. Never use real malware.

Generate the clean baseline files for this review with the FileMock generator. Files are created locally in your browser.

Related Case Studies

Ready to Achieve Similar Results?

Transform your testing workflow like Cloud storage platform (composite). Generate comprehensive test files and build reliable applications with FileMock's powerful file generation capabilities.