<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Soroush+Dalili</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Soroush+Dalili"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Soroush_Dalili"/>
		<updated>2026-05-28T10:11:16Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=222893</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=222893"/>
				<updated>2016-11-01T15:52:31Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}}&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step.&lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system or database, forwarding attacks to back-end systems, client-side attacks, or simple defacement. It depends on what the application does with the uploaded file and especially where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two classes of problems here. The first is with the file metadata, like the path and file name. These are generally provided by the transport, such as HTTP multi-part encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it.&lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file size or content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyse everything your application does with files and think carefully about what processing and interpreters are involved.&lt;br /&gt;
&lt;br /&gt;
== Risk Factors ==&lt;br /&gt;
&lt;br /&gt;
* The impact of this vulnerability is high, supposed code can be executed in the server context or on the client side. The likelihood of detection for the attacker is high. The prevalence is common. As a result the severity of this type of vulnerability is high.&lt;br /&gt;
* It is important to check a file upload module's access controls to examine the risks properly.&lt;br /&gt;
* Server-side attacks: The web server can be compromised by uploading and executing a web-shell which can run commands, browse system files, browse local resources, attack other servers, or exploit the local vulnerabilities, and so forth.&lt;br /&gt;
* Client-side attacks: Uploading malicious files can make the website vulnerable to client-side attacks such as [[Cross-site Scripting (XSS)|XSS]] or Cross-site Content Hijacking.&lt;br /&gt;
* Uploaded files can be abused to exploit other vulnerable sections of an application when a file on the same or a trusted server is needed (can again lead to client-side or server-side attacks)&lt;br /&gt;
* Uploaded files might trigger vulnerabilities in broken libraries/applications on the client side (e.g. iPhone MobileSafari LibTIFF Buffer Overflow).&lt;br /&gt;
* Uploaded files might trigger vulnerabilities in broken libraries/applications on the server side (e.g. ImageMagick flaw that called ImageTragick!).&lt;br /&gt;
* Uploaded files might trigger vulnerabilities in broken real-time monitoring tools (e.g. Symantec antivirus exploit by unpacking a RAR file)&lt;br /&gt;
* A malicious file such as a Unix shell script, a windows virus, an Excel file with a dangerous formula, or a reverse shell can be uploaded on the server in order to execute code by an administrator or webmaster later -- on the victim's machine.&lt;br /&gt;
* An attacker might be able to put a phishing page into the website or deface the website.&lt;br /&gt;
* The file storage server might be abused to host troublesome files including malwares, illegal software, or adult contents. Uploaded files might also contain malwares' command and control data, violence and harassment messages, or steganographic data that can be used by criminal organisations.&lt;br /&gt;
* Uploaded sensitive files might be accessible by unauthorised people.&lt;br /&gt;
* File uploaders may disclose internal information such as server internal paths in their error messages.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform ===&lt;br /&gt;
&lt;br /&gt;
* Upload .jsp file into web tree - jsp code executed as the web user &lt;br /&gt;
* Upload .gif file to be resized - image library flaw exploited &lt;br /&gt;
* Upload huge files - file space denial of service &lt;br /&gt;
* Upload file using malicious path or name - overwrite a critical file &lt;br /&gt;
* Upload file containing personal data - other users access it &lt;br /&gt;
* Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
* Upload .rar file to be scanned by antivirus - command executed on a server running the vulnerable antivirus software&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems ===&lt;br /&gt;
&lt;br /&gt;
* Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
* Upload virus infected file - victims' machines infected &lt;br /&gt;
* Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
* Upload .jpg file containing a Flash object - victim experiences Cross-site Content Hijacking.&lt;br /&gt;
* Upload .rar file to be scanned by antivirus - command executed on a client running the vulnerable antivirus software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Weak Protections and Bypassing Methods ==&lt;br /&gt;
&lt;br /&gt;
=== Blacklisting File Extensions ===&lt;br /&gt;
&lt;br /&gt;
This protection might be bypassed by:&lt;br /&gt;
&lt;br /&gt;
* Finding missed extensions that can be executed on the server side or can be dangerous on the client side (e.g. &amp;quot;.php5&amp;quot;, &amp;quot;.pht&amp;quot;, &amp;quot;.phtml&amp;quot;, &amp;quot;.shtml&amp;quot;, &amp;quot;.asa&amp;quot;, &amp;quot;.cer&amp;quot;, &amp;quot;.asax&amp;quot;, &amp;quot;.swf&amp;quot;, or &amp;quot;.xap&amp;quot;).&lt;br /&gt;
* Finding flaws in a web server configuration when it parses files with double extensions or it executes them by providing a sensitive extension after a delimiter such as &amp;quot;/&amp;quot; or &amp;quot;;&amp;quot; character (e.g. &amp;quot;/file.jpg/index.php&amp;quot; when the &amp;quot;file.jpg&amp;quot; file contains PHP code and has been uploaded)&lt;br /&gt;
** In Apache, a php file might be executed using the double extension technique such as &amp;quot;file.php.jpg&amp;quot; when &amp;quot;.jpg&amp;quot; is allowed. &lt;br /&gt;
** In IIS6 (or prior versions), a script file can be executed by using one of these two methods:&lt;br /&gt;
*** by adding a semi-colon character after the forbidden extension and before the permitted one (e.g. &amp;quot;file.asp;.jpg&amp;quot;)&lt;br /&gt;
*** by renaming a script file's extension (e.g. &amp;quot;.asp&amp;quot;) to an allowed extension (e.g. &amp;quot;.txt&amp;quot;) in a folder that its name ends with the script's extension (e.g. &amp;quot;folder.asp\file.txt&amp;quot;). In Windows, it is possible to create a directory by using a file uploader and ADS (Alternate Data Stream). In this method, a filename that ends with &amp;quot;::$Index_Allocation&amp;quot; or &amp;quot;:$I30:$Index_Allocation&amp;quot; makes the file uploader to create a directory rather than a file (e.g. &amp;quot;folder.asp::$Index_Allocation&amp;quot; creates &amp;quot;folder.asp&amp;quot; as a directory).&lt;br /&gt;
* Changing a number of letters to their capital forms to bypass case sensitive rules (e.g. &amp;quot;file.aSp&amp;quot; or &amp;quot;file.PHp3&amp;quot;).&lt;br /&gt;
* Using Windows 8.3 feature, it is possible to replace the existing files by using their shortname (e.g. &amp;quot;web.config&amp;quot; can be replaced by &amp;quot;web~1.con&amp;quot; or &amp;quot;.htaccess&amp;quot; can be replaced by &amp;quot;HTACCE~1&amp;quot;)&lt;br /&gt;
* Finding characters that are converted to other useful characters during the file upload process. For instance, when running PHP on IIS, the &amp;quot;&amp;gt;&amp;quot;, &amp;quot;&amp;lt;&amp;quot;, and double quote &amp;quot; characters respectively convert to &amp;quot;?&amp;quot;, &amp;quot;*&amp;quot;, and &amp;quot;.&amp;quot; characters that can be used to replace existing files (e.g. &amp;quot;web&amp;lt;&amp;lt;&amp;quot; can replace the &amp;quot;web.config&amp;quot; file). In order to include the double quote character in the filename in a normal file upload request, the filename in the &amp;quot;Content-Disposition&amp;quot; header should use single quotes (e.g. filename='web&amp;quot;config' to replace the &amp;quot;web.config&amp;quot; file).&lt;br /&gt;
* Finding neutral characters after a filename such as trailing spaces and dots in Windows filesystem or dot and slash characters in a Linux filesystem. These characters at the end of a filename will be removed automatically (e.g. &amp;quot;file.asp ... ... . . .. ..&amp;quot;, &amp;quot;file.asp &amp;quot;, or &amp;quot;file.asp.&amp;quot;). Although slash or backslash characters are also normally problematic characters, they can be ignored in a normal file upload request as anything before these characters may count as the directory name on the server-side; that said, they should be tried for a thorough test (e.g. &amp;quot;test.php/&amp;quot; or &amp;quot;test.php.\&amp;quot;).&lt;br /&gt;
* Finding flaws in extension detection techniques. A web server may use the first extension after the first dot (&amp;quot;.&amp;quot;) in the provided filename or use a flawed algorithm to detect the extension when there is none or multiple dot characters (e.g. &amp;quot;file.txt.jpg.php&amp;quot;). &lt;br /&gt;
* Using control characters such as null character (0x00) after a forbidden extension and before a permitted one may lead to a bypass. In this method, all the strings after the Null character will be discarded when saving the files. Both URL-encoded and decoded version of the null character should be tried in a file upload request for a thorough test. &lt;br /&gt;
* Using NTFS alternate data stream (ADS) in Windows. In this case, a colon character &amp;quot;:&amp;quot; will be inserted after a forbidden extension and before a permitted one. As a result, an empty file with the forbidden extension will be created on the server (e.g. &amp;quot;file.asax:.jpg&amp;quot;). This file might be edited later using other techniques such as using its short filename. The &amp;quot;::$data&amp;quot; pattern can also be used to create non-empty files. Therefore, adding a dot character after this pattern might also be useful to bypass further restrictions (.e.g. &amp;quot;file.asp::$data.&amp;quot;)&lt;br /&gt;
* Flaws in the protection mechanism when it replaces dangerous extensions. For instance, &amp;quot;file.p.phphp&amp;quot; might be changed to &amp;quot;file.php&amp;quot; after going through this functionality.&lt;br /&gt;
* Flaws in the uploaded file usage for instance when a PHP application uses the &amp;quot;include&amp;quot; function to show the uploaded images.&lt;br /&gt;
* Combination of the above techniques.&lt;br /&gt;
&lt;br /&gt;
=== Whitelisting File Extensions ===&lt;br /&gt;
&lt;br /&gt;
Applications that check the file extensions using a whitelist method also need to validate the full filename to prevent any bypass. &lt;br /&gt;
&lt;br /&gt;
* The list of permitted extensions should be reviewed as it can contain malicious extensions as well. For instance, in case of having &amp;quot;.shtml&amp;quot; in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
* Some of the bypass techniques for the blacklist methods such as using double extensions are also applicable here and should be checked. &lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;Content-Type&amp;quot; Header Validation ===&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Content-Type&amp;quot; entity in the header of the request indicates the Internet media type of the message content. Sometimes web applications use this parameter in order to recognise a file as a valid one. For instance, they only accept the files with the &amp;quot;Content-Type&amp;quot; of &amp;quot;text/plain&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
* It is possible to bypass this protection by changing this parameter in the request header using a web proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Detector ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the file types in order to process them further. For instance, when an application resize an image file, it may just show an error message when non-image files are uploaded without saving them on the server. &lt;br /&gt;
&lt;br /&gt;
* If it reads the few first characters (or headers), it can be bypassed by inserting malicious code after some valid header or within the file's metadata. &lt;br /&gt;
* Inserting code in the comments section or those section that have no effect on the main file can also lead to a bypass.&lt;br /&gt;
* The inserted data can be obfuscated or encoded if the application detects a malicious code using specific patterns or signatures.&lt;br /&gt;
* Uploaded file can be crafted to create a malicious code in case of being compressed by the application.&lt;br /&gt;
&lt;br /&gt;
=== Other Interesting Test Cases ===&lt;br /&gt;
&lt;br /&gt;
* Uploading a file when another file with the same name already exists. This may show interesting error messages that can lead to information disclosure. Logical flaws might be found if the application renames the new file to keep it on the server.&lt;br /&gt;
* Uploading a file when another folder with the same name already exists. This may show interesting error messages that can lead to information disclosure. &lt;br /&gt;
* Uploading a file with a long name. This may show interesting error messages that can lead to information disclosure.&lt;br /&gt;
* Uploading a file multiple times at the same time. This may show interesting error messages that can lead to information disclosure. &lt;br /&gt;
* Uploading valid and invalid files in different formats such as compressed or XML files to detect any possible processing on the server side. &lt;br /&gt;
* Uploading a file with &amp;quot;.&amp;quot;, &amp;quot;..&amp;quot;, or &amp;quot;...&amp;quot; as its name. For instance, in Apache in Windows, if the application saves the uploaded files in &amp;quot;/www/uploads/&amp;quot; directory, the &amp;quot;.&amp;quot; filename will create a file called &amp;quot;uploads&amp;quot; in the &amp;quot;/www/&amp;quot; directory.&lt;br /&gt;
* Uploading files that may not be deleted easily such as &amp;quot;...:.jpg&amp;quot; in NTFS that makes the &amp;quot;...&amp;quot; file (this file can be deleted using command line). This may show interesting error messages that can lead to information disclosure.&lt;br /&gt;
* Uploading a file in Windows with invalid characters such as |&amp;lt;&amp;gt;*?&amp;quot; in its name. This may show interesting error messages that can lead to information disclosure.  &lt;br /&gt;
* Uploading a file in Windows using reserved (forbidden) names such as CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. This may show interesting error messages that can lead to information disclosure. Uploading a file with a reserved name may lead to denial of service if the application keeps the name and tries to save it with another extension (detecting it wrongly as an existing file).&lt;br /&gt;
* Cross-site content hijacking issues can be exploited by uploading a file with allowed name and extension but with Flash, PDF, or Silverlight contents. &lt;br /&gt;
* Uploading a &amp;quot;crossdomain.xml&amp;quot; or &amp;quot;clientaccesspolicy.xml&amp;quot; file can make a website vulnerable to cross-site content hijacking. These files should be uploaded to the root of the website to work. However, the &amp;quot;crossdomain.xml&amp;quot; file can be in a subdirectory as long as it is allowed in the root &amp;quot;crossdomain.xml&amp;quot; file.&lt;br /&gt;
&lt;br /&gt;
=== Important Notes in Testing File Uploaders ===&lt;br /&gt;
&lt;br /&gt;
* Do not try to replace the existing files during testing unless it is safe to proceed. For instance, replacing configuration files such as &amp;quot;web.config&amp;quot; or &amp;quot;.htaccess&amp;quot; file can lead to a denial of service attack for the whole website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
* IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
* Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
* IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
* Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
* Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
* IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
* The file types allowed to be uploaded should be restricted to only those that are necessary for business functionality.&lt;br /&gt;
* Never accept a filename and its extension directly without having a whitelist filter.&lt;br /&gt;
* The application should perform filtering and content checking on any files which are uploaded to the server. Files should be thoroughly scanned and validated before being made available to other users. If in doubt, the file should be discarded.&lt;br /&gt;
* It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a &amp;quot;select case&amp;quot; syntax (in case of having VBScript) to choose the file extension in regards to the real file extension.&lt;br /&gt;
* All the control characters and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as &amp;quot;;&amp;quot;, &amp;quot;:&amp;quot;, &amp;quot;&amp;gt;&amp;quot;, &amp;quot;&amp;lt;&amp;quot;, &amp;quot;/&amp;quot; ,&amp;quot;\&amp;quot;, additional &amp;quot;.&amp;quot;, &amp;quot;*&amp;quot;, &amp;quot;%&amp;quot;, &amp;quot;$&amp;quot;, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
* Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
* It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
* Uploaded directory should not have any &amp;quot;execute&amp;quot; permission and all the script handlers should be removed from these directories.&lt;br /&gt;
* Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
* Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
* Use Cross Site Request Forgery protection methods.&lt;br /&gt;
* Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
* Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
* Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
* Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
* In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
* If it is possible, consider saving the files in a database rather than on the filesystem.&lt;br /&gt;
* If files should be saved in a filesystem, consider using an isolated server with a different domain to serve the uploaded files. &lt;br /&gt;
* File uploaders should be only accessible to authenticated and authorised users if possible.&lt;br /&gt;
* Write permission should be removed from files and folders other than the upload folders. The upload folders should not serve any &lt;br /&gt;
* Ensure that configuration files such as &amp;quot;.htaccess&amp;quot; or &amp;quot;web.config&amp;quot; cannot be replaced using file uploaders. Ensure that appropriate settings are available to ignore the &amp;quot;.htaccess&amp;quot; or &amp;quot;web.config&amp;quot; files if uploaded in the upload directories.&lt;br /&gt;
* Ensure that files with double extensions (e.g. &amp;quot;file.php.txt&amp;quot;) cannot be executed especially in Apache.&lt;br /&gt;
* Ensure that uploaded files cannot be accessed by unauthorised users.&lt;br /&gt;
* Adding the &amp;quot;Content-Disposition: Attachment&amp;quot; and &amp;quot;X-Content-Type-Options: nosniff&amp;quot; headers to the response of static files will secure the website against Flash or PDF-based cross-site content-hijacking attacks. It is recommended that this practice be performed for all of the files that users need to download in all the modules that deal with a file download. Although this method does not fully secure the website against attacks using Silverlight or similar objects, it can mitigate the risk of using Adobe Flash and PDF objects, especially when uploading PDF files is permitted.&lt;br /&gt;
* Flash/PDF (crossdomain.xml) or Silverlight (clientaccesspolicy.xml) cross-domain policy files should be removed if they are not in use and there is no business requirement for Flash or Silverlight applications to communicate with the website.&lt;br /&gt;
* Browser caching should be disabled for the corssdomain.xml and clientaccesspolicy.xml files. This enables the website to easily update the file or restrict access to the Web services if necessary. Once the client access policy file is checked, it remains in effect for the browser session so the impact of non-caching to the end-user is minimal. This can be raised as a low or informational risk issue based on the content of the target website and security and complexity of the policy file(s).&lt;br /&gt;
* CORS headers should be reviewed to only be enabled for static or publicly accessible data. Otherwise, the &amp;quot;Access-Control-Allow-Origin&amp;quot; header should only contain authorised addresses. Other CORS headers such as &amp;quot;Access-Control-Allow-Credentials&amp;quot; should only be used when they are required. Items within the CORS headers such as &amp;quot;Access-Control-Allow-Methods&amp;quot; or &amp;quot;Access-Control-Allow-Headers&amp;quot; should be reviewed and removed if they are not required.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]] ==&lt;br /&gt;
&lt;br /&gt;
* [[Path Traversal]]&lt;br /&gt;
* [[Path Manipulation]]&lt;br /&gt;
* [[Relative Path Traversal]]&lt;br /&gt;
* [[Windows_::DATA_alternate_data_stream]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation Vulnerability]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]] ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Threat Agent]] ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:External Threat Agent]]&lt;br /&gt;
* [[:Category:Internal Threat Agent]]&lt;br /&gt;
* [[:Category:Internet attacker]]&lt;br /&gt;
* [[:Category:Intranet attacker]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]] ==&lt;br /&gt;
&lt;br /&gt;
* [[System Access]]&lt;br /&gt;
* [[Security Bypass]]&lt;br /&gt;
* [[Exposure of system information]]&lt;br /&gt;
* [[Exposure of sensitive information]]&lt;br /&gt;
* [[Client Side Threat]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 [http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ ]&lt;br /&gt;
* 8 basic rules to implement secure file uploads - SANS - [http://software-security.sans.org/blog/2009/12/28/8-basic-rules-to-implement-secure-file-uploads]&lt;br /&gt;
* IIS6/ASP &amp;amp; file upload for fun and profit [http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/]&lt;br /&gt;
* Secure file upload in PHP web applications [http://www.net-security.org/dl/articles/php-file-upload.pdf]&lt;br /&gt;
* Potentially Dangerous File Types [http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf]&lt;br /&gt;
* Image Upload XSS [http://ha.ckers.org/blog/20070603/image-upload-xss/]&lt;br /&gt;
* Code Execution Through Filenames in Uploads [http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/]&lt;br /&gt;
* Secure File Upload Check List With PHP [http://hungred.com/useful-information/secure-file-upload-check-list-php/]&lt;br /&gt;
* NTFS in WikiPedia [http://en.wikipedia.org/wiki/NTFS]&lt;br /&gt;
* NTFS Streams [http://msdn.microsoft.com/en-us/library/ff469210(v=PROT.10).aspx]&lt;br /&gt;
* NTFS - Glossary [http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html]&lt;br /&gt;
* IIS 6.0 Security Best Practices [http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
* Securing Sites with Web Site Permissions [http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
* IIS 6.0 Operations Guide [http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
* Improving Web Application Security: Threats and Countermeasures [http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
* Understanding the Built-In User and Group Accounts in IIS 7.0 [http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
* IIS Security Checklist [http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
* Microsoft IIS ASP Multiple Extensions Security Bypass [http://secunia.com/advisories/37831/]&lt;br /&gt;
* CVE-2009-4444 [http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444]&lt;br /&gt;
* CVE-2009-4445 [http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445]&lt;br /&gt;
* CVE-2009-1535 [http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535]&lt;br /&gt;
* MSDN - Naming Files, Paths, and Namespaces [https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247(v=vs.85).aspx]&lt;br /&gt;
* Even uploading a JPG file can lead to Cross-Site Content Hijacking (client-side attack) [https://soroush.secproject.com/blog/2014/05/even-uploading-a-jpg-file-can-lead-to-cross-domain-data-hijacking-client-side-attack/]&lt;br /&gt;
* Cross-Site Content (Data) Hijacking (XSCH) PoC Project [https://github.com/nccgroup/CrossSiteContentHijacking]&lt;br /&gt;
* iPhone MobileSafari LibTIFF Buffer Overflow [https://www.exploit-db.com/exploits/16862/]&lt;br /&gt;
* ImageMagick Is On Fire-CVE-2016–3714 [https://imagetragick.com/]&lt;br /&gt;
* Symantec Antivirus multiple remote memory corruption unpacking RAR CVE-2016-2207 [https://bugs.chromium.org/p/project-zero/issues/detail?id=810]&lt;br /&gt;
* File in the hole - HackPra Nov. 2012 [https://www.nds.rub.de/media/attachments/files/2012/11/File-in-the-hole.pdf]&lt;br /&gt;
* Self contained web shells and other attacks via .htaccess files [https://github.com/wireghoul/htshells]&lt;br /&gt;
* Upload a web.config File for Fun &amp;amp; Profit [https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/]&lt;br /&gt;
* PHP filesystem attack vectors - Take Two [http://www.ush.it/2009/07/26/php-filesystem-attack-vectors-take-two/]&lt;br /&gt;
* File Upload and PHP on IIS: &amp;gt;=? and &amp;lt;=* and &amp;quot;=. [https://soroush.secproject.com/blog/2014/07/file-upload-and-php-on-iis-wildcards/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Authors ==&lt;br /&gt;
* [[User:Soroush Dalili|Soroush Dalili]]&lt;br /&gt;
* [[User:Dirk Wetter|Dirk Wetter]]&lt;br /&gt;
* [[User:Landon Mayo|Landon Mayo]]&lt;br /&gt;
* [[User:OWASP|OWASP]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
[[Category:File System]]&lt;br /&gt;
[[Category:Windows]]&lt;br /&gt;
[[Category:Unix]]&lt;br /&gt;
[[Category:Use of Dangerous API]]&lt;br /&gt;
[[Category:Vulnerability]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=222892</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=222892"/>
				<updated>2016-11-01T15:48:34Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: Updating the materials to include more test cases / recommendations / references&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}}&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step.&lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system or database, forwarding attacks to back-end systems, client-side attacks, or simple defacement. It depends on what the application does with the uploaded file and especially where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two classes of problems here. The first is with the file metadata, like the path and file name. These are generally provided by the transport, such as HTTP multi-part encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it.&lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file size or content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyse everything your application does with files and think carefully about what processing and interpreters are involved.&lt;br /&gt;
&lt;br /&gt;
== Risk Factors ==&lt;br /&gt;
&lt;br /&gt;
* The impact of this vulnerability is high, supposed code can be executed in the server context or on the client side. The likelihood of detection for the attacker is high. The prevalence is common. As a result the severity of this type of vulnerability is high.&lt;br /&gt;
* It is important to check a file upload module's access controls to examine the risks properly.&lt;br /&gt;
* Server-side attacks: The web server can be compromised by uploading and executing a web-shell which can run commands, browse system files, browse local resources, attack other servers, or exploit the local vulnerabilities, and so forth.&lt;br /&gt;
* Client-side attacks: Uploading malicious files can make the website vulnerable to client-side attacks such as [[Cross-site Scripting (XSS)|XSS]] or Cross-site Content Hijacking.&lt;br /&gt;
* Uploaded files can be abused to exploit other vulnerable sections of an application when a file on the same or a trusted server is needed (can again lead to client-side or server-side attacks)&lt;br /&gt;
* Uploaded files might trigger vulnerabilities in broken libraries/applications on the client side (e.g. iPhone MobileSafari LibTIFF Buffer Overflow).&lt;br /&gt;
* Uploaded files might trigger vulnerabilities in broken libraries/applications on the server side (e.g. ImageMagick flaw that called ImageTragick!).&lt;br /&gt;
* Uploaded files might trigger vulnerabilities in broken real-time monitoring tools (e.g. Symantec antivirus exploit by unpacking a RAR file)&lt;br /&gt;
* A malicious file such as a Unix shell script, a windows virus, an Excel file with a dangerous formula, or a reverse shell can be uploaded on the server in order to execute code by an administrator or webmaster later -- on the victim's machine.&lt;br /&gt;
* An attacker might be able to put a phishing page into the website or deface the website.&lt;br /&gt;
* The file storage server might be abused to host troublesome files including malwares, illegal software, or adult contents. Uploaded files might also contain malwares' command and control data, violence and harassment messages, or steganographic data that can be used by criminal organisations.&lt;br /&gt;
* Uploaded sensitive files might be accessible by unauthorised people.&lt;br /&gt;
* File uploaders may disclose internal information such as server internal paths in their error messages.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform ===&lt;br /&gt;
&lt;br /&gt;
* Upload .jsp file into web tree - jsp code executed as the web user &lt;br /&gt;
* Upload .gif file to be resized - image library flaw exploited &lt;br /&gt;
* Upload huge files - file space denial of service &lt;br /&gt;
* Upload file using malicious path or name - overwrite a critical file &lt;br /&gt;
* Upload file containing personal data - other users access it &lt;br /&gt;
* Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
* Upload .rar file to be scanned by antivirus - command executed on a server running the vulnerable antivirus software&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems ===&lt;br /&gt;
&lt;br /&gt;
* Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
* Upload virus infected file - victims' machines infected &lt;br /&gt;
* Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
* Upload .jpg file containing a Flash object - victim experiences Cross-site Content Hijacking.&lt;br /&gt;
* Upload .rar file to be scanned by antivirus - command executed on a client running the vulnerable antivirus software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing ==&lt;br /&gt;
&lt;br /&gt;
=== Blacklisting File Extensions ===&lt;br /&gt;
&lt;br /&gt;
This protection might be bypassed by:&lt;br /&gt;
&lt;br /&gt;
* Finding missed extensions that can be executed on the server side or can be dangerous on the client side (e.g. &amp;quot;.php5&amp;quot;, &amp;quot;.pht&amp;quot;, &amp;quot;.phtml&amp;quot;, &amp;quot;.shtml&amp;quot;, &amp;quot;.asa&amp;quot;, &amp;quot;.cer&amp;quot;, &amp;quot;.asax&amp;quot;, &amp;quot;.swf&amp;quot;, or &amp;quot;.xap&amp;quot;).&lt;br /&gt;
* Finding flaws in a web server configuration when it parses files with double extensions or it executes them by providing a sensitive extension after a delimiter such as &amp;quot;/&amp;quot; or &amp;quot;;&amp;quot; character (e.g. &amp;quot;/file.jpg/index.php&amp;quot; when the &amp;quot;file.jpg&amp;quot; file contains PHP code and has been uploaded)&lt;br /&gt;
** In Apache, a php file might be executed using the double extension technique such as &amp;quot;file.php.jpg&amp;quot; when &amp;quot;.jpg&amp;quot; is allowed. &lt;br /&gt;
** In IIS6 (or prior versions), a script file can be executed by using one of these two methods:&lt;br /&gt;
*** by adding a semi-colon character after the forbidden extension and before the permitted one (e.g. &amp;quot;file.asp;.jpg&amp;quot;)&lt;br /&gt;
*** by renaming a script file's extension (e.g. &amp;quot;.asp&amp;quot;) to an allowed extension (e.g. &amp;quot;.txt&amp;quot;) in a folder that its name ends with the script's extension (e.g. &amp;quot;folder.asp\file.txt&amp;quot;). In Windows, it is possible to create a directory by using a file uploader and ADS (Alternate Data Stream). In this method, a filename that ends with &amp;quot;::$Index_Allocation&amp;quot; or &amp;quot;:$I30:$Index_Allocation&amp;quot; makes the file uploader to create a directory rather than a file (e.g. &amp;quot;folder.asp::$Index_Allocation&amp;quot; creates &amp;quot;folder.asp&amp;quot; as a directory).&lt;br /&gt;
* Changing a number of letters to their capital forms to bypass case sensitive rules (e.g. &amp;quot;file.aSp&amp;quot; or &amp;quot;file.PHp3&amp;quot;).&lt;br /&gt;
* Using Windows 8.3 feature, it is possible to replace the existing files by using their shortname (e.g. &amp;quot;web.config&amp;quot; can be replaced by &amp;quot;web~1.con&amp;quot; or &amp;quot;.htaccess&amp;quot; can be replaced by &amp;quot;HTACCE~1&amp;quot;)&lt;br /&gt;
* Finding characters that are converted to other useful characters during the file upload process. For instance, when running PHP on IIS, the &amp;quot;&amp;gt;&amp;quot;, &amp;quot;&amp;lt;&amp;quot;, and double quote &amp;quot; characters respectively convert to &amp;quot;?&amp;quot;, &amp;quot;*&amp;quot;, and &amp;quot;.&amp;quot; characters that can be used to replace existing files (e.g. &amp;quot;web&amp;lt;&amp;lt;&amp;quot; can replace the &amp;quot;web.config&amp;quot; file). In order to include the double quote character in the filename in a normal file upload request, the filename in the &amp;quot;Content-Disposition&amp;quot; header should use single quotes (e.g. filename='web&amp;quot;config' to replace the &amp;quot;web.config&amp;quot; file).&lt;br /&gt;
* Finding neutral characters after a filename such as trailing spaces and dots in Windows filesystem or dot and slash characters in a Linux filesystem. These characters at the end of a filename will be removed automatically (e.g. &amp;quot;file.asp ... ... . . .. ..&amp;quot;, &amp;quot;file.asp &amp;quot;, or &amp;quot;file.asp.&amp;quot;). Although slash or backslash characters are also normally problematic characters, they can be ignored in a normal file upload request as anything before these characters may count as the directory name on the server-side; that said, they should be tried for a thorough test (e.g. &amp;quot;test.php/&amp;quot; or &amp;quot;test.php.\&amp;quot;).&lt;br /&gt;
* Finding flaws in extension detection techniques. A web server may use the first extension after the first dot (&amp;quot;.&amp;quot;) in the provided filename or use a flawed algorithm to detect the extension when there is none or multiple dot characters (e.g. &amp;quot;file.txt.jpg.php&amp;quot;). &lt;br /&gt;
* Using control characters such as null character (0x00) after a forbidden extension and before a permitted one may lead to a bypass. In this method, all the strings after the Null character will be discarded when saving the files. Both URL-encoded and decoded version of the null character should be tried in a file upload request for a thorough test. &lt;br /&gt;
* Using NTFS alternate data stream (ADS) in Windows. In this case, a colon character &amp;quot;:&amp;quot; will be inserted after a forbidden extension and before a permitted one. As a result, an empty file with the forbidden extension will be created on the server (e.g. &amp;quot;file.asax:.jpg&amp;quot;). This file might be edited later using other techniques such as using its short filename. The &amp;quot;::$data&amp;quot; pattern can also be used to create non-empty files. Therefore, adding a dot character after this pattern might also be useful to bypass further restrictions (.e.g. &amp;quot;file.asp::$data.&amp;quot;)&lt;br /&gt;
* Flaws in the protection mechanism when it replaces dangerous extensions. For instance, &amp;quot;file.p.phphp&amp;quot; might be changed to &amp;quot;file.php&amp;quot; after going through this functionality.&lt;br /&gt;
* Flaws in the uploaded file usage for instance when a PHP application uses the &amp;quot;include&amp;quot; function to show the uploaded images.&lt;br /&gt;
* Combination of the above techniques.&lt;br /&gt;
&lt;br /&gt;
=== Whitelisting File Extensions ===&lt;br /&gt;
&lt;br /&gt;
Applications that check the file extensions using a whitelist method also need to validate the full filename to prevent any bypass. &lt;br /&gt;
&lt;br /&gt;
* The list of permitted extensions should be reviewed as it can contain malicious extensions as well. For instance, in case of having &amp;quot;.shtml&amp;quot; in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
* Some of the bypass techniques for the blacklist methods such as using double extensions are also applicable here and should be checked. &lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;Content-Type&amp;quot; Header Validation ===&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Content-Type&amp;quot; entity in the header of the request indicates the Internet media type of the message content. Sometimes web applications use this parameter in order to recognise a file as a valid one. For instance, they only accept the files with the &amp;quot;Content-Type&amp;quot; of &amp;quot;text/plain&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
* It is possible to bypass this protection by changing this parameter in the request header using a web proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Detector ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the file types in order to process them further. For instance, when an application resize an image file, it may just show an error message when non-image files are uploaded without saving them on the server. &lt;br /&gt;
&lt;br /&gt;
* If it reads the few first characters (or headers), it can be bypassed by inserting malicious code after some valid header or within the file's metadata. &lt;br /&gt;
* Inserting code in the comments section or those section that have no effect on the main file can also lead to a bypass.&lt;br /&gt;
* The inserted data can be obfuscated or encoded if the application detects a malicious code using specific patterns or signatures.&lt;br /&gt;
* Uploaded file can be crafted to create a malicious code in case of being compressed by the application.&lt;br /&gt;
&lt;br /&gt;
=== Other Interesting Test Cases ===&lt;br /&gt;
&lt;br /&gt;
* Uploading a file when another file with the same name already exists. This may show interesting error messages that can lead to information disclosure. Logical flaws might be found if the application renames the new file to keep it on the server.&lt;br /&gt;
* Uploading a file when another folder with the same name already exists. This may show interesting error messages that can lead to information disclosure. &lt;br /&gt;
* Uploading a file with a long name. This may show interesting error messages that can lead to information disclosure.&lt;br /&gt;
* Uploading a file multiple times at the same time. This may show interesting error messages that can lead to information disclosure. &lt;br /&gt;
* Uploading valid and invalid files in different formats such as compressed or XML files to detect any possible processing on the server side. &lt;br /&gt;
* Uploading a file with &amp;quot;.&amp;quot;, &amp;quot;..&amp;quot;, or &amp;quot;...&amp;quot; as its name. For instance, in Apache in Windows, if the application saves the uploaded files in &amp;quot;/www/uploads/&amp;quot; directory, the &amp;quot;.&amp;quot; filename will create a file called &amp;quot;uploads&amp;quot; in the &amp;quot;/www/&amp;quot; directory.&lt;br /&gt;
* Uploading files that may not be deleted easily such as &amp;quot;...:.jpg&amp;quot; in NTFS that makes the &amp;quot;...&amp;quot; file (this file can be deleted using command line). This may show interesting error messages that can lead to information disclosure.&lt;br /&gt;
* Uploading a file in Windows with invalid characters such as |&amp;lt;&amp;gt;*?&amp;quot; in its name. This may show interesting error messages that can lead to information disclosure.  &lt;br /&gt;
* Uploading a file in Windows using reserved (forbidden) names such as CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. This may show interesting error messages that can lead to information disclosure. Uploading a file with a reserved name may lead to denial of service if the application keeps the name and tries to save it with another extension (detecting it wrongly as an existing file).&lt;br /&gt;
* Cross-site content hijacking issues can be exploited by uploading a file with allowed name and extension but with Flash, PDF, or Silverlight contents. &lt;br /&gt;
* Uploading a &amp;quot;crossdomain.xml&amp;quot; or &amp;quot;clientaccesspolicy.xml&amp;quot; file can make a website vulnerable to cross-site content hijacking. These files should be uploaded to the root of the website to work. However, the &amp;quot;crossdomain.xml&amp;quot; file can be in a subdirectory as long as it is allowed in the root &amp;quot;crossdomain.xml&amp;quot; file.&lt;br /&gt;
&lt;br /&gt;
=== Important Notes in Testing File Uploaders ===&lt;br /&gt;
&lt;br /&gt;
* Do not try to replace the existing files during testing unless it is safe to proceed. For instance, replacing configuration files such as &amp;quot;web.config&amp;quot; or &amp;quot;.htaccess&amp;quot; file can lead to a denial of service attack for the whole website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
* IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
* Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
* IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
* Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
* Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
* IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
* The file types allowed to be uploaded should be restricted to only those that are necessary for business functionality.&lt;br /&gt;
* Never accept a filename and its extension directly without having a whitelist filter.&lt;br /&gt;
* The application should perform filtering and content checking on any files which are uploaded to the server. Files should be thoroughly scanned and validated before being made available to other users. If in doubt, the file should be discarded.&lt;br /&gt;
* It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a &amp;quot;select case&amp;quot; syntax (in case of having VBScript) to choose the file extension in regards to the real file extension.&lt;br /&gt;
* All the control characters and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as &amp;quot;;&amp;quot;, &amp;quot;:&amp;quot;, &amp;quot;&amp;gt;&amp;quot;, &amp;quot;&amp;lt;&amp;quot;, &amp;quot;/&amp;quot; ,&amp;quot;\&amp;quot;, additional &amp;quot;.&amp;quot;, &amp;quot;*&amp;quot;, &amp;quot;%&amp;quot;, &amp;quot;$&amp;quot;, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
* Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
* It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
* Uploaded directory should not have any &amp;quot;execute&amp;quot; permission and all the script handlers should be removed from these directories.&lt;br /&gt;
* Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
* Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
* Use Cross Site Request Forgery protection methods.&lt;br /&gt;
* Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
* Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
* Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
* Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
* In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
* If it is possible, consider saving the files in a database rather than on the filesystem.&lt;br /&gt;
* If files should be saved in a filesystem, consider using an isolated server with a different domain to serve the uploaded files. &lt;br /&gt;
* File uploaders should be only accessible to authenticated and authorised users if possible.&lt;br /&gt;
* Write permission should be removed from files and folders other than the upload folders. The upload folders should not serve any &lt;br /&gt;
* Ensure that configuration files such as &amp;quot;.htaccess&amp;quot; or &amp;quot;web.config&amp;quot; cannot be replaced using file uploaders. Ensure that appropriate settings are available to ignore the &amp;quot;.htaccess&amp;quot; or &amp;quot;web.config&amp;quot; files if uploaded in the upload directories.&lt;br /&gt;
* Ensure that files with double extensions (e.g. &amp;quot;file.php.txt&amp;quot;) cannot be executed especially in Apache.&lt;br /&gt;
* Ensure that uploaded files cannot be accessed by unauthorised users.&lt;br /&gt;
* Adding the &amp;quot;Content-Disposition: Attachment&amp;quot; and &amp;quot;X-Content-Type-Options: nosniff&amp;quot; headers to the response of static files will secure the website against Flash or PDF-based cross-site content-hijacking attacks. It is recommended that this practice be performed for all of the files that users need to download in all the modules that deal with a file download. Although this method does not fully secure the website against attacks using Silverlight or similar objects, it can mitigate the risk of using Adobe Flash and PDF objects, especially when uploading PDF files is permitted.&lt;br /&gt;
* Flash/PDF (crossdomain.xml) or Silverlight (clientaccesspolicy.xml) cross-domain policy files should be removed if they are not in use and there is no business requirement for Flash or Silverlight applications to communicate with the website.&lt;br /&gt;
* Browser caching should be disabled for the corssdomain.xml and clientaccesspolicy.xml files. This enables the website to easily update the file or restrict access to the Web services if necessary. Once the client access policy file is checked, it remains in effect for the browser session so the impact of non-caching to the end-user is minimal. This can be raised as a low or informational risk issue based on the content of the target website and security and complexity of the policy file(s).&lt;br /&gt;
* CORS headers should be reviewed to only be enabled for static or publicly accessible data. Otherwise, the &amp;quot;Access-Control-Allow-Origin&amp;quot; header should only contain authorised addresses. Other CORS headers such as &amp;quot;Access-Control-Allow-Credentials&amp;quot; should only be used when they are required. Items within the CORS headers such as &amp;quot;Access-Control-Allow-Methods&amp;quot; or &amp;quot;Access-Control-Allow-Headers&amp;quot; should be reviewed and removed if they are not required.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]] ==&lt;br /&gt;
&lt;br /&gt;
* [[Path Traversal]]&lt;br /&gt;
* [[Path Manipulation]]&lt;br /&gt;
* [[Relative Path Traversal]]&lt;br /&gt;
* [[Windows_::DATA_alternate_data_stream]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation Vulnerability]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]] ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Threat Agent]] ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:External Threat Agent]]&lt;br /&gt;
* [[:Category:Internal Threat Agent]]&lt;br /&gt;
* [[:Category:Internet attacker]]&lt;br /&gt;
* [[:Category:Intranet attacker]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]] ==&lt;br /&gt;
&lt;br /&gt;
* [[System Access]]&lt;br /&gt;
* [[Security Bypass]]&lt;br /&gt;
* [[Exposure of system information]]&lt;br /&gt;
* [[Exposure of sensitive information]]&lt;br /&gt;
* [[Client Side Threat]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 [http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ ]&lt;br /&gt;
* 8 basic rules to implement secure file uploads - SANS - [http://software-security.sans.org/blog/2009/12/28/8-basic-rules-to-implement-secure-file-uploads]&lt;br /&gt;
* IIS6/ASP &amp;amp; file upload for fun and profit [http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/]&lt;br /&gt;
* Secure file upload in PHP web applications [http://www.net-security.org/dl/articles/php-file-upload.pdf]&lt;br /&gt;
* Potentially Dangerous File Types [http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf]&lt;br /&gt;
* Image Upload XSS [http://ha.ckers.org/blog/20070603/image-upload-xss/]&lt;br /&gt;
* Code Execution Through Filenames in Uploads [http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/]&lt;br /&gt;
* Secure File Upload Check List With PHP [http://hungred.com/useful-information/secure-file-upload-check-list-php/]&lt;br /&gt;
* NTFS in WikiPedia [http://en.wikipedia.org/wiki/NTFS]&lt;br /&gt;
* NTFS Streams [http://msdn.microsoft.com/en-us/library/ff469210(v=PROT.10).aspx]&lt;br /&gt;
* NTFS - Glossary [http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html]&lt;br /&gt;
* IIS 6.0 Security Best Practices [http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
* Securing Sites with Web Site Permissions [http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
* IIS 6.0 Operations Guide [http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
* Improving Web Application Security: Threats and Countermeasures [http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
* Understanding the Built-In User and Group Accounts in IIS 7.0 [http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
* IIS Security Checklist [http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
* Microsoft IIS ASP Multiple Extensions Security Bypass [http://secunia.com/advisories/37831/]&lt;br /&gt;
* CVE-2009-4444 [http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444]&lt;br /&gt;
* CVE-2009-4445 [http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445]&lt;br /&gt;
* CVE-2009-1535 [http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535]&lt;br /&gt;
* MSDN - Naming Files, Paths, and Namespaces [https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247(v=vs.85).aspx]&lt;br /&gt;
* Even uploading a JPG file can lead to Cross-Site Content Hijacking (client-side attack) [https://soroush.secproject.com/blog/2014/05/even-uploading-a-jpg-file-can-lead-to-cross-domain-data-hijacking-client-side-attack/]&lt;br /&gt;
* Cross-Site Content (Data) Hijacking (XSCH) PoC Project [https://github.com/nccgroup/CrossSiteContentHijacking]&lt;br /&gt;
* iPhone MobileSafari LibTIFF Buffer Overflow [https://www.exploit-db.com/exploits/16862/]&lt;br /&gt;
* ImageMagick Is On Fire-CVE-2016–3714 [https://imagetragick.com/]&lt;br /&gt;
* Symantec Antivirus multiple remote memory corruption unpacking RAR CVE-2016-2207 [https://bugs.chromium.org/p/project-zero/issues/detail?id=810]&lt;br /&gt;
* File in the hole - HackPra Nov. 2012 [https://www.nds.rub.de/media/attachments/files/2012/11/File-in-the-hole.pdf]&lt;br /&gt;
* Self contained web shells and other attacks via .htaccess files [https://github.com/wireghoul/htshells]&lt;br /&gt;
* Upload a web.config File for Fun &amp;amp; Profit [https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/]&lt;br /&gt;
* PHP filesystem attack vectors - Take Two [http://www.ush.it/2009/07/26/php-filesystem-attack-vectors-take-two/]&lt;br /&gt;
* File Upload and PHP on IIS: &amp;gt;=? and &amp;lt;=* and &amp;quot;=. [https://soroush.secproject.com/blog/2014/07/file-upload-and-php-on-iis-wildcards/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Authors ==&lt;br /&gt;
* [[User:Soroush Dalili|Soroush Dalili]]&lt;br /&gt;
* [[User:Dirk Wetter|Dirk Wetter]]&lt;br /&gt;
* [[User:Landon Mayo|Landon Mayo]]&lt;br /&gt;
* [[User:OWASP|OWASP]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
[[Category:File System]]&lt;br /&gt;
[[Category:Windows]]&lt;br /&gt;
[[Category:Unix]]&lt;br /&gt;
[[Category:Use of Dangerous API]]&lt;br /&gt;
[[Category:Vulnerability]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159809</id>
		<title>User:Soroush Dalili</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159809"/>
				<updated>2013-10-06T13:16:03Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Info ==&lt;br /&gt;
&lt;br /&gt;
My full name is “Soroush Dalili”. My field of expertise is web application security. Please visit my weblog to find more information.&lt;br /&gt;
&lt;br /&gt;
== OWASP Activities ==&lt;br /&gt;
* [[Unrestricted File Upload]]&lt;br /&gt;
&lt;br /&gt;
== Main Links ==&lt;br /&gt;
&lt;br /&gt;
* Blog - Direct Link: [http://soroush.secproject.com/blog/ Soroush.SecProject.com/blog/]&lt;br /&gt;
* Advisories - Direct Link: [http://soroush.secproject.com/blog/my-advisories/ Soroush.SecProject.com/blog/my-advisories/]&lt;br /&gt;
* Twitter: [http://www.twitter.com/irsdl www.twitter.com/irsdl]&lt;br /&gt;
* Linkedin: [http://uk.linkedin.com/in/irsdl uk.linkedin.com/in/irsdl]&lt;br /&gt;
* Me &amp;amp; Google!: [http://www.google.com/search?q=soroush%20dalili www.google.com/search?q=soroush dalili]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159808</id>
		<title>User:Soroush Dalili</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159808"/>
				<updated>2013-10-06T13:15:49Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Info ==&lt;br /&gt;
&lt;br /&gt;
My full name is “Soroush Dalili”. My field of expertise is web application security. Please visit my weblog to find more information.&lt;br /&gt;
&lt;br /&gt;
== OWASP Activities ==&lt;br /&gt;
* [[Unrestricted File Upload]]&lt;br /&gt;
&lt;br /&gt;
== Main Links ==&lt;br /&gt;
&lt;br /&gt;
* Website: [http://soroush.secproject.com/ Soroush.SecProject.com]&lt;br /&gt;
* Blog - Direct Link: [http://soroush.secproject.com/blog/ Soroush.SecProject.com/blog/]&lt;br /&gt;
* Advisories - Direct Link: [http://soroush.secproject.com/blog/my-advisories/ Soroush.SecProject.com/blog/my-advisories/]&lt;br /&gt;
* Twitter: [http://www.twitter.com/irsdl www.twitter.com/irsdl]&lt;br /&gt;
* Linkedin: [http://uk.linkedin.com/in/irsdl uk.linkedin.com/in/irsdl]&lt;br /&gt;
* Me &amp;amp; Google!: [http://www.google.com/search?q=soroush%20dalili www.google.com/search?q=soroush dalili]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159807</id>
		<title>User:Soroush Dalili</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159807"/>
				<updated>2013-10-06T13:11:25Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Info ==&lt;br /&gt;
&lt;br /&gt;
My full name is “Soroush Dalili”. My field of expertise is web application security. Please visit my weblog to find more information.&lt;br /&gt;
&lt;br /&gt;
== OWASP Activities ==&lt;br /&gt;
* [[Unrestricted File Upload]]&lt;br /&gt;
&lt;br /&gt;
== Main Links ==&lt;br /&gt;
&lt;br /&gt;
* Website: [http://soroush.secproject.com/ Soroush.SecProject.com]&lt;br /&gt;
* Blog - Direct Link: [http://soroush.secproject.com/blog/ Soroush.SecProject.com/blog/]&lt;br /&gt;
* Advisories - Direct Link: [http://soroush.secproject.com/blog/my-advisories/ Soroush.SecProject.com/blog/my-advisories/]&lt;br /&gt;
* Wiki User Page: [http://en.wikipedia.org/wiki/User:Irsdl Wiki User Page]&lt;br /&gt;
* Twitter: [http://www.twitter.com/irsdl www.twitter.com/irsdl]&lt;br /&gt;
* Linkedin: [http://uk.linkedin.com/in/irsdl uk.linkedin.com/in/irsdl]&lt;br /&gt;
* Google me: [http://www.google.com/search?q=soroush%20dalili www.google.com/search?q=soroush dalili]&lt;br /&gt;
&lt;br /&gt;
== Other Backup Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.soroush.me/ www.soroush.me]&lt;br /&gt;
* [http://www.sdl.me/ www.sdl.me]&lt;br /&gt;
* [http://dalili.soroush.me/ dalili.soroush.me]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159806</id>
		<title>User:Soroush Dalili</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=159806"/>
				<updated>2013-10-06T13:09:42Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Info ==&lt;br /&gt;
&lt;br /&gt;
My full name is “Soroush Dalili” and my usual instant name in web is SDL or IRSDL. I’m working on the computer security stuffs, and my field of expertise is penetration testing and especially web application security.&lt;br /&gt;
&lt;br /&gt;
== OWASP Activities ==&lt;br /&gt;
* [[Unrestricted File Upload]]&lt;br /&gt;
&lt;br /&gt;
== Main Links ==&lt;br /&gt;
&lt;br /&gt;
* Website: [http://soroush.secproject.com/ Soroush.SecProject.com]&lt;br /&gt;
* Blog - Direct Link: [http://soroush.secproject.com/blog/ Soroush.SecProject.com/blog/]&lt;br /&gt;
* Advisories - Direct Link: [http://soroush.secproject.com/blog/my-advisories/ Soroush.SecProject.com/blog/my-advisories/]&lt;br /&gt;
* Wiki User Page: [http://en.wikipedia.org/wiki/User:Irsdl Wiki User Page]&lt;br /&gt;
* Twitter: [http://www.twitter.com/irsdl www.twitter.com/irsdl]&lt;br /&gt;
* Linkedin: [http://uk.linkedin.com/in/irsdl uk.linkedin.com/in/irsdl]&lt;br /&gt;
* Google me: [http://www.google.com/search?q=soroush%20dalili www.google.com/search?q=soroush dalili]&lt;br /&gt;
&lt;br /&gt;
== Other Backup Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.soroush.me/ www.soroush.me]&lt;br /&gt;
* [http://www.sdl.me/ www.sdl.me]&lt;br /&gt;
* [http://dalili.soroush.me/ dalili.soroush.me]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Risk_Rating_Methodology&amp;diff=133450</id>
		<title>OWASP Risk Rating Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Risk_Rating_Methodology&amp;diff=133450"/>
				<updated>2012-07-24T23:06:17Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: Skill level section fixed. Still not sure how can we have &amp;quot;5&amp;quot; in the example for the Skill level.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v3}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The OWASP Risk Rating Methodology== &lt;br /&gt;
&lt;br /&gt;
Discovering vulnerabilities is important, but just as important is being able to estimate the associated risk to the business. Early in the lifecycle, you may identify security concerns in the architecture or design by using [[threat modeling]].  Later, you may find security issues using [[code review]] or [[penetration testing]].  Or you may not discover a problem until the application is in production and is actually compromised.&lt;br /&gt;
&lt;br /&gt;
By following the approach here, you'll be able to estimate the severity of all of these risks to your business, and make an informed decision about what to do about them. Having a system in place for rating risks will save time and eliminate arguing about priorities. This system will help to ensure that you don't get distracted by minor risks while ignoring more serious risks that are less well understood.&lt;br /&gt;
&lt;br /&gt;
Ideally, there would be a universal risk rating system that would accurately estimate all risks for all organizations. But a vulnerability that is critical to one organization may not be very important to another. So a basic framework is presented here that you ''should customize'' for your organization.&lt;br /&gt;
&lt;br /&gt;
The authors have tried hard to make this model simple enough to use, while keeping enough detail for accurate risk estimates to be made. Please reference the section below on customization for more information about tailoring the model for use in your organization.&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
There are many different approaches to risk analysis. See the reference section below for some of the most common ones. The OWASP approach presented here is based on these standard methodologies and is customized for application security.&lt;br /&gt;
&lt;br /&gt;
Let's start with the standard risk model:&lt;br /&gt;
&lt;br /&gt;
       '''Risk = Likelihood * Impact'''&lt;br /&gt;
&lt;br /&gt;
In the sections below, we break down the factors that make up &amp;quot;likelihood&amp;quot; and &amp;quot;impact&amp;quot; for application security and show how to combine them to determine the overall severity for the risk.&lt;br /&gt;
&lt;br /&gt;
* [[#Step 1: Identifying a Risk]]&lt;br /&gt;
* [[#Step 2: Factors for Estimating Likelihood]]&lt;br /&gt;
* [[#Step 3: Factors for Estimating Impact]]&lt;br /&gt;
* [[#Step 4: Determining Severity of the Risk]]&lt;br /&gt;
* [[#Step 5: Deciding What to Fix]]&lt;br /&gt;
* [[#Step 6: Customizing Your Risk Rating Model]]&lt;br /&gt;
&lt;br /&gt;
==Step 1: Identifying a Risk==&lt;br /&gt;
&lt;br /&gt;
The first step is to identify a security risk that needs to be rated. You'll need to gather information about the [[threat agent]] involved, the [[attack]] they're using, the [[vulnerability]] involved, and the [[impact]] of a successful exploit on your business. There may be multiple possible groups of attackers, or even multiple possible business impacts.  In general, it's best to err on the side of caution by using the worst-case option, as that will result in the highest overall risk.&lt;br /&gt;
&lt;br /&gt;
==Step 2: Factors for Estimating Likelihood==&lt;br /&gt;
&lt;br /&gt;
Once you've identified a potential risk, and want to figure out how serious it is, the first step is to estimate the &amp;quot;likelihood&amp;quot;. At the highest level, this is a rough measure of how likely this particular vulnerability is to be uncovered and exploited by an attacker. We do not need to be over-precise in this estimate. Generally, identifying whether the likelihood is low, medium, or high is sufficient.&lt;br /&gt;
&lt;br /&gt;
There are a number of factors that can help us figure this out. The first set of factors are related to the [[threat agent]] involved. The goal is to estimate the likelihood of a successful attack from a group of possible attackers. Note that there may be multiple threat agents that can exploit a particular vulnerability, so it's usually best to use the worst-case scenario. For example, an insider may be a much more likely attacker than an anonymous outsider - but it depends on a number of factors.&lt;br /&gt;
&lt;br /&gt;
Note that each factor has a set of options, and each option has a likelihood rating from 0 to 9 associated with it. We'll use these numbers later to estimate the overall likelihood.&lt;br /&gt;
&lt;br /&gt;
===[[Threat Agent]] Factors===&lt;br /&gt;
&lt;br /&gt;
The first set of factors are related to the [[threat agent]] involved. The goal here is to estimate the likelihood of a successful attack by this group of threat agents. Use the worst-case threat agent.&lt;br /&gt;
&lt;br /&gt;
; Skill level&lt;br /&gt;
: How technically skilled is this group of threat agents? Security penetration skills (1), network and programming skills (3), advanced computer user (4), some technical skills (6), no technical skills (9)&lt;br /&gt;
&lt;br /&gt;
; Motive&lt;br /&gt;
: How motivated is this group of threat agents to find and exploit this vulnerability? Low or no reward (1), possible reward (4), high reward (9)&lt;br /&gt;
&lt;br /&gt;
; Opportunity&lt;br /&gt;
: What resources and opportunity are required for this group of threat agents to find and exploit this vulnerability? full access or expensive resources required (0), special access or resources required (4), some access or resources required (7), no access or resources required (9)&lt;br /&gt;
&lt;br /&gt;
; Size&lt;br /&gt;
: How large is this group of threat agents? Developers (2), system administrators (2), intranet users (4), partners (5), authenticated users (6), anonymous Internet users (9)&lt;br /&gt;
&lt;br /&gt;
===[[Vulnerability]] Factors===&lt;br /&gt;
&lt;br /&gt;
The next set of factors are related to the [[vulnerability]] involved. The goal here is to estimate the likelihood of the particular vulnerability involved being discovered and exploited. Assume the threat agent selected above.&lt;br /&gt;
&lt;br /&gt;
; Ease of discovery&lt;br /&gt;
: How easy is it for this group of threat agents to discover this vulnerability? Practically impossible (1), difficult (3), easy (7), automated tools available (9)&lt;br /&gt;
&lt;br /&gt;
; Ease of exploit&lt;br /&gt;
: How easy is it for this group of threat agents to actually exploit this vulnerability? Theoretical (1), difficult (3), easy (5), automated tools available (9)&lt;br /&gt;
&lt;br /&gt;
; Awareness&lt;br /&gt;
: How well known is this vulnerability to this group of threat agents? Unknown (1), hidden (4), obvious (6), public knowledge (9)&lt;br /&gt;
&lt;br /&gt;
; Intrusion detection&lt;br /&gt;
: How likely is an exploit to be detected? Active detection in application (1), logged and reviewed (3), logged without review (8), not logged (9)&lt;br /&gt;
&lt;br /&gt;
==Step 3: Factors for Estimating Impact==&lt;br /&gt;
&lt;br /&gt;
When considering the impact of a successful attack, it's important to realize that there are two kinds of impacts. The first is the &amp;quot;technical impact&amp;quot; on the application, the data it uses, and the functions it provides.  The other is the &amp;quot;business impact&amp;quot; on the business and company operating the application.&lt;br /&gt;
&lt;br /&gt;
Ultimately, the business impact is more important. However, you may not have access to all the information required to figure out the business consequences of a successful exploit. In this case, providing as much detail about the technical risk will enable the appropriate business representative to make a decision about the business risk.&lt;br /&gt;
&lt;br /&gt;
Again, each factor has a set of options, and each option has an impact rating from 0 to 9 associated with it. We'll use these numbers later to estimate the overall impact.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Technical Impact Factors===&lt;br /&gt;
&lt;br /&gt;
Technical impact can be broken down into factors aligned with the traditional security areas of concern: confidentiality, integrity, availability, and accountability. The goal is to estimate the magnitude of the impact on the system if the vulnerability were to be exploited.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Loss of confidentiality&lt;br /&gt;
: How much data could be disclosed and how sensitive is it? Minimal non-sensitive data disclosed (2), minimal critical data disclosed (6), extensive non-sensitive data disclosed (6), extensive critical data disclosed (7), all data disclosed (9)&lt;br /&gt;
&lt;br /&gt;
; Loss of integrity&lt;br /&gt;
: How much data could be corrupted and how damaged is it? Minimal slightly corrupt data (1), minimal seriously corrupt data (3), extensive slightly corrupt data (5), extensive seriously corrupt data (7), all data totally corrupt (9)&lt;br /&gt;
&lt;br /&gt;
; Loss of availability&lt;br /&gt;
: How much service could be lost and how vital is it? Minimal secondary services interrupted (1), minimal primary services interrupted (5), extensive secondary services interrupted (5), extensive primary services interrupted (7), all services completely lost (9)&lt;br /&gt;
&lt;br /&gt;
; Loss of accountability&lt;br /&gt;
: Are the threat agents' actions traceable to an individual? Fully traceable (1), possibly traceable (7), completely anonymous (9)&lt;br /&gt;
&lt;br /&gt;
===Business Impact Factors===&lt;br /&gt;
&lt;br /&gt;
The business impact stems from the technical impact, but requires a deep understanding of what is important to the company running the application. In general, you should be aiming to support your risks with business impact, particularly if your audience is executive level. The business risk is what justifies investment in fixing security problems.&lt;br /&gt;
&lt;br /&gt;
Many companies have an asset classification guide and/or a business impact reference to help formalize what is important to their business. These standards can help you focus on what's truly important for security. If these aren't available, then talk with people who understand the business to get their take on what's important.&lt;br /&gt;
&lt;br /&gt;
The factors below are common areas for many businesses, but this area is even more unique to a company than the factors related to threat agent, vulnerability, and technical impact.&lt;br /&gt;
&lt;br /&gt;
; Financial damage&lt;br /&gt;
: How much financial damage will result from an exploit? Less than the cost to fix the vulnerability (1), minor effect on annual profit (3), significant effect on annual profit (7), bankruptcy (9)&lt;br /&gt;
&lt;br /&gt;
; Reputation damage&lt;br /&gt;
: Would an exploit result in reputation damage that would harm the business? Minimal damage (1), Loss of major accounts (4), loss of goodwill (5), brand damage (9)&lt;br /&gt;
&lt;br /&gt;
; Non-compliance&lt;br /&gt;
: How much exposure does non-compliance introduce? Minor violation (2), clear violation (5), high profile violation (7)&lt;br /&gt;
&lt;br /&gt;
; Privacy violation&lt;br /&gt;
: How much personally identifiable information could be disclosed? One individual (3), hundreds of people (5), thousands of people (7), millions of people (9)&lt;br /&gt;
&lt;br /&gt;
==Step 4: Determining the Severity of the Risk== &lt;br /&gt;
&lt;br /&gt;
In this step we're going to put together the likelihood estimate and the impact estimate to calculate an overall severity for this risk.  All you need to do here is figure out whether the likelihood is LOW, MEDIUM, or HIGH and then do the same for impact. We'll just split our 0 to 9 scale into three parts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot; width=&amp;quot;40%&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; colspan=&amp;quot;2&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Likelihood and Impact Levels&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;50%&amp;quot;&amp;gt;0 to &amp;amp;lt;3&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;50%&amp;quot; bgcolor=&amp;quot;lightgreen&amp;quot;&amp;gt;LOW&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;3 to &amp;amp;lt;6&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;yellow&amp;quot;&amp;gt;MEDIUM&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;6 to 9&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;red&amp;quot;&amp;gt;HIGH&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Informal Method===&lt;br /&gt;
&lt;br /&gt;
In many environments, there is nothing wrong with &amp;quot;eyeballing&amp;quot; the factors and simply capturing the answers. You should think through the factors and identify the key &amp;quot;driving&amp;quot; factors that are controlling the result. You may discover that your initial impression was wrong by considering aspects of the risk that weren't obvious.&lt;br /&gt;
&lt;br /&gt;
===Repeatable Method===&lt;br /&gt;
&lt;br /&gt;
If you need to defend your ratings or make them repeatable, then you may want to go through a more formal process of rating the factors and calculating the result. Remember that there is quite a lot of uncertainty in these estimates, and that these factors are intended to help you arrive at a sensible result. This process can be supported by automated tools to make the calculation easier. &lt;br /&gt;
&lt;br /&gt;
The first step is to select one of the options associated with each factor and enter the associated number in the table. Then you simply take the average of the scores to calculate the overall likelihood. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td colspan=&amp;quot;4&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Threat agent factors&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td  colspan=&amp;quot;4&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Vulnerability factors&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Skill level&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Motive&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Opportunity&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Size&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;2%&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Ease of discovery&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Ease of exploit&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Awareness&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Intrusion detection&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;5&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;2&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;7&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;1&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;3&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;6&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;9&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;2&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td colspan=&amp;quot;9&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightblue&amp;quot;&amp;gt;Overall likelihood=4.375 (MEDIUM)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we need to figure out the overall impact. The process is similar here. In many cases the answer will be obvious, but you can make an estimate based on the factors, or you can average the scores for each of the factors. Again, less than 3 is LOW, 3 to less than 6 is MEDIUM, and 6 to 9 is HIGH.  For example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td colspan=&amp;quot;4&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Technical Impact&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td  colspan=&amp;quot;4&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Business Impact&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Loss of confidentiality&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Loss of integrity&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Loss of availability&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Loss of accountability&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;2%&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Financial damage&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Reputation damage&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Non-compliance&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;10%&amp;quot;&amp;gt;Privacy violation&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;9&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;7&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;5&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;8&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;1&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;2&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;1&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;5&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td colspan=&amp;quot;4&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightblue&amp;quot;&amp;gt;Overall technical impact=7.25 (HIGH)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td colspan=&amp;quot;4&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightblue&amp;quot;&amp;gt;Overall business impact=2.25 (LOW)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Determining Severity===&lt;br /&gt;
&lt;br /&gt;
However we arrived at the likelihood and impact estimates, we can now combine them to get a final severity rating for this risk. Note that if you have good business impact information, you should use that instead of the technical impact information.  But if you have no information about the business, then technical impact is the next best thing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; colspan=&amp;quot;5&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Overall Risk Severity&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;15%&amp;quot; rowspan=&amp;quot;4&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Impact&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;15%&amp;quot;&amp;gt;HIGH&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;15%&amp;quot; bgcolor=&amp;quot;orange&amp;quot;&amp;gt;Medium&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;15%&amp;quot; bgcolor=&amp;quot;red&amp;quot;&amp;gt;High&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; width=&amp;quot;15%&amp;quot; bgcolor=&amp;quot;pink&amp;quot;&amp;gt;Critical&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;MEDIUM&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;yellow&amp;quot;&amp;gt;Low&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;orange&amp;quot;&amp;gt;Medium&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;red&amp;quot;&amp;gt;High&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;LOW&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightgreen&amp;quot;&amp;gt;Note&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;yellow&amp;quot;&amp;gt;Low&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;orange&amp;quot;&amp;gt;Medium&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;LOW&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;MEDIUM&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;HIGH&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td align=&amp;quot;center&amp;quot; colspan=&amp;quot;4&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Likelihood&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example above, the likelihood is MEDIUM, and the technical impact is HIGH, so from a purely technical perspective, it appears that the overall severity is HIGH.  However, note that the business impact is actually LOW, so the overall severity is best described as LOW as well. This is why understanding the business context of the vulnerabilities you are evaluating is so critical to making good risk decisions. Failure to understand this context can lead to the lack of trust between the business and security teams that is present in many organizations.&lt;br /&gt;
&lt;br /&gt;
==Step 5: Deciding What to Fix==&lt;br /&gt;
&lt;br /&gt;
After you've classified the risks to your application, you'll have a prioritized list of what to fix. As a general rule, you should fix the most severe risks first. It simply doesn't help your overall risk profile to fix less important risks, even if they're easy or cheap to fix.&lt;br /&gt;
&lt;br /&gt;
Remember, not all risks are worth fixing, and some loss is not only expected, but justifiable based upon the cost of fixing the issue. For example, if it would cost $100,000 to implement controls to stem $2,000 of fraud per year, it would take 50 years return on investment to stamp out the loss. But remember there may be reputation damage from the fraud that could cost the organization much more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Step 6: Customizing Your Risk Rating Model==&lt;br /&gt;
&lt;br /&gt;
Having a risk ranking framework that's customizable for a business is critical for adoption.  A tailored model is much more likely to produce results that match people's perceptions about what is a serious risk. You can waste lots of time arguing about the risk ratings if they're not supported by a model like this. There are several ways to tailor this model for your organization.&lt;br /&gt;
&lt;br /&gt;
===Adding factors===&lt;br /&gt;
&lt;br /&gt;
You can choose different factors that better represent what's important for your organization. For example, a military application might add impact factors related to loss of human life or classified information. You might also add likelihood factors, such as the window of opportunity for an attacker or encryption algorithm strength.&lt;br /&gt;
&lt;br /&gt;
===Customizing options===&lt;br /&gt;
&lt;br /&gt;
There are some sample options associated with each factor, but the model will be much more effective if you customize these options to your business. For example, use the names of the different teams and your names for different classifications of information. You can also change the scores associated with the options. The best way to identify the right scores is to compare the ratings produced by the model with ratings produced by a team of experts. You can tune the model by carefully adjusting the scores to match.&lt;br /&gt;
&lt;br /&gt;
===Weighting factors===&lt;br /&gt;
&lt;br /&gt;
The model above assumes that all the factors are equally important. You can weight the factors to emphasize the factors that are more significant for your business. This makes the model a bit more complex, as you'll need to use a weighted average. But otherwise everything works the same. Again, you can tune the model by matching it against risk ratings you agree are accurate.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* NIST 800-30 Risk Management Guide for Information Technology Systems [http://csrc.nist.gov/publications/nistpubs/800-30/sp800-30.pdf]&lt;br /&gt;
&lt;br /&gt;
* AS/NZS 4360 Risk Management [http://www.saiglobal.com/shop/script/Details.asp?docn=AS564557616854]&lt;br /&gt;
&lt;br /&gt;
* Industry standard vulnerability severity and risk rankings (CVSS) [http://www.first.org/cvss/]&lt;br /&gt;
&lt;br /&gt;
* Security-enhancing process models (CLASP) [http://www.owasp.org/index.php/Category:OWASP_CLASP_Project]&lt;br /&gt;
&lt;br /&gt;
* Microsoft Web Application Security Frame [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/TMWA.asp]&lt;br /&gt;
&lt;br /&gt;
* Security In The Software Lifecycle from DHS [https://buildsecurityin.us-cert.gov/daisy/bsi/87/version/12/part/4/data/Draft+Security+in+the+Software+Lifcycle+v1.2.pdf?branch=main&amp;amp;language=default]&lt;br /&gt;
&lt;br /&gt;
* [[Threat_Risk_Modeling|Threat Risk Modeling]]&lt;br /&gt;
&lt;br /&gt;
* Pratical Threat Analysis [http://www.ptatechnologies.com/]&lt;br /&gt;
&lt;br /&gt;
* A Platform for Risk Analysis of Security Critical Systems [http://www2.nr.no/coras/]&lt;br /&gt;
&lt;br /&gt;
* Model-driven Development and Analysis of Secure Information Systems [http://heim.ifi.uio.no/~ketils/securis/the-securis-technical-description.htm]&lt;br /&gt;
&lt;br /&gt;
* Value Driven Security Threat Modeling Based on Attack Path Analysis[http://sunset.usc.edu/events/2006/CSSE_Convocation/publications/ChenValueBasedSecurityThreatModel.pdf]&lt;br /&gt;
&lt;br /&gt;
== Project Sponsors ==&lt;br /&gt;
&lt;br /&gt;
This project is sponsored by {{MemberLinks|link=http://www.aspectsecurity.com|logo=Aspect_logo_owasp.jpg}}&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=126279</id>
		<title>User:Soroush Dalili</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=126279"/>
				<updated>2012-03-14T20:46:50Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Info ==&lt;br /&gt;
&lt;br /&gt;
My full name is “Soroush Dalili” and my usual instant name in web is SDL or IRSDL. I’m working on the computer security stuffs, and my field of expertise is penetration testing and especially web application security.&lt;br /&gt;
&lt;br /&gt;
== OWASP Activities ==&lt;br /&gt;
* [[Unrestricted File Upload]]&lt;br /&gt;
&lt;br /&gt;
== Main Links ==&lt;br /&gt;
&lt;br /&gt;
* Website: [http://soroush.secproject.com/ Soroush.SecProject.com]&lt;br /&gt;
* Blog - Direct Link: [http://soroush.secproject.com/blog/ Soroush.SecProject.com/blog/]&lt;br /&gt;
* Advisories - Direct Link: [http://soroush.secproject.com/blog/my-advisories/ Soroush.SecProject.com/blog/my-advisories/]&lt;br /&gt;
* Mirror Blog: [http://irsdl1.wordpress.com/ irsdl1.wordpress.com] (as my main web hosting (GoDaddy) has filtered some countries such as Iran)&lt;br /&gt;
* Wiki User Page: [http://en.wikipedia.org/wiki/User:Irsdl Wiki User Page]&lt;br /&gt;
* Twitter: [http://www.twitter.com/irsdl www.twitter.com/irsdl]&lt;br /&gt;
* Linkedin: [http://uk.linkedin.com/in/irsdl uk.linkedin.com/in/irsdl]&lt;br /&gt;
* Google me: [http://www.google.com/search?q=soroush%20dalili www.google.com/search?q=soroush dalili]&lt;br /&gt;
&lt;br /&gt;
== Other Backup Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.soroush.me/ www.soroush.me]&lt;br /&gt;
* [http://www.sdl.me/ www.sdl.me]&lt;br /&gt;
* [http://dalili.soroush.me/ dalili.soroush.me]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Windows_::DATA_alternate_data_stream&amp;diff=100985</id>
		<title>Talk:Windows ::DATA alternate data stream</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Windows_::DATA_alternate_data_stream&amp;diff=100985"/>
				<updated>2011-01-19T13:06:20Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: Created page with 'Please check if it's an attack. It didn't have any special category.'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Please check if it's an attack. It didn't have any special category.&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Windows_::DATA_alternate_data_stream&amp;diff=100984</id>
		<title>Windows ::DATA alternate data stream</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Windows_::DATA_alternate_data_stream&amp;diff=100984"/>
				<updated>2011-01-19T13:03:07Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Attack}}&lt;br /&gt;
&lt;br /&gt;
Last revision: '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
The NTFS file system includes support for alternate data streams.  This is not a well known feature and was included, primarily, to provide compatibility with files in the Macintosh file system.  Alternate data streams allow files to contain more than one stream of data.  Every file has at least one data stream.  In Windows, this default data stream is called :$DATA.&lt;br /&gt;
&lt;br /&gt;
Windows Explorer doesn't provide a way of seing what alternate data streams are in a file (or a way to remove them without deleting the file) but they can be created and accessed easily.  Because they are difficult to find they are often used by hackers to hide files on machines that they've compromised (perhaps files for a rootkit).  Executables in alternate data streams can be executed from the command line but they will not show up in Windows Explorer (or the Console).  Reference Example 1 for information on creating and accessing alternate data streams.&lt;br /&gt;
&lt;br /&gt;
Since the :$DATA alternate stream exists for every file it can be an alternate way to access any file.  Reference Example 2 for information on accessing the :$DATA alternate data stream in a text file.  Any application that creates files or looks at or depends on the end of the file name (or the extension) should be aware of the possibility of these alternate data streams.  If unsanitized user input is used to create or reference a file name an attacker could use the :$DATA stream to change the behavior of the software.  A well-known vulnerability of this nature existed in older versions of IIS.  When IIS saw a request for a file with an ASP extension it sent the ASP file to the application associated with the extension.  This application would run the server-side code in the ASP file and generate the HTML response for the request.  Due to a flaw in the extension parsing of these versions of IIS, filename.asp::$DATA did not match the extension and since there was no application registered for the asp::$DATA extension, the asp source code was returned to the attacker.&lt;br /&gt;
&lt;br /&gt;
Proper user input sanitation is the best defense against this type of attack.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
===Example 1 - Creating Alternate Data Streams===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
C:\&amp;gt; type C:\windows\system32\notepad.exe &amp;gt; c:\windows\system32\calc.exe:notepad.exe&lt;br /&gt;
C:\&amp;gt; start c:\windows\system32\calc.exe:notepad.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 2 - Accessing the :$DATA Alternate Data Stream===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
C:\&amp;gt; start c:\textfile.txt::$DATA&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 3 - Exploiting the ASP Alternate Data Stream Show Code Vulnerability===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Normal access:&lt;br /&gt;
    http://www.alternate-data-streams.com/default.asp&lt;br /&gt;
&lt;br /&gt;
Show code bypass accessing the :$DATA alternate data stream:&lt;br /&gt;
    http://www.alternate-data-streams.com/default.asp::$DATA&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In the vulnerable versions, IIS parsed the extension of this file as asp::$DATA, not ASP.  As such the application associated with the ASP extension was not invoked and the ASP source code was viewable by the attacker.&lt;br /&gt;
&lt;br /&gt;
==Related Threats==&lt;br /&gt;
&lt;br /&gt;
==Related Attacks==&lt;br /&gt;
&lt;br /&gt;
==Related Vulnerabilities==&lt;br /&gt;
* [[Unrestricted File Upload]]&lt;br /&gt;
&lt;br /&gt;
==Related Countermeasures==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation]]&lt;br /&gt;
&lt;br /&gt;
==Categories==&lt;br /&gt;
&lt;br /&gt;
[[Category:Attack]]&lt;br /&gt;
[[Category:Windows]]&lt;br /&gt;
[[Category:Input Validation]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=100983</id>
		<title>User:Soroush Dalili</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=100983"/>
				<updated>2011-01-19T12:50:20Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Info ==&lt;br /&gt;
&lt;br /&gt;
My full name is “Soroush Dalili” and my usual instant name in web is SDL or IRSDL. I’m working on the computer security stuffs, and my field of expertise is penetration testing and especially web application security.&lt;br /&gt;
&lt;br /&gt;
== OWASP Activities ==&lt;br /&gt;
* [[Unrestricted File Upload]]&lt;br /&gt;
&lt;br /&gt;
== Main Links ==&lt;br /&gt;
&lt;br /&gt;
* Website: [http://soroush.secproject.com/ Soroush.SecProject.com]&lt;br /&gt;
* Blog - Direct Link: [http://soroush.secproject.com/blog/ Soroush.SecProject.com/blog/]&lt;br /&gt;
* Advisories - Direct Link: [http://soroush.secproject.com/blog/my-advisories/ Soroush.SecProject.com/blog/my-advisories/]&lt;br /&gt;
* Mirror Blog: [http://irsdl1.wordpress.com/ irsdl1.wordpress.com] (as my main web hosting (GoDaddy) has filtered some countries such as Iran)&lt;br /&gt;
* Wiki User Page: [http://en.wikipedia.org/wiki/User:Irsdl Wiki User Page]&lt;br /&gt;
* Twitter: [http://www.twitter.com/irsdl www.twitter.com/irsdl]&lt;br /&gt;
* Linkedin: [http://uk.linkedin.com/in/irsdl uk.linkedin.com/in/irsdl]&lt;br /&gt;
* Google me: [http://www.google.com/search?q=soroush%20dalili www.google.com/search?q=soroush dalili]&lt;br /&gt;
&lt;br /&gt;
== Other Backup Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.soroush.me/ www.soroush.me]&lt;br /&gt;
* [http://www.sdl.me/ www.sdl.me]&lt;br /&gt;
* [http://dalili.soroush.me/ dalili.soroush.me]&lt;br /&gt;
* [http://www.plaincipher.com/ www.plaincipher.com]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=100982</id>
		<title>User:Soroush Dalili</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Soroush_Dalili&amp;diff=100982"/>
				<updated>2011-01-19T12:48:32Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Info ==&lt;br /&gt;
&lt;br /&gt;
My full name is “Soroush Dalili” and my usual instant name in web is SDL or IRSDL. I’m working on the computer security stuffs, and my field of expertise is penetration testing and especially web application security.&lt;br /&gt;
&lt;br /&gt;
== Main Links ==&lt;br /&gt;
&lt;br /&gt;
* Website: [http://soroush.secproject.com/ Soroush.SecProject.com]&lt;br /&gt;
* Blog - Direct Link: [http://soroush.secproject.com/blog/ Soroush.SecProject.com/blog/]&lt;br /&gt;
* Advisories - Direct Link: [http://soroush.secproject.com/blog/my-advisories/ Soroush.SecProject.com/blog/my-advisories/]&lt;br /&gt;
* Mirror Blog: [http://irsdl1.wordpress.com/ irsdl1.wordpress.com] (as my main web hosting (GoDaddy) has filtered some countries such as Iran)&lt;br /&gt;
* Wiki User Page: [http://en.wikipedia.org/wiki/User:Irsdl Wiki User Page]&lt;br /&gt;
* Twitter: [http://www.twitter.com/irsdl www.twitter.com/irsdl]&lt;br /&gt;
* Linkedin: [http://uk.linkedin.com/in/irsdl uk.linkedin.com/in/irsdl]&lt;br /&gt;
* Google me: [http://www.google.com/search?q=soroush%20dalili www.google.com/search?q=soroush dalili]&lt;br /&gt;
&lt;br /&gt;
== Other Backup Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.soroush.me/ www.soroush.me]&lt;br /&gt;
* [http://www.sdl.me/ www.sdl.me]&lt;br /&gt;
* [http://dalili.soroush.me/ dalili.soroush.me]&lt;br /&gt;
* [http://www.plaincipher.com/ www.plaincipher.com]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=100980</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=100980"/>
				<updated>2011-01-19T12:30:53Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Author(s): &lt;br /&gt;
*[[User:Soroush Dalili|Soroush Dalili]]&lt;br /&gt;
*[[User:OWASP|OWASP]]&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..”, “file.asp ”, or “file.asp.”).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an executive file such as ASP with another extension in a folder which ends with an executive extension such as “.asp” (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should end with “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example:  “newfolder.asp::$Index_Allocation” creates “newfolder.asp” as a new directory).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”.&lt;br /&gt;
*In Windows Servers, it is possible to replace the files by using their short-name (8.3). (example: “web.config” can be replaced by uploading “web~1.con”)&lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
* [[Path Traversal]]&lt;br /&gt;
* [[Path Manipulation]]&lt;br /&gt;
* [[Relative Path Traversal]]&lt;br /&gt;
* [[Windows_::DATA_alternate_data_stream]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation Vulnerability]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Threat Agent]]  ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:External Threat Agent]]&lt;br /&gt;
* [[:Category:Internal Threat Agent]]&lt;br /&gt;
* [[:Category:Internet attacker]]&lt;br /&gt;
* [[:Category:Intranet attacker]]&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
* [[System Access]]&lt;br /&gt;
* [[Security Bypass]]&lt;br /&gt;
* [[Exposure of system information]]&lt;br /&gt;
* [[Exposure of sensitive information]]&lt;br /&gt;
* [[Client Side Threat]]&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*NTFS in WikiPedia http://en.wikipedia.org/wiki/NTFS&lt;br /&gt;
*NTFS Streams http://msdn.microsoft.com/en-us/library/ff469210(v=PROT.10).aspx&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 6.0 Security Best Practices http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx&lt;br /&gt;
*Securing Sites with Web Site Permissions http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx&lt;br /&gt;
*IIS 6.0 Operations Guide http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ms994921.aspx&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0 http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/&lt;br /&gt;
*IIS Security Checklist http://windows.stanford.edu/docs/IISsecchecklist.htm&lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*CVE-2009-4444 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444&lt;br /&gt;
*CVE-2009-4445 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445&lt;br /&gt;
*CVE-2009-1535 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
[[Category:File System]]&lt;br /&gt;
[[Category:Windows]]&lt;br /&gt;
[[Category:Unix]]&lt;br /&gt;
[[Category:Use of Dangerous API]]&lt;br /&gt;
[[Category:Vulnerability]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96288</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96288"/>
				<updated>2010-12-14T13:17:12Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an executive file such as ASP with another extension in a folder which ends with an executive extension such as “.asp” (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should end with “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example:  “newfolder.asp::$Index_Allocation” creates “newfolder.asp” as a new directory).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*NTFS in WikiPedia http://en.wikipedia.org/wiki/NTFS&lt;br /&gt;
*NTFS Streams http://msdn.microsoft.com/en-us/library/ff469210(v=PROT.10).aspx&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 6.0 Security Best Practices http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx&lt;br /&gt;
*Securing Sites with Web Site Permissions http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx&lt;br /&gt;
*IIS 6.0 Operations Guide http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ms994921.aspx&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0 http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/&lt;br /&gt;
*IIS Security Checklist http://windows.stanford.edu/docs/IISsecchecklist.htm&lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*CVE-2009-4444 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444&lt;br /&gt;
*CVE-2009-4445 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445&lt;br /&gt;
*CVE-2009-1535 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535&lt;br /&gt;
&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 12:38, 14 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96287</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96287"/>
				<updated>2010-12-14T13:13:49Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an executive file such as ASP with another extension in a folder which ends with an executive extension such as “.asp” (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should end with “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example:  “newfolder.asp::$Index_Allocation” creates “newfolder.asp” as a new directory).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*NTFS in WikiPedia http://en.wikipedia.org/wiki/NTFS&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 6.0 Security Best Practices http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx&lt;br /&gt;
*Securing Sites with Web Site Permissions http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx&lt;br /&gt;
*IIS 6.0 Operations Guide http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ms994921.aspx&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0 http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/&lt;br /&gt;
*IIS Security Checklist http://windows.stanford.edu/docs/IISsecchecklist.htm&lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*CVE-2009-4444 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444&lt;br /&gt;
*CVE-2009-4445 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445&lt;br /&gt;
*CVE-2009-1535 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535&lt;br /&gt;
&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 12:38, 14 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96286</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96286"/>
				<updated>2010-12-14T12:55:11Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an executive file such as ASP with another extension in a folder which ends with an executive extension such as “.asp” (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should end with “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example:  “newfolder.asp::$Index_Allocation” creates “newfolder.asp” as a new directory).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*Alternate Data Streams http://es.wikipedia.org/wiki/Alternate_Data_Streams&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 6.0 Security Best Practices http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx&lt;br /&gt;
*Securing Sites with Web Site Permissions http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx&lt;br /&gt;
*IIS 6.0 Operations Guide http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ms994921.aspx&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0 http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/&lt;br /&gt;
*IIS Security Checklist http://windows.stanford.edu/docs/IISsecchecklist.htm&lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*CVE-2009-4444 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444&lt;br /&gt;
*CVE-2009-4445 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445&lt;br /&gt;
*CVE-2009-1535 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535&lt;br /&gt;
&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 12:38, 14 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96285</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96285"/>
				<updated>2010-12-14T12:54:00Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an executive file such as ASP with another extension in a folder which ends with an executive extension such as “.asp” (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should end with “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example:  “ newfolder.asp::$Index_Allocation” creates “newfolder.asp” directory).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*Alternate Data Streams http://es.wikipedia.org/wiki/Alternate_Data_Streams&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 6.0 Security Best Practices http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx&lt;br /&gt;
*Securing Sites with Web Site Permissions http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx&lt;br /&gt;
*IIS 6.0 Operations Guide http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ms994921.aspx&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0 http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/&lt;br /&gt;
*IIS Security Checklist http://windows.stanford.edu/docs/IISsecchecklist.htm&lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*CVE-2009-4444 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444&lt;br /&gt;
*CVE-2009-4445 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445&lt;br /&gt;
*CVE-2009-1535 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535&lt;br /&gt;
&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 12:38, 14 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96284</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96284"/>
				<updated>2010-12-14T12:39:32Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an ASP file with another extension in a folder which has “.asp” in its name (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should include “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example: “ newfolder.asp::$Index_Allocation”).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*Alternate Data Streams http://es.wikipedia.org/wiki/Alternate_Data_Streams&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 6.0 Security Best Practices http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx&lt;br /&gt;
*Securing Sites with Web Site Permissions http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx&lt;br /&gt;
*IIS 6.0 Operations Guide http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ms994921.aspx&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0 http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/&lt;br /&gt;
*IIS Security Checklist http://windows.stanford.edu/docs/IISsecchecklist.htm&lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*CVE-2009-4444 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444&lt;br /&gt;
*CVE-2009-4445 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445&lt;br /&gt;
*CVE-2009-1535 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535&lt;br /&gt;
&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 12:38, 14 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96283</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96283"/>
				<updated>2010-12-14T12:38:35Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an ASP file with another extension in a folder which has “.asp” in its name (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should include “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example: “ newfolder.asp::$Index_Allocation”).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*Alternate Data Streams http://es.wikipedia.org/wiki/Alternate_Data_Streams&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 6.0 Security Best Practices http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx&lt;br /&gt;
*Securing Sites with Web Site Permissionshttp://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx&lt;br /&gt;
*IIS 6.0 Operations Guide http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures http://msdn.microsoft.com/en-us/library/ms994921.aspx&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0 http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/&lt;br /&gt;
*IIS Security Checklist http://windows.stanford.edu/docs/IISsecchecklist.htm&lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*CVE-2009-4444 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4444&lt;br /&gt;
*CVE-2009-4445 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4445&lt;br /&gt;
*CVE-2009-1535 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1535&lt;br /&gt;
&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 12:38, 14 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96282</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96282"/>
				<updated>2010-12-14T12:27:23Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an ASP file with another extension in a folder which has “.asp” in its name (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should include “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example: “ newfolder.asp::$Index_Allocation”).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
*Secure file upload in PHP web applications http://www.net-security.org/dl/articles/php-file-upload.pdf&lt;br /&gt;
*Image Upload XSS http://ha.ckers.org/blog/20070603/image-upload-xss/&lt;br /&gt;
*Code Execution Through Filenames in Uploads http://ha.ckers.org/blog/20070620/code-execution-through-filenames-in-uploads/&lt;br /&gt;
*Secure File Upload Check List With PHP http://hungred.com/useful-information/secure-file-upload-check-list-php/&lt;br /&gt;
*Potentially Dangerous File Types http://www.windowsitpro.com/Files/18/27072/Webtable_01.pdf&lt;br /&gt;
*NTFS - Glossary http://inform.pucp.edu.pe/~inf232/Ntfs/ntfs_doc_v0.5/help/glossary.html&lt;br /&gt;
*IIS 5.1 Directory Authentication Bypass http://soroush.secproject.com/downloadable/IIS5.1_Authentication_Bypass.pdf&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 12:27, 14 December 2010 (UTC)&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96281</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96281"/>
				<updated>2010-12-14T12:06:57Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“).&lt;br /&gt;
*A web-server may use the first extension after the first dot (“.”) in the file name or use a specific priority algorithm to detect the file extension. Therefore, protection can be bypassed by uploading a file with two extensions after the dot character. The first one is forbidden, and the second one is permitted (example: “file.php.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an ASP file with another extension in a folder which has “.asp” in its name (example: “folder.asp\file.txt”). Besides, it is possible to create a directory just by using a file uploader and ADS (Alternate Data Stream). In this method, filename should include “::$Index_Allocation” or “:$I30:$Index_Allocation” to create a directory instead of a file (example: “ newfolder.asp::$Index_Allocation”).&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 10:46, 14 December 2010 (UTC)&lt;br /&gt;
TBD &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96278</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=96278"/>
				<updated>2010-12-14T10:46:56Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Stub}} {{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“). &lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”).&lt;br /&gt;
*In case of using IIS6 (or prior versions), it might be possible to bypass this protection by putting an ASP file with another extension in a folder which has &amp;quot;.asp&amp;quot; in its name (example: “folder.asp\file.txt”)&lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
*IIS6/ASP &amp;amp; file upload for fun and profit http://blog.48bits.com/2010/09/28/iis6-asp-file-upload-for-fun-and-profit/&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 10:46, 14 December 2010 (UTC)&lt;br /&gt;
TBD &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Unrestricted_File_Upload&amp;diff=81684</id>
		<title>Talk:Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Unrestricted_File_Upload&amp;diff=81684"/>
				<updated>2010-04-18T19:17:23Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: Created page with 'Please update this page and correct my mistakes or add some new ideas. --~~~~'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Please update this page and correct my mistakes or add some new ideas. --[[User:Soroush Dalili|Soroush Dalili]] 19:17, 18 April 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81683</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81683"/>
				<updated>2010-04-18T19:15:55Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Stub}} {{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“). &lt;br /&gt;
*In case of using insecure IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”). &lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prevention Methods (Solutions to be more secure) ==&lt;br /&gt;
In order to make a Windows server more secure, it is very important to follow the Microsoft security best practices first. For this purpose, some of the useful links are:&lt;br /&gt;
*IIS 6.0 Security Best Practices[http://technet.microsoft.com/en-us/library/cc782762(WS.10).aspx]&lt;br /&gt;
*Securing Sites with Web Site Permissions[http://technet.microsoft.com/en-us/library/cc756133(WS.10).aspx]&lt;br /&gt;
*IIS 6.0 Operations Guide[http://technet.microsoft.com/en-us/library/cc785089(WS.10).aspx]&lt;br /&gt;
*Improving Web Application Security: Threats and Countermeasures[http://msdn.microsoft.com/en-us/library/ms994921.aspx]&lt;br /&gt;
*Understanding the Built-In User and Group Accounts in IIS 7.0[http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/]&lt;br /&gt;
*IIS Security Checklist[http://windows.stanford.edu/docs/IISsecchecklist.htm]&lt;br /&gt;
And some special recommendations for the developers and webmasters:&lt;br /&gt;
*Never accept a filename and its extension directly without having a white-list filter.&lt;br /&gt;
*It is necessary to have a list of only permitted extensions on the web application. And, file extension can be selected from the list. For instance, it can be a “select case” syntax (in case of having VBScript) to choose the file extension in regard to the real file extension.&lt;br /&gt;
*All the control characters  and Unicode ones should be removed from the filenames and their extensions without any exception. Also, the special characters such as “;”, “:”, “&amp;gt;”, “&amp;lt;”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be discarded as well. If it is applicable and there is no need to have Unicode characters, it is highly recommended to only accept Alpha-Numeric characters and only 1 dot as an input for the file name and the extension; in which the file name and also the extension should not be empty at all (regular expression: [a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}).&lt;br /&gt;
*Limit the filename length. For instance, the maximum length of the name of a file plus its extension should be less than 255 characters (without any directory) in an NTFS partition.&lt;br /&gt;
*It is recommended to use an algorithm to determine the filenames. For instance, a filename can be a MD5 hash of the name of file plus the date of the day.&lt;br /&gt;
*Uploaded directory should not have any “execute” permission.&lt;br /&gt;
*Limit the file size to a maximum value in order to prevent denial of service attacks (on file space or other web application’s functions such as the image resizer).&lt;br /&gt;
*Restrict small size files as they can lead to denial of service attacks. So, the minimum size of files should be considered.&lt;br /&gt;
*Use Cross Site Request Forgery protection methods.&lt;br /&gt;
*Prevent from overwriting a file in case of having the same hash for both.&lt;br /&gt;
*Use a virus scanner on the server (if it is applicable). Or, if the contents of files are not confidential, a free virus scanner website can be used. In this case, file should be stored with a random name and without any extension on the server first, and after the virus checking (uploading to a free virus scanner website and getting back the result), it can be renamed to its specific name and extension.&lt;br /&gt;
*Try to use POST method instead of PUT (or GET!)&lt;br /&gt;
*Log users’ activities. However, the logging mechanism should be secured against log forgery and code injection itself.&lt;br /&gt;
*In case of having compressed file extract functions, contents of the compressed file should be checked one by one as a new file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
--[[User:Soroush Dalili|Soroush Dalili]] 19:15, 18 April 2010 (UTC)&lt;br /&gt;
TBD &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81681</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81681"/>
				<updated>2010-04-18T19:07:17Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Stub}} {{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this vulnerability is high but the likelihood is low. So, the severity of this type of vulnerability is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This vulnerability can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“). &lt;br /&gt;
*In case of using insecure IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”). &lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
&lt;br /&gt;
TBD &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81680</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81680"/>
				<updated>2010-04-18T19:05:40Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Stub}} {{Template:Vulnerability}} &lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
&lt;br /&gt;
[[ASDR TOC Vulnerabilities|Vulnerabilities Table of Contents]] &lt;br /&gt;
&lt;br /&gt;
== Description  ==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. &lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored. &lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it. &lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Factors  ==&lt;br /&gt;
&lt;br /&gt;
*The impact of this attack is high but the likelihood is low. So, the severity of this type of attack is Medium. &lt;br /&gt;
*The website can be defaced. &lt;br /&gt;
*The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on. &lt;br /&gt;
*This attack can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]]. &lt;br /&gt;
*An attacker might be able to put a phishing page into the website. &lt;br /&gt;
*Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server. &lt;br /&gt;
*Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file. &lt;br /&gt;
*A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later. &lt;br /&gt;
*The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
== Examples  ==&lt;br /&gt;
&lt;br /&gt;
=== Attacks on application platform  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .jsp file into web tree - jsp code executed as web user &lt;br /&gt;
*Upload .gif to be resized - image library flaw exploited &lt;br /&gt;
*Upload huge files - file space denial of service &lt;br /&gt;
*Upload file using malicious path or name - overwrite critical file &lt;br /&gt;
*Upload file containing personal data - other users access it &lt;br /&gt;
*Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
=== Attacks on other systems  ===&lt;br /&gt;
&lt;br /&gt;
*Upload .exe file into web tree - victims download trojaned executable &lt;br /&gt;
*Upload virus infected file - victims' machines infected &lt;br /&gt;
*Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Weak Protection Methods and Methods of Bypassing  ==&lt;br /&gt;
&lt;br /&gt;
=== Using Black-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Some web applications still use only a black-list of extensions to prevent from uploading a malicious file. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by using some extensions which are executable on the server but are not mentioned in the list. (Example: “file.php5”, “file.shtml”, “file.asa”, or “file.cer”) &lt;br /&gt;
*Sometimes it is possible to bypass this protection by changing some letters of extension to the capital form (example: “file.aSp” or “file.PHp3”). &lt;br /&gt;
*Using trailing spaces and/or dots at the end of the filename can sometimes cause bypassing the protection. These spaces and/or dots at the end of the filename will be removed when the file wants to be saved on the hard disk automatically. The filename can be sent to the server by using a local proxy or using a simple script (example: “file.asp ... ... . . .. ..“). &lt;br /&gt;
*In case of using insecure IIS6 (or prior versions), it might be possible to bypass this protection by adding a semi-colon after the forbidden extension and before the permitted extension (example: “file.asp;.jpg”). &lt;br /&gt;
*This protection can be completely bypassed by using the most famous control character which is Null character (0x00) after the forbidden extension and before the permitted one. In this method, during the saving process all the strings after the Null character will be discarded. Putting a Null character in the filename can be simply done by using a local proxy or by using a script (example: “file.asp%00.jpg”). Besides, it would be perfect if the Null character is inserted directly by using the Hex view option of a local proxy such as Burpsuite or Webscarab in the right place (without using&amp;amp;nbsp;%). &lt;br /&gt;
*It is also possible to create a file with a forbidden extension by using NTFS alternate data stream (ADS). In this case, a “:” sign will be inserted after the forbidden extension and before the permitted one. As a result, an empty file with the forbidden extension will be created on the server (example: “file.asp:.jpg”). Attacker can try to edit this file later to execute his/her malicious codes. However, an empty file is not always good for an attacker. So, there is an invented method by the author of this paper in which an attacker can upload a non-empty shell file by using the ADS. In this method, a forbidden file can be uploaded by using this pattern: “file.asp::$data.”. &lt;br /&gt;
*Sometimes combination of the above can lead to bypassing the protections.&lt;br /&gt;
&lt;br /&gt;
=== Using White-List for Files’ Extensions  ===&lt;br /&gt;
&lt;br /&gt;
Many web applications use a white-list to accept the files’ extensions. Although using white-list is one of the recommendations, it is not enough on its own. Without having input validation, there is still a chance for an attacker to bypass the protections. &lt;br /&gt;
&lt;br /&gt;
*the 3rd, 4th, 5th, and 6th methods of last section apply here as well. &lt;br /&gt;
*The list of permitted extensions should be reviewed as it can contain malicious extension as well. For instance, in case of having “.shtml” in the list, the application can be vulnerable to SSI attacks.&lt;br /&gt;
&lt;br /&gt;
=== Using “Content-Type” from the Header  ===&lt;br /&gt;
&lt;br /&gt;
“Content-Type” entity in the header of the request indicates the Internet media type of the message content . Sometimes web applications use this parameter in order to recognize a file as a good one. For instance, they only accept the files with the “Content-Type” of “text/plain”. &lt;br /&gt;
&lt;br /&gt;
*It is possible to bypass this protection by changing this parameter in the request header by using a local proxy.&lt;br /&gt;
&lt;br /&gt;
=== Using a File Type Recogniser  ===&lt;br /&gt;
&lt;br /&gt;
Sometimes web applications intentionally or unintentionally use some functions (or APIs) to check the type of the file in order to do further process. For instance, in case of having image resizing, it is probable to have image type recogniser. &lt;br /&gt;
&lt;br /&gt;
*Sometimes the recognisers just read the few first characters (or header) of the files in order to check them. In this case, an attacker can insert the malicious code after some valid header. &lt;br /&gt;
*There are always some places in the structure of the files which are for the comments section and have no effect on the main file. And, an attacker can insert malicious codes in these points. &lt;br /&gt;
*Also, it is not impossible to think about a file modifier (for example an image resizer) which produces malicious codes itself in case of receiving special input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Attacks]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Attack 1]] &lt;br /&gt;
*[[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Vulnerabilities]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Vulnerability 1]] &lt;br /&gt;
*[[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Controls]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Control 1]] &lt;br /&gt;
*[[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related [[Technical Impacts]]  ==&lt;br /&gt;
&lt;br /&gt;
*[[Technical Impact 1]] &lt;br /&gt;
*[[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References  ==&lt;br /&gt;
&lt;br /&gt;
*Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/ &lt;br /&gt;
*Microsoft IIS ASP Multiple Extensions Security Bypass http://secunia.com/advisories/37831/&lt;br /&gt;
&lt;br /&gt;
TBD &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
[[Category:FIXME|add linksIn addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;&amp;lt;/nowiki&amp;gt;Availability VulnerabilityAuthorization VulnerabilityAuthentication VulnerabilityConcurrency VulnerabilityConfiguration VulnerabilityCryptographic VulnerabilityEncoding VulnerabilityError Handling VulnerabilityInput Validation VulnerabilityLogging and Auditing VulnerabilitySession Management Vulnerability]] [[Category:Error_Handling_Vulnerability]] [[Category:Vulnerability]] [[Category:OWASP_ASDR_Project]] [[Category:File_System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81679</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81679"/>
				<updated>2010-04-18T18:47:24Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Stub}}&lt;br /&gt;
{{Template:Vulnerability}}&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''&lt;br /&gt;
&lt;br /&gt;
[[ASDR_TOC_Vulnerabilities|Vulnerabilities Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step.&lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored.&lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it.&lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Risk Factors==&lt;br /&gt;
&lt;br /&gt;
* The impact of this attack is high but the likelihood is low. So, the severity of this type of attack is Medium.&lt;br /&gt;
* The website can be defaced.&lt;br /&gt;
* The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on.&lt;br /&gt;
* This attack can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]].&lt;br /&gt;
* An attacker might be able to put a phishing page into the website.&lt;br /&gt;
* Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server.&lt;br /&gt;
* Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file.&lt;br /&gt;
* A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later.&lt;br /&gt;
* The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Attacks on application platform===&lt;br /&gt;
* Upload .jsp file into web tree - jsp code executed as web user&lt;br /&gt;
* Upload .gif to be resized - image library flaw exploited&lt;br /&gt;
* Upload huge files - file space denial of service&lt;br /&gt;
* Upload file using malicious path or name - overwrite critical file&lt;br /&gt;
* Upload file containing personal data - other users access it&lt;br /&gt;
* Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
===Attacks on other systems===&lt;br /&gt;
* Upload .exe file into web tree - victims download trojaned executable&lt;br /&gt;
* Upload virus infected file - victims' machines infected&lt;br /&gt;
* Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Attacks]]==&lt;br /&gt;
&lt;br /&gt;
* [[Attack 1]]&lt;br /&gt;
* [[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
&lt;br /&gt;
* [[Vulnerability 1]]&lt;br /&gt;
* [[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Controls]]==&lt;br /&gt;
&lt;br /&gt;
* [[Control 1]]&lt;br /&gt;
* [[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Technical Impacts]]==&lt;br /&gt;
&lt;br /&gt;
* [[Technical Impact 1]]&lt;br /&gt;
* [[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
* Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
[[Category:FIXME|add links&lt;br /&gt;
&lt;br /&gt;
In addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;[[Category:Error Handling Vulnerability]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Availability Vulnerability&lt;br /&gt;
&lt;br /&gt;
Authorization Vulnerability&lt;br /&gt;
&lt;br /&gt;
Authentication Vulnerability&lt;br /&gt;
&lt;br /&gt;
Concurrency Vulnerability&lt;br /&gt;
&lt;br /&gt;
Configuration Vulnerability&lt;br /&gt;
&lt;br /&gt;
Cryptographic Vulnerability&lt;br /&gt;
&lt;br /&gt;
Encoding Vulnerability&lt;br /&gt;
&lt;br /&gt;
Error Handling Vulnerability&lt;br /&gt;
&lt;br /&gt;
Input Validation Vulnerability&lt;br /&gt;
&lt;br /&gt;
Logging and Auditing Vulnerability&lt;br /&gt;
&lt;br /&gt;
Session Management Vulnerability]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Vulnerability]]&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
[[Category:File System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81678</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81678"/>
				<updated>2010-04-18T18:45:21Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Stub}}&lt;br /&gt;
{{Template:Vulnerability}}&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''&lt;br /&gt;
&lt;br /&gt;
[[ASDR_TOC_Vulnerabilities|Vulnerabilities Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step.&lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored.&lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it.&lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Risk Factors==&lt;br /&gt;
&lt;br /&gt;
* The impact of this attack is high but the likelihood is low. So, the severity of this type of attack is Medium.&lt;br /&gt;
* The website can be defaced.&lt;br /&gt;
* The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on.&lt;br /&gt;
* This attack can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]].&lt;br /&gt;
* An attacker might be able to put a phishing page into the website.&lt;br /&gt;
* Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server.&lt;br /&gt;
* Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file.&lt;br /&gt;
* A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later.&lt;br /&gt;
* The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Attacks on application platform===&lt;br /&gt;
* Upload .jsp file into web tree - jsp code executed as web user&lt;br /&gt;
* Upload .gif to be resized - image library flaw exploited&lt;br /&gt;
* Upload huge files - file space denial of service&lt;br /&gt;
* Upload file using malicious path or name - overwrite critical file&lt;br /&gt;
* Upload file containing personal data - other users access it&lt;br /&gt;
* Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
===Attacks on other systems===&lt;br /&gt;
* Upload .exe file into web tree - victims download trojaned executable&lt;br /&gt;
* Upload virus infected file - victims' machines infected&lt;br /&gt;
* Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Attacks]]==&lt;br /&gt;
&lt;br /&gt;
* [[Attack 1]]&lt;br /&gt;
* [[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
&lt;br /&gt;
* [[Vulnerability 1]]&lt;br /&gt;
* [[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Controls]]==&lt;br /&gt;
&lt;br /&gt;
* [[Control 1]]&lt;br /&gt;
* [[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Technical Impacts]]==&lt;br /&gt;
&lt;br /&gt;
* [[Technical Impact 1]]&lt;br /&gt;
* [[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
* Improve File Uploaders’ Protections – Bypass Methods- Rev. 1.0 [http://soroush.secproject.com/blog/2010/03/improve-file-uploaders%e2%80%99-protections-rev-1-0/]&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
[[Category:FIXME|add links&lt;br /&gt;
&lt;br /&gt;
In addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;[[Category:Error Handling Vulnerability]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Availability Vulnerability&lt;br /&gt;
&lt;br /&gt;
Authorization Vulnerability&lt;br /&gt;
&lt;br /&gt;
Authentication Vulnerability&lt;br /&gt;
&lt;br /&gt;
Concurrency Vulnerability&lt;br /&gt;
&lt;br /&gt;
Configuration Vulnerability&lt;br /&gt;
&lt;br /&gt;
Cryptographic Vulnerability&lt;br /&gt;
&lt;br /&gt;
Encoding Vulnerability&lt;br /&gt;
&lt;br /&gt;
Error Handling Vulnerability&lt;br /&gt;
&lt;br /&gt;
Input Validation Vulnerability&lt;br /&gt;
&lt;br /&gt;
Logging and Auditing Vulnerability&lt;br /&gt;
&lt;br /&gt;
Session Management Vulnerability]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Vulnerability]]&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
[[Category:File System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81677</id>
		<title>Unrestricted File Upload</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unrestricted_File_Upload&amp;diff=81677"/>
				<updated>2010-04-18T18:39:18Z</updated>
		
		<summary type="html">&lt;p&gt;Soroush Dalili: /* Risk Factors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Stub}}&lt;br /&gt;
{{Template:Vulnerability}}&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''&lt;br /&gt;
&lt;br /&gt;
[[ASDR_TOC_Vulnerabilities|Vulnerabilities Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step.&lt;br /&gt;
&lt;br /&gt;
The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement. It depends on what the application does with the uploaded file, including where it is stored.&lt;br /&gt;
&lt;br /&gt;
There are really two different classes of problems here. The first is with the file metadata, like the path and filename. These are generally provided by the transport, such as HTTP multipart encoding. This data may trick the application into overwriting a critical file or storing the file in a bad location. You must validate the metadata extremely carefully before using it.&lt;br /&gt;
&lt;br /&gt;
The other class of problem is with the file content. The range of problems here depends entirely on what the file is used for. See the examples below for some ideas about how files might be misused. To protect against this type of attack, you should analyze everything your application does with files and think carefully about what processing and interpreters are involved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Risk Factors==&lt;br /&gt;
&lt;br /&gt;
* The impact of this attack is high but the likelihood is low. So, the severity of this type of attack is Medium.&lt;br /&gt;
* The website can be defaced.&lt;br /&gt;
* The web server can be compromised by uploading and executing a web-shell which can: run a command, browse the system files, browse the local resources, attack to other servers, and exploit the local vulnerabilities, and so on.&lt;br /&gt;
* This attack can make the website vulnerable to some other types of attacks such as [[Cross-site Scripting (XSS)|XSS]].&lt;br /&gt;
* An attacker might be able to put a phishing page into the website.&lt;br /&gt;
* Local file inclusion vulnerabilities can be exploited by uploading a malicious file into the server.&lt;br /&gt;
* Local vulnerabilities of real-time monitoring tools such as an antivirus can be exploited by uploading a harmful file.&lt;br /&gt;
* A malicious file can be uploaded on the server in order to have a chance to be executed by administrator or webmaster later.&lt;br /&gt;
* The web server might be used as a warez server by a bad guy in order to be host of malwares, illegal software, steganographic objects, and so on.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Attacks on application platform===&lt;br /&gt;
* Upload .jsp file into web tree - jsp code executed as web user&lt;br /&gt;
* Upload .gif to be resized - image library flaw exploited&lt;br /&gt;
* Upload huge files - file space denial of service&lt;br /&gt;
* Upload file using malicious path or name - overwrite critical file&lt;br /&gt;
* Upload file containing personal data - other users access it&lt;br /&gt;
* Upload file containing &amp;quot;tags&amp;quot; - tags get executed as part of being &amp;quot;included&amp;quot; in a web page&lt;br /&gt;
&lt;br /&gt;
===Attacks on other systems===&lt;br /&gt;
* Upload .exe file into web tree - victims download trojaned executable&lt;br /&gt;
* Upload virus infected file - victims' machines infected&lt;br /&gt;
* Upload .html file containing script - victim experiences [[Cross-site Scripting (XSS)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Attacks]]==&lt;br /&gt;
&lt;br /&gt;
* [[Attack 1]]&lt;br /&gt;
* [[Attack 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
&lt;br /&gt;
* [[Vulnerability 1]]&lt;br /&gt;
* [[Vulnerabiltiy 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Controls]]==&lt;br /&gt;
&lt;br /&gt;
* [[Control 1]]&lt;br /&gt;
* [[Control 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related [[Technical Impacts]]==&lt;br /&gt;
&lt;br /&gt;
* [[Technical Impact 1]]&lt;br /&gt;
* [[Technical Impact 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
[[Category:FIXME|add links&lt;br /&gt;
&lt;br /&gt;
In addition, one should classify vulnerability based on the following subcategories: Ex:&amp;lt;nowiki&amp;gt;[[Category:Error Handling Vulnerability]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Availability Vulnerability&lt;br /&gt;
&lt;br /&gt;
Authorization Vulnerability&lt;br /&gt;
&lt;br /&gt;
Authentication Vulnerability&lt;br /&gt;
&lt;br /&gt;
Concurrency Vulnerability&lt;br /&gt;
&lt;br /&gt;
Configuration Vulnerability&lt;br /&gt;
&lt;br /&gt;
Cryptographic Vulnerability&lt;br /&gt;
&lt;br /&gt;
Encoding Vulnerability&lt;br /&gt;
&lt;br /&gt;
Error Handling Vulnerability&lt;br /&gt;
&lt;br /&gt;
Input Validation Vulnerability&lt;br /&gt;
&lt;br /&gt;
Logging and Auditing Vulnerability&lt;br /&gt;
&lt;br /&gt;
Session Management Vulnerability]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:Vulnerability]]&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
[[Category:File System]]&lt;/div&gt;</summary>
		<author><name>Soroush Dalili</name></author>	</entry>

	</feed>