<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: CGI Do's and Don'ts</title>
	<atom:link href="http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/feed/" rel="self" type="application/rss+xml" />
	<link>http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/</link>
	<description>News and Updates on the Community.</description>
	<pubDate>Wed, 20 Aug 2008 21:10:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Simon Westcott</title>
		<link>http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/#comment-3709</link>
		<dc:creator>Simon Westcott</dc:creator>
		<pubDate>Wed, 21 May 2008 17:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://community.plus.net/?p=12465#comment-3709</guid>
		<description>Good stuff Ben.  The only problem with intval() is that it does more than validate input, it also filters input.  This can lead to expected and undesired results.  For example,

intval('123abc'); // 123
intval(0123);     // 83

It's safer to reject invalid input as filtering can lead to further security holes.  One method I've seen more than once for preventing directory traversal is to removed '..' from file paths,

$safe_filename = str_replace('..', '.', $_FILES['filename']);

This filter is OK when $_FILE['filename'] is '../../../../etc/passwd', however it can be exploited with '.../.../.../.../etc/passwd'.</description>
		<content:encoded><![CDATA[<p>Good stuff Ben.  The only problem with intval() is that it does more than validate input, it also filters input.  This can lead to expected and undesired results.  For example,</p>
<p>intval('123abc'); // 123<br />
intval(0123);     // 83</p>
<p>It's safer to reject invalid input as filtering can lead to further security holes.  One method I've seen more than once for preventing directory traversal is to removed '..' from file paths,</p>
<p>$safe_filename = str_replace('..', '.', $_FILES['filename']);</p>
<p>This filter is OK when $_FILE['filename'] is '../../../../etc/passwd', however it can be exploited with '.../.../.../.../etc/passwd'.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A.</title>
		<link>http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/#comment-3686</link>
		<dc:creator>A.</dc:creator>
		<pubDate>Wed, 21 May 2008 06:12:55 +0000</pubDate>
		<guid isPermaLink="false">http://community.plus.net/?p=12465#comment-3686</guid>
		<description>Never forget the mysql_real_escape_string() function in PHP. It will prevent every type of SQL injection attack for all value types. For file uploads is_uploaded_file() is a must, otherwise you risk local file inclusion exploits.

&#62; profile.php?id=1
Many search engines including Google will refuse to crawl pages with the "id" query string in them. profile.php?user=1 seems ideal.</description>
		<content:encoded><![CDATA[<p>Never forget the mysql_real_escape_string() function in PHP. It will prevent every type of SQL injection attack for all value types. For file uploads is_uploaded_file() is a must, otherwise you risk local file inclusion exploits.</p>
<p>&gt; profile.php?id=1<br />
Many search engines including Google will refuse to crawl pages with the "id" query string in them. profile.php?user=1 seems ideal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/#comment-3679</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Tue, 20 May 2008 21:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://community.plus.net/?p=12465#comment-3679</guid>
		<description>Loving that blog Ben.

Nice one. Thanks.</description>
		<content:encoded><![CDATA[<p>Loving that blog Ben.</p>
<p>Nice one. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Mitchell</title>
		<link>http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/#comment-3668</link>
		<dc:creator>James Mitchell</dc:creator>
		<pubDate>Tue, 20 May 2008 16:18:15 +0000</pubDate>
		<guid isPermaLink="false">http://community.plus.net/?p=12465#comment-3668</guid>
		<description>There's a huge amount of SQL fast-fluxing injection happening at the moment across the net.  The Asprox botnet is quickly spreading around.

I know of several SQL based forums that have been compromised in the last couple of days.

There's more info on Asprox :

http://blogs.zdnet.com/security/?p=1122</description>
		<content:encoded><![CDATA[<p>There's a huge amount of SQL fast-fluxing injection happening at the moment across the net.  The Asprox botnet is quickly spreading around.</p>
<p>I know of several SQL based forums that have been compromised in the last couple of days.</p>
<p>There's more info on Asprox :</p>
<p><a href="http://blogs.zdnet.com/security/?p=1122" rel="nofollow">http://blogs.zdnet.com/security/?p=1122</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Brown</title>
		<link>http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/#comment-3658</link>
		<dc:creator>Ben Brown</dc:creator>
		<pubDate>Tue, 20 May 2008 13:26:01 +0000</pubDate>
		<guid isPermaLink="false">http://community.plus.net/?p=12465#comment-3658</guid>
		<description>In retrospect prehaps "Good" and "Bad" weren't the right words to use. I agree that escaping input data is good, however if you are using integers then no escaping is required. Whether the value is valid should be down to the rest of the script but the risk of sql injection etc is not possible with an integer (as returned by "intval" in my example), and this document is intended as a brief starting point, and not a comprehensive design manifesto.</description>
		<content:encoded><![CDATA[<p>In retrospect prehaps "Good" and "Bad" weren't the right words to use. I agree that escaping input data is good, however if you are using integers then no escaping is required. Whether the value is valid should be down to the rest of the script but the risk of sql injection etc is not possible with an integer (as returned by "intval" in my example), and this document is intended as a brief starting point, and not a comprehensive design manifesto.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://community.plus.net/blog/2008/05/20/cgi-dos-and-donts/#comment-3655</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Tue, 20 May 2008 12:26:50 +0000</pubDate>
		<guid isPermaLink="false">http://community.plus.net/?p=12465#comment-3655</guid>
		<description>I object to the following assertion:

# bad
profile.php?user=Ben

# good
profile.php?id=1

In my eyes your "Good" option is no better than your "Bad" option. What you should be doing is:
- properly escaping input data (Yes this is *easier to check* if you're expecting an INT rather than a string type - but expecting an INT is *no more secure* than expecting a string)
- Once you've ascertained that the input is "safe" you should check that it's valid (Is it a real user ID belonging to a real user)
- Check that the user requesting the information has the authority to access the data (ie - should I be able to see user ID 1's profile?)</description>
		<content:encoded><![CDATA[<p>I object to the following assertion:</p>
<p># bad<br />
profile.php?user=Ben</p>
<p># good<br />
profile.php?id=1</p>
<p>In my eyes your "Good" option is no better than your "Bad" option. What you should be doing is:<br />
- properly escaping input data (Yes this is *easier to check* if you're expecting an INT rather than a string type - but expecting an INT is *no more secure* than expecting a string)<br />
- Once you've ascertained that the input is "safe" you should check that it's valid (Is it a real user ID belonging to a real user)<br />
- Check that the user requesting the information has the authority to access the data (ie - should I be able to see user ID 1's profile?)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
