Skip to content

Bug class · Intermediate

Unrestricted file upload

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

median public bounty
$1,337

Covers CWE 434.

How it works

Full lesson

The pattern behind every report in this class.

Unrestricted file upload is a flaw where an application accepts a file of a type or content it should reject, then stores it somewhere it can be retrieved or executed. The reports behind this lesson show it across open source web applications, Department of Defense sites, enterprise file transfer appliances, marketing SaaS tools, partner portals, issue trackers and cloud storage backed uploads. Programs care because the same missing check can turn a harmless looking form into stored script execution in another user's browser, server side code execution, or overwriting of files that belong to other people.

What it usually leads to depends on where the file lands. When uploads are served from the same origin with a content type that allows active content, the result is stored cross site scripting, as seen in issue trackers, helpdesk forms and signature settings. When the upload directory executes server side scripts, the result is code execution, as seen in backup, workflow and document server products. When files are stored in shared cloud buckets under predictable keys, the result can be replacement of another user's attachment. Some reports stop at acceptance of a dangerous type, which is weaker but still worth understanding.

It turns up most often wherever users are invited to attach something: profile pictures, avatars, logos, signatures, chat windows, bug report forms, CV and resume uploads, theme assets and snippet features. It also appears in less obvious places such as remote avatar URL options, direct upload routes for cloud storage, web server PUT handling and appliance admin interfaces. The common thread is a feature that takes a file from a user and does not fully decide what that file is allowed to be or where it is allowed to be served from.

Conceptually the flow is simple. A user picks a file, the browser sends it to an endpoint, the server decides whether to keep it, and later the file is served back or processed. The vulnerability appears when one of those steps is missing or too trusting. Many reports show the server checking only the declared content type and not the real content or extension, so an executable class file was stored and served. Others show the check looking only at the filename extension while the file was still served as active content.

Things to try

All 59

Each line worked in a disclosed report. Test only what a program's scope allows.

Upload endpoints and authentication 11

  • Use IIS tilde enumeration to find upload handlers, then fuzz for an image upload handler and upload a script type.
  • Upload an attachment with the same filename as another user's attachment and check whether it overwrites the earlier file.
  • Upload a dangerous file type through an attachment feature and check whether it is accepted and served.
  • Upload a dangerous file type through a CV or resume upload and check whether it is accepted.

Client-side download and file handling 9

  • Check whether a browser or desktop app lets a file be uploaded without meaningful user interaction or confirmation.
  • Run curl with the flags that honour the server-supplied filename and have the server name an existing local file, then check whether it is overwritten.
  • Send a link in a desktop messenger's spam section and check whether it opens in an in-app window that can load local files.
  • Send an email whose attachment name contains a quote and a benign extension, then download it and check the saved extension.

Profile, avatar and media features 8

  • Embed code in an image with a metadata tool, rename it to a script extension and upload it through a profile picture feature, then work out the stored path from the response.
  • Upload an executable through a contact image dialog and see whether any data type is accepted.
  • On a mobile site's image upload handler, send a file of a different type and check whether it is stored and executed.
  • Upload a non-image file through an image field and check whether unrestricted types are accepted.

SVG, XML and metadata payloads 6

  • Upload an SVG as a logo and check whether script in it executes in other users' browsers.
  • Add an AsciiDoc block macro that references a local file path in a wiki page, then decode the rendered image to read the file.
  • Use the counter function in an AsciiDoc document to set locked attributes such as URI reading and diagram fetch, then read local files or write to arbitrary paths.
  • Upload an SVG containing an external entity and check whether the parser resolves it.

Filename and extension manipulation 5

  • Send a save-image request with filename and extension parameters and test whether directory traversal in the filename writes outside the intended directory.
  • Change the extension parameter on an image save endpoint to a server-side script type and check whether the file is created and reachable.
  • Pass a variant parameter hash that includes a write-to-file operation and check whether image data is written to an arbitrary server path.
  • Upload a filename containing a right-to-left override character and check how the UI displays it and whether an executable type is accepted.

Bypasses and variations

  • Bypass a client-side-only file type check by sending the upload request directly rather than through the page's script.
  • Insert a null byte between two extensions so the validator sees a safe extension while the server saves and executes the dangerous one.
  • Add a trailing space after a script extension in the uploaded filename to defeat the extension check.
  • Bypass a drag-and-drop file type check by using the browse button to select a disallowed document type.
  • Prepend an image magic string to a script file to defeat content validation, then combine it with a filename trick.

Tips for beginners

All 14
  • Start with the features that already take files: profile pictures, avatars, logos, signatures, chat attachments, bug report forms, CV and resume uploads, theme assets and snippet features. These are the places the evidence shows repeatedly. Read the page's JavaScript to find the real submit endpoint and the uploads directory rather than guessing.
  • Check whether the type check is only in the browser. If the page filters by extension or drag and drop, send the request directly and see whether the server still accepts it. A client side only check is one of the most common findings in this set.
  • Look at how the file is served back, not just whether it is accepted. Upload a file that the server serves with a content type allowing script execution and check whether it runs in another user's browser. Acceptance alone is weak; execution or a clear path to it is what shows impact.
  • Try the filename and extension parameters, not only the file body. Send a save image request with filename and extension parameters and test whether traversal writes outside the intended directory, or whether changing the extension to a server side script type creates a reachable file.
  • Test the remote URL option on avatar and image features. The remote avatar URL path skipped the file type checks that the direct upload path applied, so point the URL parameter at a non image file and see whether any type is accepted.
  • Check unauthenticated endpoints and public reachability. Find an upload endpoint that needs no authentication and check whether uploaded files are publicly reachable. Enumerate directories to find an upload folder that returns success without authentication.

Start here: a reading path

Open the path

Clear reports in order, easiest first.

Guides and techniques

View all

The best explainers, cheat sheets and technique posts on File upload, from around the web.

Newest reports

All 504

Most recently disclosed.

New File upload reports by email

Follow File upload and get each week's new disclosures in one short email.

Free. New reports for what you follow, weekly by default. One-click unsubscribe. Privacy