ThreatMon Blog
  • Platform
  • Intelligence Modules
    • Cyber Threat Intelligence
    • Attack Surface Management
    • Digital Risk Protection
  • Resources
    • Blog
    • Reports
  • Company
    • About Us
    • Term & Use
    • Privacy Policy
  • Platform
  • Intelligence Modules
    • Cyber Threat Intelligence
    • Attack Surface Management
    • Digital Risk Protection
  • Resources
    • Blog
    • Reports
  • Company
    • About Us
    • Term & Use
    • Privacy Policy
No Result
View All Result
ThreatMon Blog
No Result
View All Result

Home » What is File Upload Vulnerability?

What is File Upload Vulnerability?

ibrahim mestav by ibrahim mestav
August 5, 2023
in General
0
what-is-file-upload-vulnerability-01
591
SHARES
3.3k
VIEWS
Share on FacebookShare on Twitter

File upload vulnerabilities are when a web server allows users to upload files to its filesystem without sufficiently validating things like their name, type, contents, or size. Failing to properly enforce restrictions on these could mean that even a basic image upload function can be used to upload arbitrary and potentially dangerous files instead. This vulnerability could even include server-side script files that enable remote code execution.

What if it allows file upload?

In some cases, the act of uploading the file is in itself enough to cause damage. Other attacks (XSS etc.) may involve a follow-up HTTP request for the file, typically to trigger its execution by the server.

The file’s type isn’t validated properly, and the server configuration allows certain types of file (such as .php and .jsp) to be executed as code. In this case, an attacker could potentially upload a server-side code file that functions as a web shell, effectively granting them full control over the server.

If the filename isn’t validated properly, this could allow an attacker to overwrite critical files simply by uploading a file with the same name. If the server is also vulnerable to directory traversal, this could mean attackers are even able to upload files to unanticipated locations.

Failing to make sure that the size of the file falls within expected thresholds could also enable a form of denial-of-service (DoS) attack, whereby the attacker fills the available disk space.

Browse to “test.php” to upload as an image from the image upload area to the web server, as shown in the screenshot below, with the malicious file previously created with the “msfvenom” of the Metasploit Framework tool.

file-upload-01

When the image gets successfully uploaded on the web server it will send the link of the directory where the image is saved to view the uploaded image. Since can’t upload any real image, therefore, let try to execute a PHP backdoor by making click on the link “here”.

file-upload-02

When the victim clicks the above link “here” will get the victim’s reverse connection through meterpreter session inside the Metasploit Framework.

file-upload-attacker-tool

Thus, the attacker or attackers can easily do what they want.

Mitigation

  1. Check the file extension against a whitelist of permitted extensions rather than a blacklist of prohibited ones. It’s much easier to guess which extensions you might want to allow than it is to guess which ones an attacker might try to upload. Make sure the filename doesn’t contain any substrings that may be interpreted as a directory or a traversal sequence (../).

Should be prohibit the content of byte values ​​named “Magic Header Bytes”.

  • Byte value of image files with the extension “.png”: “\x89PNG\r\n\x1a\n\0\0\0\rIHDR\0\0\x03H\0\xs0\x03[“
  • Byte value of image files with the extension “.jpg”: “\xff\xd8\xff”

On the other hand, must be also prohibit null byte values ​​(x00, 0xC0, 0x80, %00 and %0d%0a).

Here are other popular uses that are among the bans:

  • .asp, .Asp, .ASp, .ASP, .aspx, .Aspx, .ASpx, .ASPx, .ASPX, .config, .Config, .ConfiG .ashx, .asmx, .aspq, .axd, .cshtm, .cshtml, .rem, .soap, .vbhtm, .vbhtml, .asa, .cer, .shtml,
  • .cfm, .cfml, .cfc, .dbm
  • .swf
  • .jsp, .jspx, .jsw, .jsv, .jspf, .wss, .do, .action, .JSP, .JSW
  • .pl, .cgi, .PL
  • .php, .php2, .php3, .php4, .php5, .php6, .php7, .phps, .phps, .pht, .phtm, .phtml, .pgif, .shtml, .htaccess, .phar, .inc, pHp, .pHP5, .PhAr, Php5, .PHP
  • .yaws
  1. Rename uploaded files to avoid collisions that may cause existing files to be overwritten. Do not upload files to the server’s permanent filesystem until they have been fully validated. As much as possible, use an established framework for preprocessing file uploads rather than attempting to write your own validation mechanisms.

References:

https://book.hacktricks.xyz/pentesting-web/file-upload

https://portswigger.net/web-security/file-upload

https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload

https://www.hacksplaining.com/exercises/file-upload

https://www.geeksforgeeks.org/file-upload-vulnerability-of-web-applications/

https://blog.intigriti.com/hackademy/file-upload-vulnerabilities/

https://www.opswat.com/blog/file-upload-protection-best-practices

Previous Post

What is Weak SSL Algorithms?

Next Post

What Is Jquery XSS Vulnerability Version?

Next Post
What Is Jquery XSS Vulnerability Version?

What Is Jquery XSS Vulnerability Version?

Recommended

what-is-cyber-threat

What is “Cyber Threat”?

September 7, 2023
chatgpt-and-cyber-security-in-15-questions-impacts-benefits-and-harms1

ChatGPT and Cyber Security in 15 Questions: Impacts, Benefits and Harms

August 5, 2023

Popular Story

  • chatgpt-and-malware-analysis-threatmon

    ChatGPT and Malware Analysis – ThreatMon

    977 shares
    Share 391 Tweet 244
  • ChatGPT and Cyber Security in 15 Questions: Impacts, Benefits and Harms

    777 shares
    Share 311 Tweet 194
  • TA558 APT Group Uses Malicious Microsoft Compiled HTML Help Files

    751 shares
    Share 300 Tweet 188
  • What is SMTP Open Mail Relay Vulnerability?

    728 shares
    Share 291 Tweet 182
  • The Importance of Attack Surface Management for Organizations

    678 shares
    Share 271 Tweet 170

Intelligence Modules

Cyber Threat Intelligence Attack Surface Management Digital Risk Protection

Resources

Blog Reports

Platform

Discover the platform

Company

About Us Terms & Use Privacy Policy

Blog

The Importance of Attack Surface Management for Organizations ChatGPT and Malware Analysis – ThreatMon TA558 APT Group Uses Malicious Microsoft Compiled HTML Help Files
threatmon-logo

Copyright © 2023

No Result
View All Result
  • Platform
  • Intelligence Modules
    • Cyber Threat Intelligence
    • Attack Surface Management
    • Digital Risk Protection
  • Resources
    • Blog
    • Reports
  • Company
    • About Us
    • Term & Use
    • Privacy Policy

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

Advanced Threat Intelligence Platform
Get 30 Days Free Trial
Get 30 Days Free Trial