<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Snippets of defense Pt.III</title>
	<atom:link href="http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/</link>
	<description>Information Security Think Tank</description>
	<lastBuildDate>Sat, 02 Feb 2013 17:50:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
	<item>
		<title>By: Content Injection: Hack the Hacker &#124; GNUCITIZEN</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-128212</link>
		<dc:creator>Content Injection: Hack the Hacker &#124; GNUCITIZEN</dc:creator>
		<pubDate>Mon, 08 Mar 2010 12:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-128212</guid>
		<description>[...] blocking etc). Check out some of Mario&#8217;s code snippets of defense for the idea: here, here, here, and [...]</description>
		<content:encoded><![CDATA[<p>[...] blocking etc). Check out some of Mario&#8217;s code snippets of defense for the idea: here, here, here, and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Content Injection: Hack the Hacker &#187; Inking's Security Blog</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-118630</link>
		<dc:creator>Content Injection: Hack the Hacker &#187; Inking's Security Blog</dc:creator>
		<pubDate>Fri, 11 Apr 2008 14:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-118630</guid>
		<description>[...] blocking etc). Check out some of Marioâ€™s code snippets of defense for the idea: here, here, here, and [...]</description>
		<content:encoded><![CDATA[<p>[...] blocking etc). Check out some of Marioâ€™s code snippets of defense for the idea: here, here, here, and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raaka!</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-61861</link>
		<dc:creator>Raaka!</dc:creator>
		<pubDate>Fri, 26 Oct 2007 19:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-61861</guid>
		<description>LOL =))

where is reZen now :p

thanks for the code</description>
		<content:encoded><![CDATA[<p>LOL =))</p>
<p>where is reZen now :p</p>
<p>thanks for the code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Heiderich</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-60626</link>
		<dc:creator>Mario Heiderich</dc:creator>
		<pubDate>Mon, 22 Oct 2007 21:13:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-60626</guid>
		<description>Hey ReZEN - click that, junior!
http://tinyurl.com/2h3ps6

You should have read my post ;)</description>
		<content:encoded><![CDATA[<p>Hey ReZEN &#8211; click that, junior!<br />
<a href="http://tinyurl.com/2h3ps6" rel="nofollow">http://tinyurl.com/2h3ps6</a></p>
<p>You should have read my post ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pdp</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-60584</link>
		<dc:creator>pdp</dc:creator>
		<pubDate>Mon, 22 Oct 2007 16:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-60584</guid>
		<description>ReZEN, if you don&#039;t like it, please don&#039;t read it. All .mario did is to show a kind of code which may fit into some scenarios. We all know that there are no bulletproof solutions.</description>
		<content:encoded><![CDATA[<p>ReZEN, if you don&#8217;t like it, please don&#8217;t read it. All .mario did is to show a kind of code which may fit into some scenarios. We all know that there are no bulletproof solutions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ReZEN</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-60571</link>
		<dc:creator>ReZEN</dc:creator>
		<pubDate>Mon, 22 Oct 2007 14:57:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-60571</guid>
		<description>.mario:

Wow this is hilarious.  Kids and their games.  Next time you want to post pure crap just through up a link to rotten.com or ogrish or something and quit wasting everyones time with your absolute shit code.  Have you done NO research on this subject at all?  And if you had THIS IS WHAT YOU CAME UP WITH?</description>
		<content:encoded><![CDATA[<p>.mario:</p>
<p>Wow this is hilarious.  Kids and their games.  Next time you want to post pure crap just through up a link to rotten.com or ogrish or something and quit wasting everyones time with your absolute shit code.  Have you done NO research on this subject at all?  And if you had THIS IS WHAT YOU CAME UP WITH?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wade</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-60559</link>
		<dc:creator>Wade</dc:creator>
		<pubDate>Mon, 22 Oct 2007 14:35:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-60559</guid>
		<description>mario. sorry for rehashing this again, but I don&#039;t want to see anyone using this code thinking that it&#039;s going to save them against XSS. As previously mentioned by kuza55 and digi7al64, $_GET and $_POST values (which would typically used by developers) are not being affected by the sanitation script. For this to be more &quot;copy and paste&quot; friendly,  you might want to initialize the whole thing by using:

&lt;pre&gt;&lt;code&gt;$_GET = filter($_GET);
$_POST = filter($_POST);
$_COOKIE = filter($_COOKIE);&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>mario. sorry for rehashing this again, but I don&#8217;t want to see anyone using this code thinking that it&#8217;s going to save them against XSS. As previously mentioned by kuza55 and digi7al64, $_GET and $_POST values (which would typically used by developers) are not being affected by the sanitation script. For this to be more &#8220;copy and paste&#8221; friendly,  you might want to initialize the whole thing by using:</p>
<pre><code>$_GET = filter($_GET);
$_POST = filter($_POST);
$_COOKIE = filter($_COOKIE);</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: pdp</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-60076</link>
		<dc:creator>pdp</dc:creator>
		<pubDate>Sun, 21 Oct 2007 06:50:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-60076</guid>
		<description>digi7al64, wordpress will try to prevent you from posting anything that looks like HTML. Just make sure that all your &lt; are replaced &lt; and &gt; is replaced with &gt; :) cheers</description>
		<content:encoded><![CDATA[<p>digi7al64, wordpress will try to prevent you from posting anything that looks like HTML. Just make sure that all your &lt; are replaced &amp;lt; and &gt; is replaced with &amp;gt; :) cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: digi7al64</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-60045</link>
		<dc:creator>digi7al64</dc:creator>
		<pubDate>Sun, 21 Oct 2007 03:29:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-60045</guid>
		<description>it seems this blog removed half of my code. therefore don&#039;t worry about approving my post, please delete it. i don&#039;t intend to repost</description>
		<content:encoded><![CDATA[<p>it seems this blog removed half of my code. therefore don&#8217;t worry about approving my post, please delete it. i don&#8217;t intend to repost</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: digi7al64</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-60043</link>
		<dc:creator>digi7al64</dc:creator>
		<pubDate>Sun, 21 Oct 2007 03:26:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-60043</guid>
		<description>I been using a similar method to the one you presented here for a while now but there are a few different things in mine that perhaps could be blended into yours to make it safer.

I.E

&lt;blockquote&gt;&gt; I use the iconv function to force an encoding set on the supplied data
&gt; I loop through each $_POST and $_GET and set the values that way (as kuza55 suggested [cookie not included as this is only an idea to get you going])&lt;/blockquote&gt;

Finally, there is a small bug in my code (intentional for this post) so post back if you can find how to make it throw an error, should be easy :)

oh and as a final thought, generally you might want to trim the string straight up to a fixed length you know you can handle it with whatever you want to do.

&lt;pre&gt;&lt;code&gt;$value){
			$_POST[$name] = santize($value);
		}
	}
	
	// Clean any supplied get values
	if(isset($_GET)) {
		foreach($_GET as $name =&gt; $value){
			$_GET[$name] = santize($value);
		}
	}
?&gt;&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I been using a similar method to the one you presented here for a while now but there are a few different things in mine that perhaps could be blended into yours to make it safer.</p>
<p>I.E</p>
<blockquote><p>&gt; I use the iconv function to force an encoding set on the supplied data<br />
&gt; I loop through each $_POST and $_GET and set the values that way (as kuza55 suggested [cookie not included as this is only an idea to get you going])</p></blockquote>
<p>Finally, there is a small bug in my code (intentional for this post) so post back if you can find how to make it throw an error, should be easy :)</p>
<p>oh and as a final thought, generally you might want to trim the string straight up to a fixed length you know you can handle it with whatever you want to do.</p>
<pre><code>$value){
			$_POST[$name] = santize($value);
		}
	}
	
	// Clean any supplied get values
	if(isset($_GET)) {
		foreach($_GET as $name =&gt; $value){
			$_GET[$name] = santize($value);
		}
	}
?&gt;</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-59968</link>
		<dc:creator>David</dc:creator>
		<pubDate>Sat, 20 Oct 2007 22:05:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-59968</guid>
		<description>Not really recursive (function doesn&#039;t call itself, just goes 1 level into an array). Seems you can reduce the whole thing to 1 function by using actual recursion:

&lt;pre&gt;&lt;code&gt; $var) {
				$safe_html[$key]=recurs_escape_html($var);
			}
		} else {
			return htmlentities($data, ENT_QUOTES, &#039;ISO-8859-1&#039;);
		}
		return $safe_html;
	}
?&gt;&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Not really recursive (function doesn&#8217;t call itself, just goes 1 level into an array). Seems you can reduce the whole thing to 1 function by using actual recursion:</p>
<pre><code> $var) {
				$safe_html[$key]=recurs_escape_html($var);
			}
		} else {
			return htmlentities($data, ENT_QUOTES, 'ISO-8859-1');
		}
		return $safe_html;
	}
?&gt;</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: .mario</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-59840</link>
		<dc:creator>.mario</dc:creator>
		<pubDate>Sat, 20 Oct 2007 12:00:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-59840</guid>
		<description>Hi!

Thanks for the comments. 

Kuza55 you are right - $_REQUEST _can_ be problematic in some setups but this is example is more to show on how you can build an easy to extend first solution to cope with global input filtering - which I really rarely come to see during work. It of course no &#039;use it and be happy forever&#039; solution but a snippet to point into a certain direction.

Greetings,
.mario</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>Thanks for the comments. </p>
<p>Kuza55 you are right &#8211; $_REQUEST _can_ be problematic in some setups but this is example is more to show on how you can build an easy to extend first solution to cope with global input filtering &#8211; which I really rarely come to see during work. It of course no &#8216;use it and be happy forever&#8217; solution but a snippet to point into a certain direction.</p>
<p>Greetings,<br />
.mario</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kuza55</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-59839</link>
		<dc:creator>kuza55</dc:creator>
		<pubDate>Sat, 20 Oct 2007 11:46:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-59839</guid>
		<description>You&#039;re missing the end of a line:

&lt;pre&gt;&lt;code&gt;return strip_tags(str_replace($search, $replace, $string)&lt;/code&gt;&lt;/pre&gt;

should be

&lt;pre&gt;&lt;code&gt;return strip_tags(str_replace($search, $replace, $string));&lt;/code&gt;&lt;/pre&gt;

Furthermore editing $_REQUEST does not change the values in $_GET, $_POST, $_COOKIE, etc. SO you would need to do this to every array you want to sanitize, and then reconstruct $_REQUEST from your already filtered initial arrays.

This is purely IMO, but $_REQUEST seems like a bad idea, since you don&#039;t know where the stuff your working with came from, especially considering it relies on the variables_order directive.

Anyway, this seems pretty much identical to magic_quotes so I&#039;m not going to bother criticising it since the arguments for/against magic_quotes have been rehashed enough times already.</description>
		<content:encoded><![CDATA[<p>You&#8217;re missing the end of a line:</p>
<pre><code>return strip_tags(str_replace($search, $replace, $string)</code></pre>
<p>should be</p>
<pre><code>return strip_tags(str_replace($search, $replace, $string));</code></pre>
<p>Furthermore editing $_REQUEST does not change the values in $_GET, $_POST, $_COOKIE, etc. SO you would need to do this to every array you want to sanitize, and then reconstruct $_REQUEST from your already filtered initial arrays.</p>
<p>This is purely IMO, but $_REQUEST seems like a bad idea, since you don&#8217;t know where the stuff your working with came from, especially considering it relies on the variables_order directive.</p>
<p>Anyway, this seems pretty much identical to magic_quotes so I&#8217;m not going to bother criticising it since the arguments for/against magic_quotes have been rehashed enough times already.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sirw2p</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-59829</link>
		<dc:creator>Sirw2p</dc:creator>
		<pubDate>Sat, 20 Oct 2007 10:08:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-59829</guid>
		<description>Good code, but there are easier ways to filter and prevent xss attacks.</description>
		<content:encoded><![CDATA[<p>Good code, but there are easier ways to filter and prevent xss attacks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NIX</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/comment-page-1/#comment-59815</link>
		<dc:creator>NIX</dc:creator>
		<pubDate>Sat, 20 Oct 2007 09:26:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii#comment-59815</guid>
		<description>thats a good one ;)
thanks</description>
		<content:encoded><![CDATA[<p>thats a good one ;)<br />
thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
