Vulnerability class

How to prove an upload is exploitable, and verify the fix

Updated

An upload is exploitable when a file you control is stored and later served or executed as something other than an inert download. Test the content-type check, the filenames, and whether the storage location is reachable and executable.

Where this class of bug actually lives in a file upload feature

  • Content-type checks on the header. Content-Type: image/png is client-supplied; the bytes can be anything.
  • Dangerous extensions. .svg, .html, .phtml, .jsp and double extensions like x.php.jpg.
  • Storage served directly. A bucket or uploads directory that serves files with a guessed content type, on the app's own origin.
  • Path control. The filename is used as the storage path, so ../ writes outside the directory, or a shared key overwrites another tenant's file.

What to try first

  1. Upload an .html and an .svg containing script, then fetch the returned URL and see what the server sends back as Content-Type.
  2. Upload a file with a spoofed Content-Type header and a dangerous extension.
  3. Upload with a filename containing ../ and check whether the returned path escapes the upload directory.
  4. Check whether the returned URL is on the app origin and whether it is authenticated.

A reproduction you can keep

The served response is the finding, not the upload response:

Upload, then read what the server actually serves
printf '<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>' > x.svg
curl -sS -F 'file=@x.svg;type=image/png' \
  https://staging.example.com/api/upload -H 'Authorization: Bearer ***'

# fetch the returned URL and read the headers
curl -sS -D - -o /dev/null '<returned-url>' | grep -iE '^(content-type|content-disposition|x-content-type)'

# vulnerable: image/svg+xml inline, on the app origin — stored XSS
# fixed: application/octet-stream + attachment, or a different host entirely

What "fixed" has to look like

Validate by inspecting the bytes rather than the header, generate a random storage name, and serve from a separate origin with Content-Disposition: attachment and a fixed content type. Verify by re-uploading the same payload and confirming the served response is an inert attachment.

Where people get this wrong

  • An extension allowlist that checks the last dot accepts x.php.jpg on a server that reads the first.
  • Serving user uploads from the app's own origin means any HTML or SVG executes with your cookies.
  • Scanning uploads for malware does not fix a path traversal in the storage key.

What Offense does here

Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.

Questions this page answers

Why is SVG upload dangerous?

SVG is XML and can carry script. Served inline from the app origin, it executes in your session.

Is checking the extension enough?

No. Check the magic bytes, generate the filename, and serve as an attachment from a separate origin.

Written by Offense Research, reviewed December 2, 2026. Correct something? Email imran@offenseresearch.com.