Case F43527 · Web AppSec · L3 Applied

Securing File Uploads

Practise as: InterviewLevel: L3 Applied

Interview questionYou are reviewing a feature that lets users upload profile pictures and documents. What could go wrong, and how would you secure it?

  1. 01 Answer
  2. 02 Example
  3. 03 Trade-offs
What a strong answer covers

Try it out loud first. Then check yourself:

  1. Risks: web shell execution, stored XSS via SVG or HTML, path traversal in filenames, parser exploits, zip bombs, malware hosting
  2. Allowlist extensions and verify content (magic bytes, then re-encode images); do not trust Content-Type from the client
  3. Rename to random IDs, store outside the web root or in object storage, and serve from a separate cookieless domain
  4. Serve with Content-Disposition: attachment where possible and X-Content-Type-Options: nosniff; enforce size limits
  5. Trade-off: AV scanning and sandboxed conversion add latency and cost but matter for files other users or staff open

If the interviewer pushes back

  • Why is checking the extension against .php not enough on an Apache or IIS server?

Go deeper

More Web AppSec cards

All Web AppSec cards →

cardosec draws a security topic and gives you a clock: explain it out loud with no notes, then see what you covered and what you missed. Free during early access.

Reviewed 2026-10-09