Unrestricted File Uploads
Last updated
Was this helpful?
Last updated
Was this helpful?
When file uploads do not have good file type checks or max file size limits then Unrestricted File Upload vulnerabilities are likely to occur.
WebShell
Create Phishing pages
Defacement
Storing XSS
Installing Malware
In the source code we see that the profile image we uploaded kept the name of the file and is referencing it with an <img> tag and an src attribute.
In this case we are able to upload a profile photo that is actually a php file and then navigate to the upload directory and get the server to run it.
Do an OPTIONS query against the domain to see the allowed verbs. (nc, nmap, putty)
If we get a 4xx or 5xx then it means OPTIONS is not allowed and we should just try one or two PUTs anyways to check it.
Plan what directories to try. We should look into where certain items get stored like User Avatars, Content Files, Uploads, Attachments, Settings. If the WebApp is open source look for the directory structure on github. If its closed source then look at setup and user guides to get an idea of storage. Both HTML and WebApp Docs help here.
Then craft a PUT and test the directories to see if you can drop files.
Who will use the file? How will the uploaded file be used by the system? What privileges will the file have in the server?
It is also best to scan all uploaded files with AV/EDR products and also use web libraries that are made for safe file uploads.
To prevent file upload vulns make sure to check the file names, extensions, size, and the actual data within the file itself. This is because when the file is included in a page then even if the extension does not trigger the php engine to run, the tagging will.