Skip to content

Chapter 7

The complete attack decision tree

Systematic branch navigation for file upload assessments.

1 min readFile Upload

When an upload endpoint has three or four filters stacked together, random guessing burns hours. Follow the branches below from top to bottom and let each server error tell you which station to probe next.

Find upload feature
│
├── Client-side check only?
│ └── Send web shell via HTTP proxy. Check for code execution.
│
├── Server-side extension check?
│ └── Climb extension ladder: .php5, .phtml, .phar, double extensions,
│ trailing dots, null bytes, or .htaccess configuration upload.
│
├── Magic byte check?
│ └── Deploy polyglots: PHP-in-GIF, header splicing, or EXIF comment injection.
│
├── Structured document or archive allowed?
│ ├── SVG: Test stored script injection and XML external entity resolution.
│ ├── Office: Test XXE inside OOXML packages and CSV formula injection.
│ └── Zip archive: Craft Zip Slip path traversal writes and test nested evasion.
│
├── Server processes files?
│ └── Fingerprint libraries: ImageMagick, ExifTool, Ghostscript, FFmpeg,
│ Apache POI, or PHP phar stream wrapper deserialization.
│
└── File served back to clients?
├── Check for inline rendering without Content Security Policy.
├── Check for missing nosniff headers and browser MIME sniffing.
├── Check object identifiers for insecure direct object references.
└── Test for storage race windows during asynchronous antivirus scanning.

Follow these instructions at each branch.

  1. Intercept the upload request in your web proxy.
  2. Replace the file extension and MIME type with your desired test payload.
  3. If the server accepts the file without rejection, verify direct script execution.

If the server rejects .php or .asp, test alternate registered extensions. Try mixed case variations such as .phtml or .pHp. Upload an Apache .htaccess file to map .jpg files to the PHP engine.

If the server inspects initial file bytes, prepend valid format headers. Combine a GIF89a header with web shell instructions. Verify whether the application processes the hybrid file as an image while retaining the code payload.

When an application accepts vector graphics, test for script execution and external entity resolution. When an application accepts archives, inspect whether unpacking operations write files outside target roots. When an application accepts spreadsheets, test whether exported reports evaluate cell formulas.

Inspect HTTP response headers when downloading uploaded files. If the response lacks X-Content-Type-Options: nosniff, test for browser type sniffing. Verify whether download routes permit unauthorized access across user accounts.

Next, Chapter 8 lists the tools that carry out each branch of this tree.

File UploadFor authorized testing only.