<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: MySQL input/output validation</title>
	<atom:link href="http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/</link>
	<description>anything about Web Security</description>
	<lastBuildDate>Mon, 10 Aug 2009 13:49:41 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Reiners</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-27</link>
		<dc:creator>Reiners</dc:creator>
		<pubDate>Sat, 07 Jun 2008 13:36:06 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-27</guid>
		<description>hey raz0r,
there has been some discussion on is_numeric() on sla.ckers &lt;a href=&quot;http://sla.ckers.org/forum/read.php?16,13507,14797#msg-14782&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. although we found no example how to exploit it, I agreed with Mordred that hex numbers should not be accepted if you expect integers only (which is a common case for SQL input).

greetings,
Reiners</description>
		<content:encoded><![CDATA[<p>hey raz0r,<br />
there has been some discussion on is_numeric() on sla.ckers <a href="http://sla.ckers.org/forum/read.php?16,13507,14797#msg-14782" rel="nofollow">here</a>. although we found no example how to exploit it, I agreed with Mordred that hex numbers should not be accepted if you expect integers only (which is a common case for SQL input).</p>
<p>greetings,<br />
Reiners</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raz0rname</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-26</link>
		<dc:creator>raz0rname</dc:creator>
		<pubDate>Sat, 07 Jun 2008 13:14:29 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-26</guid>
		<description>Nice function, but why don&#039;t you use is_numeric() instead of ctype_digit()? is_numeric() is commonly used in such cases. I have written a function that checks user input, have a look if you are interested (the post is in Russian, but i guess we both speak PHP :)
http://raz0r.name/releases/funkciya-dlya-obrabotki-vxodyashhix-dannyx/</description>
		<content:encoded><![CDATA[<p>Nice function, but why don&#8217;t you use is_numeric() instead of ctype_digit()? is_numeric() is commonly used in such cases. I have written a function that checks user input, have a look if you are interested (the post is in Russian, but i guess we both speak PHP <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://raz0r.name/releases/funkciya-dlya-obrabotki-vxodyashhix-dannyx/" rel="nofollow">http://raz0r.name/releases/funkciya-dlya-obrabotki-vxodyashhix-dannyx/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reiners</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-8</link>
		<dc:creator>Reiners</dc:creator>
		<pubDate>Tue, 13 Nov 2007 22:52:39 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-8</guid>
		<description>Ok I see your point with the type cast and changed it back to the original intval() ;). But actually we could take it out completly if we trust ctype_digit() I think.
As far as I&#039;ve tested ctype_digit - it does return true/false, just like the &lt;a HREF=&quot;http://de3.php.net/ctype_digit&quot; rel=&quot;nofollow&quot;&gt;php manual&lt;/a&gt; says so I see no problem there, or am I missing something?</description>
		<content:encoded><![CDATA[<p>Ok I see your point with the type cast and changed it back to the original intval() <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . But actually we could take it out completly if we trust ctype_digit() I think.<br />
As far as I&#8217;ve tested ctype_digit &#8211; it does return true/false, just like the <a HREF="http://de3.php.net/ctype_digit" rel="nofollow">php manual</a> says so I see no problem there, or am I missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: .ﻩﻨﺮﻪﺴ</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-7</link>
		<dc:creator>.ﻩﻨﺮﻪﺴ</dc:creator>
		<pubDate>Tue, 13 Nov 2007 22:17:27 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-7</guid>
		<description>I don&#039;t really agree with the typecast. You normally cast when you want to make sure that something that&#039;s supposed to be of a certain type will really be of that certain type (like you need 1 - even if it&#039;s coming in as &quot;1&quot;). 

When dealing with user generated content you might expect anything - so a typecast is pretty useless. I think especially when facing potential SQLI there&#039;s nothing else that validation. If that fails the probability is 90+% sure that something wnet wrong - so why casting in those cases? :)

Ah - and never forget - I stepped into this trap myself some times - ctype_digit returns the incoming string - not true. Might produce evil surprises especially when dealing with unit tests :)

Greetings,
.mario</description>
		<content:encoded><![CDATA[<p>I don&#8217;t really agree with the typecast. You normally cast when you want to make sure that something that&#8217;s supposed to be of a certain type will really be of that certain type (like you need 1 &#8211; even if it&#8217;s coming in as &#8220;1&#8243;). </p>
<p>When dealing with user generated content you might expect anything &#8211; so a typecast is pretty useless. I think especially when facing potential SQLI there&#8217;s nothing else that validation. If that fails the probability is 90+% sure that something wnet wrong &#8211; so why casting in those cases? <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Ah &#8211; and never forget &#8211; I stepped into this trap myself some times &#8211; ctype_digit returns the incoming string &#8211; not true. Might produce evil surprises especially when dealing with unit tests <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Greetings,<br />
.mario</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reiners</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-6</link>
		<dc:creator>Reiners</dc:creator>
		<pubDate>Mon, 12 Nov 2007 17:35:36 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-6</guid>
		<description>thanks again for your input .mario! I changed is_int() to ctype_digit() because int&#039;s come in as string, you&#039;re right. 
But I still think that if you decide to truncate data (which isn&#039;t neccessary) it should be the first thing you do.
Additionally I replaced intval() with a type cast (int)  because I couldn&#039;t find out any difference, but its one function less we have to trust. 
What do you think?</description>
		<content:encoded><![CDATA[<p>thanks again for your input .mario! I changed is_int() to ctype_digit() because int&#8217;s come in as string, you&#8217;re right.<br />
But I still think that if you decide to truncate data (which isn&#8217;t neccessary) it should be the first thing you do.<br />
Additionally I replaced intval() with a type cast (int)  because I couldn&#8217;t find out any difference, but its one function less we have to trust.<br />
What do you think?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: .ﻩﻨﺮﻪﺴ</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-5</link>
		<dc:creator>.ﻩﻨﺮﻪﺴ</dc:creator>
		<pubDate>Mon, 12 Nov 2007 16:43:28 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-5</guid>
		<description>I&#039;d rather suggest to chose validation over truncation. If you deal with IDs you most times get integers (coming in as string when user submitted) - so you can chose is_numeric() or ctype_digit().</description>
		<content:encoded><![CDATA[<p>I&#8217;d rather suggest to chose validation over truncation. If you deal with IDs you most times get integers (coming in as string when user submitted) &#8211; so you can chose is_numeric() or ctype_digit().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reiners</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-4</link>
		<dc:creator>Reiners</dc:creator>
		<pubDate>Mon, 12 Nov 2007 00:52:09 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-4</guid>
		<description>I just added the truncation to make clear that you should truncate at first before you do other sanitizing. As seen in the added sla.ckers link, one may add the truncation at the wrong place. But you are right, it&#039;s not neccessary. However it can protect the used php functions (we have to trust) against BoF or alike, if you know your input is going to be not longer than a fixed value anyway.
As far as I&#039;ve tested, mysql query fails with entities in the mysql syntax. There is no decoding inside the query or a quoted value.

Thanks for your input, really appreciated. I thought my blog is quite unknown yet, though I didnt raise any attention because theres not much to read about yet and even the published articles need a finish ;).</description>
		<content:encoded><![CDATA[<p>I just added the truncation to make clear that you should truncate at first before you do other sanitizing. As seen in the added sla.ckers link, one may add the truncation at the wrong place. But you are right, it&#8217;s not neccessary. However it can protect the used php functions (we have to trust) against BoF or alike, if you know your input is going to be not longer than a fixed value anyway.<br />
As far as I&#8217;ve tested, mysql query fails with entities in the mysql syntax. There is no decoding inside the query or a quoted value.</p>
<p>Thanks for your input, really appreciated. I thought my blog is quite unknown yet, though I didnt raise any attention because theres not much to read about yet and even the published articles need a finish <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: .ﻩﻨﺮﻪﺴ</title>
		<link>http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-3</link>
		<dc:creator>.ﻩﻨﺮﻪﺴ</dc:creator>
		<pubDate>Sun, 11 Nov 2007 19:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://websec.wordpress.com/2007/11/11/mysql-inputoutput-validation/#comment-3</guid>
		<description>Hmmm - why the truncation? Also it should be pointed out that mysql_real_escape_string can&#039;t be used in any case.

I winder how MySQL reacts on quotes encoded ans hex entities - do you have any info on that?

Greetings,
.ﻩﻨﺮﻪﺴ</description>
		<content:encoded><![CDATA[<p>Hmmm &#8211; why the truncation? Also it should be pointed out that mysql_real_escape_string can&#8217;t be used in any case.</p>
<p>I winder how MySQL reacts on quotes encoded ans hex entities &#8211; do you have any info on that?</p>
<p>Greetings,<br />
.ﻩﻨﺮﻪﺴ</p>
]]></content:encoded>
	</item>
</channel>
</rss>
