<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>

<title>&lt;big&gt;SQL Injection FAQ &lt;/big&gt;</title><link>http://www.openlinksw.com:443/blog/kidehen@openlinksw.com/blog/?id=48</link><description>SQL Injection FAQ 

&amp;nbsp;http://www.sqlsecurity.com/DesktopDefault.aspx?tabindex=2&amp;amp;;tabid=3&amp;nbsp; 






Are other SQL Servers (Sybase, Oracle, DB2) subject to SQL injection?
Yes, to varying degrees. Here is a site that can get you more details on some of the issues with other SQL Servers. http://www.owasp.orgWhat is SQL Injection and why is all this information not included in the regular FAQ? 
SQL Injection is simply a term describing the act of passing SQL code into an application that was not intended by the developer. &amp;nbsp; Since this topic is not specifically restricted to SQL Server it is not included in the normal FAQ.&amp;nbsp; In fact, much of the problems that allow SQL injection are not the fault of the database server per-se but rather are due to poor input validation and coding at other code layers.&amp;nbsp; However, due to the serious nature and prevalence of this problem I feel its inclusion in a thorough discussion of SQL Server security is warranted.
What causes SQL Injection?
SQL injection is usually caused by developers who use &quot;string-building&quot; techniques in order to execute SQL code.&amp;nbsp; For example, in a search page, the developer may use the following code to execute a query (VBScript/ASP sample shown):
Set myRecordset = myConnection.execute(&quot;SELECT * FROM myTable WHERE someText =&#39;&quot; &amp;amp; request.form(&quot;inputdata&quot;) &amp;amp; &quot;&#39;&quot;)
The reason this statement is likely to introduce an SQL injection problem is that the developer has made a classic mistake - poor input validation.&amp;nbsp; We are trusting that user has not entered something malicious - something like the innocent looking single quote (&#39;).&amp;nbsp; Let&#39;s consider what would happen if a user entered the following text into the search form:
&#39; exec master..xp_cmdshell &#39;net user test testpass /ADD&#39; --
Then, when the query string is assembled and sent to SQL Server, the server will process the following code:
SELECT * FROM myTable WHERE someText =&#39;&#39; exec master..xp_cmdshell &#39;net user test testpass /ADD&#39;--&#39;
Notice, the first single quote entered by the user closed the string and SQL Server eagerly executes the next SQL statements in the batch including a command to add a new user to the local accounts database.&amp;nbsp; If this application were running as &#39;sa&#39; and the MSSQLSERVER service is running with sufficient privileges we would now have an account with which to access this machine.&amp;nbsp; Also note the use of the comment operator (--) to force the SQL Server to ignore the trailing quote placed by the developer&#39;s code.
More
Very intresting that these are all Native Interface based exploits.&amp;nbsp; So the security issue isn&#39;t ODBC, JDBC, ADO.NET, or OLE DB specific (although they certainly increase the potential damage that can be unleashed via metadata analysis en route to that huge Cartesian Product ; the mother of all Exploits!). Our Session Rules Book was devised in 1993 with many of these issues in mind, and to this date there are no other ODBC/JDBC/OLE DB products out there that even come close to acknowledging this reality.</description><pubDate>Wed, 21 May 2003 22:27:45 GMT</pubDate><generator>Virtuoso Universal Server 08.03.3335</generator><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kingsley Uyi Idehen</dc:creator><image><title>SQL Injection FAQ </title><url>http://www.openlinksw.com:443/weblog/public/images/vbloglogo.gif</url><link>http://www.openlinksw.com:443/blog/kidehen@openlinksw.com/blog/?id=48</link><description>I have seen the future and it&#39;s full of Linked Data! :-)</description><width>88</width><height>31</height></image>

</channel>
</rss>
