<?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: Reflected SQL injection</title>
	<atom:link href="http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/</link>
	<description>A tool for designers dealing with programmers dealing with designers...</description>
	<pubDate>Sun, 14 Mar 2010 02:02:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Gwyn Fisher</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-253</link>
		<dc:creator>Gwyn Fisher</dc:creator>
		<pubDate>Tue, 24 Jul 2007 12:43:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-253</guid>
		<description>It's worth noting that prevalent source code analysis tools (such as the one I represent, Klocwork, full disclosure and all that) can find such reflections as well as the more normal scenarios spelled out above. The tools do tend to be pricey, although there are some very capable open source options available to individual developers that are worth checking out.

Anyway, congratulations on isolating your problem. So many developers let things like this make it all the way through QA and out into the wild, it's just not funny.

If you've got some time, check out our website for description of the kinds of things we find, or go to wikipedia and check out the prevalent open and commercial tools by looking for "static analysis".</description>
		<content:encoded><![CDATA[<p>It&#8217;s worth noting that prevalent source code analysis tools (such as the one I represent, Klocwork, full disclosure and all that) can find such reflections as well as the more normal scenarios spelled out above. The tools do tend to be pricey, although there are some very capable open source options available to individual developers that are worth checking out.</p>
<p>Anyway, congratulations on isolating your problem. So many developers let things like this make it all the way through QA and out into the wild, it&#8217;s just not funny.</p>
<p>If you&#8217;ve got some time, check out our website for description of the kinds of things we find, or go to wikipedia and check out the prevalent open and commercial tools by looking for &#8220;static analysis&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Heyes</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-252</link>
		<dc:creator>Gareth Heyes</dc:creator>
		<pubDate>Tue, 24 Jul 2007 12:33:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-252</guid>
		<description>It wasn't as easy as that, the data wasn't being mirrored but created based on certain conditions.

The idea was to enable a user to choose a set template of data which can be modified dynamically or overwritten when in the new table.</description>
		<content:encoded><![CDATA[<p>It wasn&#8217;t as easy as that, the data wasn&#8217;t being mirrored but created based on certain conditions.</p>
<p>The idea was to enable a user to choose a set template of data which can be modified dynamically or overwritten when in the new table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ce</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-251</link>
		<dc:creator>ce</dc:creator>
		<pubDate>Tue, 24 Jul 2007 12:12:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-251</guid>
		<description>when moving from table to table, why don't just use
INSERT INTO ... SELECT ... FROM ...</description>
		<content:encoded><![CDATA[<p>when moving from table to table, why don&#8217;t just use<br />
INSERT INTO &#8230; SELECT &#8230; FROM &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dancaragea</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-250</link>
		<dc:creator>dancaragea</dc:creator>
		<pubDate>Tue, 24 Jul 2007 10:16:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-250</guid>
		<description>There are 6 different situations where you have to escape the data in a web app:
(GPC means user data from a form)
1. GPC -&#62; DB (that's a classic)

2. GPC -&#62; GPC (when there's an error processing the form and you present the form back, with the form fields pre-filled with whatever data the user entered the first time)

3. GPC -&#62; display (when you write back a message like "you entered &#60;blabla&#62;". This is not the same with gpc-&#62;gpc)

4. DB -&#62; GPC (edit forms)

5. DB -&#62; display (e.g. to display blog posts, comments, etc)

6. DB -&#62; DB (rare but you still have to escape this one. I use this case in an application to move messages from a queue table to the inbox table)</description>
		<content:encoded><![CDATA[<p>There are 6 different situations where you have to escape the data in a web app:<br />
(GPC means user data from a form)<br />
1. GPC -&gt; DB (that&#8217;s a classic)</p>
<p>2. GPC -&gt; GPC (when there&#8217;s an error processing the form and you present the form back, with the form fields pre-filled with whatever data the user entered the first time)</p>
<p>3. GPC -&gt; display (when you write back a message like &#8220;you entered &lt;blabla&gt;&#8221;. This is not the same with gpc-&gt;gpc)</p>
<p>4. DB -&gt; GPC (edit forms)</p>
<p>5. DB -&gt; display (e.g. to display blog posts, comments, etc)</p>
<p>6. DB -&gt; DB (rare but you still have to escape this one. I use this case in an application to move messages from a queue table to the inbox table)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felix Zaslavskiy</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-249</link>
		<dc:creator>Felix Zaslavskiy</dc:creator>
		<pubDate>Tue, 24 Jul 2007 04:08:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-249</guid>
		<description>You should escape your input at the level of the query for example a simple enough wrapper around the query function should do. It would work something like this:

sql_query( "select .. from .. where id=%d", $id );

This function would do a mysql_escape_string() call on each parameter before doing a sprintf() on the string.  

So yes you will be doing extra computations because everything will get escaped but you get worthy security.</description>
		<content:encoded><![CDATA[<p>You should escape your input at the level of the query for example a simple enough wrapper around the query function should do. It would work something like this:</p>
<p>sql_query( &#8220;select .. from .. where id=%d&#8221;, $id );</p>
<p>This function would do a mysql_escape_string() call on each parameter before doing a sprintf() on the string.  </p>
<p>So yes you will be doing extra computations because everything will get escaped but you get worthy security.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Heyes</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-247</link>
		<dc:creator>Gareth Heyes</dc:creator>
		<pubDate>Mon, 23 Jul 2007 21:54:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-247</guid>
		<description>I had a step by step wizard which asked for the required steps and the code worked for data supplied from the user but it didn't have any escaping code for data interaction. It does now though ;)</description>
		<content:encoded><![CDATA[<p>I had a step by step wizard which asked for the required steps and the code worked for data supplied from the user but it didn&#8217;t have any escaping code for data interaction. It does now though <img src='http://www.thespanner.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Davey</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-246</link>
		<dc:creator>Richard Davey</dc:creator>
		<pubDate>Mon, 23 Jul 2007 21:45:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-246</guid>
		<description>I'm curious - you escaped the user input before storing it in Table 1 according to your diagram. How was the data then un-escaped in-between making its way from Table 1 to 2?</description>
		<content:encoded><![CDATA[<p>I&#8217;m curious - you escaped the user input before storing it in Table 1 according to your diagram. How was the data then un-escaped in-between making its way from Table 1 to 2?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Heyes</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-242</link>
		<dc:creator>Gareth Heyes</dc:creator>
		<pubDate>Mon, 23 Jul 2007 15:33:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-242</guid>
		<description>Yep prepared statements would be better I must admit. But the system I had developed wasn't using them at the time.

I had to store copies of the same data in separate tables because users can either keep the data as it is or modify it to suit their needs.

I could explain further but I'd have to give you more details how the system works, what it does etc.

I just found the vulnerability interesting because my filters didn't work.</description>
		<content:encoded><![CDATA[<p>Yep prepared statements would be better I must admit. But the system I had developed wasn&#8217;t using them at the time.</p>
<p>I had to store copies of the same data in separate tables because users can either keep the data as it is or modify it to suit their needs.</p>
<p>I could explain further but I&#8217;d have to give you more details how the system works, what it does etc.</p>
<p>I just found the vulnerability interesting because my filters didn&#8217;t work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giorgio Maone</title>
		<link>http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-240</link>
		<dc:creator>Giorgio Maone</dc:creator>
		<pubDate>Mon, 23 Jul 2007 15:26:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2007/07/23/reflected-sql-injection/#comment-240</guid>
		<description>Just another crystal clear case supporting prepared statements / parameters binding.

Security aside, using a prepared statement should be your first choice in a loop: why would you want to parse the same SQL source over and over again?</description>
		<content:encoded><![CDATA[<p>Just another crystal clear case supporting prepared statements / parameters binding.</p>
<p>Security aside, using a prepared statement should be your first choice in a loop: why would you want to parse the same SQL source over and over again?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
