<?xml version='1.0' encoding='utf-8' ?>
<feed xmlns='http://www.w3.org/2005/Atom'>
  <title type='text'>WPoch</title>
  <generator uri='http://effectif.com/nesta'>Nesta</generator>
  <id>tag:www.wpoch.com.ar,2009:/</id>
  <link href='http://www.wpoch.com.ar/articles.xml' rel='self' />
  <link href='http://www.wpoch.com.ar' rel='alternate' />
  <subtitle type='text'>Code is the king</subtitle>
  <updated>2011-11-16T00:00:00+00:00</updated>
  <author>
    <name>Walter Poch</name>
    <uri>http://wpoch.com.ar</uri>
    <email>me@wpoch.com.ar</email>
  </author>
  <entry>
    <title></title>
    <link href='http://www.wpoch.com.ar/security-considerations-file-upload' rel='alternate' type='text/html' />
    <id>tag:www.wpoch.com.ar,2011-11-16:/security-considerations-file-upload</id>
    <content type='html'>
            &lt;h1&gt;Security Considerations On File Uploads&lt;/h1&gt;
            
            &lt;p&gt;After researching a little bit around the web I came out with these kind of checklist whenever you may want to add File Upload to your project:&lt;/p&gt;
            
            &lt;ul&gt;
            &lt;li&gt;Use POST instead of PUT method.&lt;/li&gt;
            &lt;li&gt;First store your files on disk before upload to a database.&lt;/li&gt;
            &lt;li&gt;Try to store these file on a folder different from the website tree and the system partition, and also restrict the execution right to that folder.&lt;/li&gt;
            &lt;li&gt;If you have to store the files under the website tree, make sure they are on a different folder that your code.&lt;/li&gt;
            &lt;li&gt;Scan the uploaded files for viruses.&lt;/li&gt;
            &lt;li&gt;Validate the length of the request and restrict the file sizes, in order to skip potentially DOS attacks. On .Net always set the &lt;em&gt;maxRequestLength&lt;/em&gt; and &lt;em&gt;executionTimeout&lt;/em&gt; attributes of the &lt;httpruntime&gt; element to avoid attacks (By default, this is set to 4096 kilobytes (KB)). Also limit the minimum size of the files.&lt;/li&gt;
            &lt;li&gt;Use your own naming convention to store the files, that doesn't use the users file name.&lt;/li&gt;
            &lt;li&gt;Validate the file type, extension, and mimetype[1] using whitelists. (check for double extensions), on client AND server.&lt;/li&gt;
            &lt;li&gt;If you could, use an strict regular expression like: &quot;[a-zA-Z0-9]{1,200}.[a-zA-Z0-9]{1,10}&quot; to validate file names.&lt;/li&gt;
            &lt;li&gt;Don't overwrite existing files.&lt;/li&gt;
            &lt;li&gt;Use Cross Site Request Forgery protection methods.&lt;/li&gt;
            &lt;li&gt;Log user activity.&lt;/li&gt;
            &lt;/ul&gt;
            
            
            &lt;h2&gt;Must read&lt;/h2&gt;
            
            &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;https://www.owasp.org/index.php/Unrestricted_File_Upload&quot;&gt;https://www.owasp.org/index.php/Unrestricted_File_Upload&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
            
            
            &lt;h2&gt;Other Resources&lt;/h2&gt;
            
            &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;http://joginipally.blogspot.com/2008/11/security-considerations-for-file-upload.html&quot;&gt;http://joginipally.blogspot.com/2008/11/security-considerations-for-file-upload.html&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;http://www.acunetix.com/websitesecurity/upload-forms-threat.htm&quot;&gt;http://www.acunetix.com/websitesecurity/upload-forms-threat.htm&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;http://blogs.msdn.com/b/ace_team/archive/2007/09/19/asp-net-file-upload-how-to-prevent-network-clogging.aspx&quot;&gt;http://blogs.msdn.com/b/ace_team/archive/2007/09/19/asp-net-file-upload-how-to-prevent-network-clogging.aspx&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa479405.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/aa479405.aspx&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;[1] &lt;a href=&quot;http://www.webmaster-toolkit.com/mime-types.shtml&quot;&gt;http://www.webmaster-toolkit.com/mime-types.shtml&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          </content>
    <published>2011-11-16T00:00:00+00:00</published>
    <updated>2011-11-16T00:00:00+00:00</updated>
  </entry>
</feed>

