← File Upload lesson
Server-SideFile UploadAdvanced35 min+100 XP

SVG With a Server Tag

The SVG Uploader enforces a short extension blocklist and stores uploads in a public directory. Bypass the filter with a server-executable file and open it.

“The avatar filter blocked `.php`. The server executed `.php5`.”

CWE-434OWASP Top 10 A04:2021OWASP ASVS 12.4
The story
An upload has two identities: the name the application checks and the handler the server uses. Security fails when those two disagree.

The filter uses a short blocklist of extensions. The web server is configured to execute other extensions. The attacker uploads a file with a missed extension and opens it in the public upload directory.

Your objective
  • Inspect the upload filter
  • Find an executable extension the blocklist misses
  • Open the uploaded file and capture the flag
Boundary under test

Filename to filesystem path

Field guide · request anatomy

Where to look before you type a payload

01Receive

The server accepts multipart data with a filename, declared content type and bytes.

02Name

The handler uses the client filename or derives an extension from it.

03Validate

Checks may trust the Content-Type header, a blocklist or an extension that is easy to spoof.

04Store

The file is written to a directory that may be web-accessible or executable.

Progressive hints

Open one hint at a time. The first two build the model; the last two point at the boundary.

Hint 1

Inspect the upload filter and the public upload path.

Hint 2

Try an executable extension the blocklist misses.

Hint 3

The blocklist misses .php5, .php7. Upload a file with that extension and open it.

Hint 4 · near the answer

Open the uploaded file and capture the flag.

Guided workbench

Observe → Hypothesize → Test → Prove → Explain

This is the same loop a reviewer expects in a report. Your draft stays in this browser; nothing is submitted until you choose to export it.

0/15steps complete
Observe0/3
Hypothesize0/3
Test0/3
Prove0/3
Explain0/3

Evidence log

Write for a reviewer who was not in the room. Every claim needs a request, response or state change behind it.

Preview the evidence report
# Lab evidence report — SVG With a Server Tag

- Family: File Upload
- Lab ID: web-upload-svg
- Date: 2026-12-05

## Workflow

### Observe

- [ ] Open "SVG With a Server Tag" and record /upload, the HTTP method and the role you are given.
- [ ] List every parameter, header, cookie and object identifier the normal flow exposes.
- [ ] Save a baseline response: status, body shape, timing and the fields that change by user.

### Hypothesize

- [ ] Name the server decision that protects /upload, and the evidence it should use.
- [ ] Use the clue as a constraint, not an answer: The blocklist is not exhaustive. Try an alternative server extension such as .php5, .phtml or .pht.
- [ ] Predict the exact status, body or state change that would prove the decision is missing.

### Test

- [ ] Start from the baseline and change one value: the filename extension (.php5, .php7).
- [ ] Keep the request replayable; vary encoding, method or identifier location only after the first result.
- [ ] Capture the full request and response for the winning attempt, including the flag.

### Prove

- [ ] Capture the flag and name the exact foreign object, role or state change it proves.
- [ ] Repeat from a clean session and confirm the result is not cached or stale.
- [ ] State impact precisely: what data or action did you actually obtain?

### Explain

- [ ] State the root cause without naming the payload: which decision failed?
- [ ] Name the control that prevents recurrence and the layer where it belongs.
- [ ] Write one regression test that fails before the fix and passes after it.

## Evidence

### Target and baseline

_Not recorded._

### Hypothesis

_Not recorded._

### Winning request

_Not recorded._

### Proof

_Not recorded._

### Root cause

_Not recorded._

### Control and regression test

_Not recorded._

## Analyst conclusion

The proof demonstrates the missing control above. The regression test should fail against the vulnerable behavior and pass after remediation.
Solution and debrief
Locked until you capture the flag.

The full request, the reasoning and the debrief unlock after a successful capture. That is deliberate: struggle first, then consolidate.

What a reviewer will ask

False positives to rule out

  • The upload rejects .php: test .phtml, .phar, double extensions, case variants and trailing dots or spaces.
  • The Content-Type must be image/png: the header is client-controlled; verify the actual bytes.
  • The file is stored outside the web root: it may still be reachable through a download handler or an include primitive.

Regression tests to name

  • Executable extension: The upload is rejected and no executable file is stored
  • Content mismatch: Content detection rejects or re-encodes it
  • Filename traversal: The server ignores the client name and generates its own
The defender's move
  • Allowlist extensions and verify magic bytes.
  • Store uploads outside the web root with random names.
  • Disable execution in the upload directory and scan files.
See the secure-code pattern and all 4 regression tests →
الخلاصة

الفلتر على الاسم لا يحمي إذا كان الخادم سينفذ الملف.