9. Other techniques

Few other techniques worth mentioning

File upload injections in file name

Use a malicious string for uploaded file name.

For example: file$whoami).jpg or

file`whoami`.jpg 

or file.jpg||whoami webapp attempts to move uploaded file with an OS command i.e. mv file /tmp then our filename would inject the whoami command. this essentially leads to remote code execution

similarly, XSS payloads in filename would also theoretically work such as <script>alert(window.origin);</script>

potentially also able to inject a SQL query in filename


File upload attacks - Upload directory disclosure

In some upload forms like a feedback or submission form we may not have access directly to the link of our uploaded file / not know upload dir.

Fuzzing works to find it or even use other vulns like XXE / LFI to find where uploaded files are by reading source code

Additional method to disclose upload directory is through forcing error messages as they often reveal helpful information

may lead to webserver showing an error that it could not write the file; potentially disclosing upload directory. we may also try uploading a file with a >5000char name


windows-specific file upload attacks

Reserved characters such as:

|
<
*
?

Similarly: CON , COM1, LPT1, or NUL may also cause errors because webapp can not write a file with those reserved names.

Another option is to use Windows 8.3 filename convention to overwrite existing files + refer to files that do not exist. older versions of windows were limited to short length for filenames and used ~ to complete the filename which we can use to our advantage. https://en.wikipedia.org/wiki/8.3_filename

For ex: hackthebox.txt we can use HAC~1.TXT or HAC~2.TXT where digit represents order of matching files that start with HAC


Advanced file upload attacks

Any automatic processing that occurs to an uploaded file

may be exploited if not securely coded

Commonly used libraries may have public exploits for such vulns

When dealing with custom code / custom libraries detecting such vulnerabilities requires more advanced knowledge and techniques