<?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: Oracle, bind variables and SQL Injection &#8211;  Keeping out unwanted guests</title>
	<atom:link href="http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/</link>
	<description>Oracle - for when it was like that when you got there</description>
	<lastBuildDate>Fri, 24 May 2013 13:38:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Ruth</title>
		<link>http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/#comment-25288</link>
		<dc:creator><![CDATA[Ruth]]></dc:creator>
		<pubDate>Fri, 23 Nov 2012 14:25:56 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=1041#comment-25288</guid>
		<description><![CDATA[This is great, thanks! I&#039;m new to Oracle, and many of my coworkers go slack-jawed when I start talking attack vectors, so it&#039;s really reassuring to find a clear explanation of the Oracle defence. Thanks!]]></description>
		<content:encoded><![CDATA[<p>This is great, thanks! I&#8217;m new to Oracle, and many of my coworkers go slack-jawed when I start talking attack vectors, so it&#8217;s really reassuring to find a clear explanation of the Oracle defence. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mikesmithers</title>
		<link>http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/#comment-3382</link>
		<dc:creator><![CDATA[mikesmithers]]></dc:creator>
		<pubDate>Sun, 12 Jun 2011 14:17:13 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=1041#comment-3382</guid>
		<description><![CDATA[Gary,

great question. Almost worth another post just to answer it.
If you do a var_dump on the $query variable when you enter the text you suggest you&#039;ll get :
[sourcecode language=&quot;sql&quot;]
BEGIN :l_count := validate_app_user_fn(&#039;HARRY&#039;,&#039;DUNNO\&#039;); DELETE FROM APP_USERS; COMMIT; DBMS_OUTPUT.PUT_LINE(\&#039;&#039;); END;
[/sourcecode]

This generates the error :

[sourcecode light=&quot;true&quot;]
ORA-06550: line 1, column 111: PLS-00103: Encountered the symbol &quot;\&quot; when expecting one of the following: ( ) - + case mod new not null others &lt;an identifier&gt; &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; table avg count current exists max min prior sql stddev sum variance execute multiset the both leading trailing forall merge year month DAY_ hour minute second timezone_hour timezone_minute timezone_region timezone_abbr time timestamp interval date &lt;a string literal with character set specification&gt;
[/sourcecode]

You can get a clearer idea of what&#039;s happening here if we use a shorter string.
So - username = &lt;em&gt;Harry&lt;/em&gt;, Password =&lt;em&gt; &#039;vain attempt to inject some SQL &#039; &lt;/em&gt;
[sourcecode language=&quot;sql&quot;]
BEGIN :l_count := validate_app_user_fn(&#039;HARRY&#039;,&#039;VAIN ATTEMPT TO INJECT SOME SQL\&#039;&#039;); END;
[/sourcecode]

Which results in :

[sourcecode light=&quot;true&quot;]
ORA-01756: quoted string not properly terminated
[/sourcecode]

Essentially, this is because the database engine recognises the $query value as a PL/SQL block.
It then binds the input variables to the input values for the function. Therefore, whatever values the user enters, they&#039;ll be treated as parameters to the function and nothing else.]]></description>
		<content:encoded><![CDATA[<p>Gary,</p>
<p>great question. Almost worth another post just to answer it.<br />
If you do a var_dump on the $query variable when you enter the text you suggest you&#8217;ll get :</p>
<pre class="brush: sql; title: ; notranslate">
BEGIN :l_count := validate_app_user_fn('HARRY','DUNNO\'); DELETE FROM APP_USERS; COMMIT; DBMS_OUTPUT.PUT_LINE(\''); END;
</pre>
<p>This generates the error :</p>
<pre class="brush: plain; light: true; title: ; notranslate">
ORA-06550: line 1, column 111: PLS-00103: Encountered the symbol &quot;\&quot; when expecting one of the following: ( ) - + case mod new not null others &lt;an identifier&gt; &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; table avg count current exists max min prior sql stddev sum variance execute multiset the both leading trailing forall merge year month DAY_ hour minute second timezone_hour timezone_minute timezone_region timezone_abbr time timestamp interval date &lt;a string literal with character set specification&gt;
</pre>
<p>You can get a clearer idea of what&#8217;s happening here if we use a shorter string.<br />
So &#8211; username = <em>Harry</em>, Password =<em> &#8216;vain attempt to inject some SQL &#8216; </em></p>
<pre class="brush: sql; title: ; notranslate">
BEGIN :l_count := validate_app_user_fn('HARRY','VAIN ATTEMPT TO INJECT SOME SQL\''); END;
</pre>
<p>Which results in :</p>
<pre class="brush: plain; light: true; title: ; notranslate">
ORA-01756: quoted string not properly terminated
</pre>
<p>Essentially, this is because the database engine recognises the $query value as a PL/SQL block.<br />
It then binds the input variables to the input values for the function. Therefore, whatever values the user enters, they&#8217;ll be treated as parameters to the function and nothing else.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/#comment-3367</link>
		<dc:creator><![CDATA[Gary]]></dc:creator>
		<pubDate>Sat, 11 Jun 2011 00:34:15 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=1041#comment-3367</guid>
		<description><![CDATA[Surely the problem here has been made worse, not better.
Rather than just a SELECT statement to play with, he&#039;s now got all the power of PL/SQL to inject.

What if he puts in 
dunno&#039;); delete from app_users; commit; dbms_output.put_line(&#039;
as the password value ?
Won&#039;t it execute the following ?

BEGIN :l_count := validate_app_user_fn(&#039;HARRY&#039;,&#039;dunno&#039;); delete from app_users; commit; dbms_output.put_line(&#039;&#039;); END;]]></description>
		<content:encoded><![CDATA[<p>Surely the problem here has been made worse, not better.<br />
Rather than just a SELECT statement to play with, he&#8217;s now got all the power of PL/SQL to inject.</p>
<p>What if he puts in<br />
dunno&#8217;); delete from app_users; commit; dbms_output.put_line(&#8216;<br />
as the password value ?<br />
Won&#8217;t it execute the following ?</p>
<p>BEGIN :l_count := validate_app_user_fn(&#8216;HARRY&#8217;,'dunno&#8217;); delete from app_users; commit; dbms_output.put_line(&#8221;); END;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mikesmithers</title>
		<link>http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/#comment-3328</link>
		<dc:creator><![CDATA[mikesmithers]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 08:24:19 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=1041#comment-3328</guid>
		<description><![CDATA[There still doesn&#039;t appear to be a definitive explaination of how the Sony attack happened, although SQL Injection may well have played a part.
I found a pretty good article on it at&lt;a href=&quot;https://www.veracode.com/blog/2011/05/possible-playstation-network-attack-vectors/&quot; rel=&quot;nofollow&quot;&gt; https://www.veracode.com/blog/2011/05/possible-playstation-network-attack-vectors/&lt;/a&gt; if anyone&#039;s interested.
One of the possibilities mentioned in the article is that part of the attack could have been initiated from inside the firewall. I wrote something about this kind of attack a while ago. The post can be found &lt;a href=&quot;http://wp.me/pweWl-51&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.]]></description>
		<content:encoded><![CDATA[<p>There still doesn&#8217;t appear to be a definitive explaination of how the Sony attack happened, although SQL Injection may well have played a part.<br />
I found a pretty good article on it at<a href="https://www.veracode.com/blog/2011/05/possible-playstation-network-attack-vectors/" rel="nofollow"> </a><a href="https://www.veracode.com/blog/2011/05/possible-playstation-network-attack-vectors/" rel="nofollow">https://www.veracode.com/blog/2011/05/possible-playstation-network-attack-vectors/</a> if anyone&#8217;s interested.<br />
One of the possibilities mentioned in the article is that part of the attack could have been initiated from inside the firewall. I wrote something about this kind of attack a while ago. The post can be found <a href="http://wp.me/pweWl-51" rel="nofollow">here</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PeterPatrick</title>
		<link>http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/#comment-3322</link>
		<dc:creator><![CDATA[PeterPatrick]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 02:55:31 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=1041#comment-3322</guid>
		<description><![CDATA[The Sony database injection was a very big news...]]></description>
		<content:encoded><![CDATA[<p>The Sony database injection was a very big news&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
