<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mohsin Sumar &#187; how is chmod 777 insecure</title>
	<atom:link href="http://www.mohsinsumar.com/tag/how-is-chmod-777-insecure/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mohsinsumar.com</link>
	<description>Zend Certified Engineer, PHP Professional, Designer &#38; Web Developer</description>
	<lastBuildDate>Sun, 13 Nov 2011 19:35:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Securing PHP application from malicious scripts</title>
		<link>http://www.mohsinsumar.com/php/securing-php-application-from-malicious-scripts/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=securing-php-application-from-malicious-scripts</link>
		<comments>http://www.mohsinsumar.com/php/securing-php-application-from-malicious-scripts/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 22:35:48 +0000</pubDate>
		<dc:creator>Mohsin Sumar</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[.htaccess disable directory listing]]></category>
		<category><![CDATA[how is chmod 777 insecure]]></category>
		<category><![CDATA[options all -indexes]]></category>
		<category><![CDATA[php application security]]></category>
		<category><![CDATA[php upload security]]></category>
		<category><![CDATA[prevent malicious code execution]]></category>
		<category><![CDATA[Secure File Uploads]]></category>

		<guid isPermaLink="false">http://www.mohsinsumar.com/?p=91</guid>
		<description><![CDATA[If you've stumbled across this post, then you've recently become a victim of the most famous way of uploading a malicious script to a website - PHP file uploads. Read through this article to understand the problem and an easy solution to add an extra layer of security to your web application. ]]></description>
			<content:encoded><![CDATA[<p>If you've stumbled across this post, then you've recently become a victim of the most famous way of uploading a malicious script to a website - PHP file uploads.</p>
<p>Many websites and web applications that are developed using PHP &amp; MySQL allow users to upload files, photos and documents to the server. Normally, the upload script receives the files and moves (or writes) it to a directory (folder) with write permissions. If you are on Linux, then this would mean that your folder CHMOD value is 0777.</p>
<p><span style="text-decoration: underline;"><strong>The Problem</strong></span><br />
The changing of CHMOD value to 0777 practically allows anyone in the WORLD to write to your folder and is therefore not recommended. However, many a times we are left with no option but to do so - depending on the servers' environment.</p>
<p><span style="text-decoration: underline;"><strong>How can this be a problem?</strong></span><br />
This allows attackers to upload upload a malicious PHP script to your directory, which they will then execute by accessing it. This script could either be a mass-mailing script or a malicious script to gain access to your account (or web server).</p>
<p><span style="text-decoration: underline;"><strong>The Solution</strong></span><br />
It is said that prevention is better than cure - and therefore, it is important to prevent these scripts from being executed by the server. This can very simply be done by adding a few lines of code to your .htaccess file. If your directory is supposed to hold photo files only, then the following code is recommended to prevent scripts from being executed.</p>
<p>It is also important to disable directory listing on these folders.</p>
<pre><span style="color: #800000;"># Disable Directory Listing
Options All -Indexes</span>

<span style="color: #800000;"># Allow access to these file extensions only
</span><span style="color: #800000;">&lt;FilesMatch "\.(htaccess|htpasswd|ini|php|cgi|pl|phps|sh)$"&gt;
 Order Allow,Deny
 Deny from all
&lt;/FilesMatch&gt;</span><span style="color: #800000;">
</span></pre>
<p>The above will add an extra layer of security to your web application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohsinsumar.com/php/securing-php-application-from-malicious-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

