File upload vulnerabilities are when a web server allows users to upload files to its filesystem without sufficiently validating things like ;
- Name
- Content
- Size
- Type
Leak in Content-Type response
The Content-Type response header may provide clues about what kind of file the server believes it has served. If this header hasn’t been explicitly set by the application code, it typically reflects the result of the file extension–MIME type mapping
Servers don’t execute PHP files by default. There are multiple ways to enable the execution of PHP files depending on the server technology. For example, in an Apache server, to run PHP in every directory, you need to add the following line to /etc/apache2/apache2.conf
The server can also be configured to apply specific rules to individual folders. This is done in the .htaccess file with those lines :
Example of a manipulated form where I add a htaccess file to run exploit.php5
Example of directory-specific configuration in a IIS server, located in web.config
Obfuscating
Intrinsic properties of files
JPG :
Files always begin with bytes FF D8 FF
Polyglot files
We can create polyglot files with tools like exiftool that can allow us to hide malicious code in a different file type than the code.