Skip to content

Chapter 0

The file journey model

Six stations where different components make trust assumptions.

3 min readFile Upload

Do not treat file upload flaws as a single vulnerability. An uploaded file moves through a long path inside the application architecture. At every station, a different software component makes an assumption about the file.

01 VALIDATION GATE Extension & MIME Check Regex flaws, blocklists, spoofed Content-Type 02 STORAGE & NAMING Disk Path or Bucket Path traversal, webroot writes, filename overwrite 03 SERVING LAYER Browser Delivery Same-origin SVG XSS, missing nosniff or attachment 04 SERVER PARSING Image, PDF & XML Libs ImageMagick, Ghostscript, XXE 05 INTERPRETATION Workers & Imports Zip Slip, SSRF, polyglots 06 DORMANCY Delayed Trigger Admin export, CSV formula, backup
Figure 1 Every upload passes through six trust boundaries. When station 1 blocks your shell, move downstream to stations 2 through 6.

Every attack in this guide targets one or more of these six stations.

Before saving anything, the server inspects your file name, extension, Content-Type header, or leading magic bytes. Many teams rely on brittle regular expressions or short blocklists that miss double extensions, uppercase variants, or spoofed MIME types. When this gate leaks, dangerous files walk straight inside.

Next, the app chooses where to write those bytes and what to call them. Safe systems generate a random UUID and push the file to an isolated object bucket like Amazon S3. Risky systems keep your original filename or drop the file into a webroot directory where the web server executes scripts directly.

When another user opens that file, response headers and domain isolation decide what happens next. If the app serves an uploaded HTML or SVG file inline on the main origin without X-Content-Type-Options: nosniff, your file runs JavaScript inside the victim’s session.

The parser station includes libraries that read and convert files. Examples include thumbnail generators, image metadata readers, and preview renderers. These libraries frequently run C or C++ code with legacy memory flaws. A valid image file can exploit a parser vulnerability during processing.

The interpretation station processes file contents for business logic. Applications extract archives, parse XML spreadsheets, and import database records. This station introduces archive traversal, XML external entity injection, and deserialization.

Some files cause harm long after upload completion. A malicious spreadsheet can wait in storage until an administrator exports a financial report. When the user opens the file in desktop software, embedded formulas or macros execute.

Novice testers often spend all their time trying to bypass file extension checks at Station 1. Experienced researchers look closely at Stations 4, 5, and 6. Complex processing pipelines often operate without input validation because developers assume images are harmless.

Next, start at Station 1 and work through Chapter 1 on defeating the validation gate.

Station 1 blocks .php and .html, so you upload badge.svg. The server accepts it and returns the response below when another user visits the file URL. Which station failed, and what is the impact?

HTTP/1.1 200 OK
Host: app.target.com
Content-Type: image/svg+xml
Content-Disposition: inline; filename="badge.svg"

<svg xmlns=“http://www.w3.org/2000/svg” onload=“alert(document.domain)”/>

Look at three lines together: the Host header, Content-Type, and Content-Disposition.
Station 3 failed. The app serves image/svg+xml inline on the main application origin app.target.com. Browsers execute embedded scripts inside inline SVGs, giving you Stored XSS on the primary domain. See SVG attacks for payloads and bypasses.
Serve user uploads from a separate sandbox domain, force Content-Disposition: attachment, send X-Content-Type-Options: nosniff, or rasterize uploaded images server side.
Connections3 backlinks · 5 outgoing · 6 cross-guideFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

File UploadFor authorized testing only.