<?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>James Wilson --blog &#187; Security</title>
	<atom:link href="http://ja.meswilson.com/blog/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://ja.meswilson.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 04 Feb 2010 22:05:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Exposing PHP is a Security Risk</title>
		<link>http://ja.meswilson.com/blog/2007/11/19/exposing-php-is-a-security-risk/</link>
		<comments>http://ja.meswilson.com/blog/2007/11/19/exposing-php-is-a-security-risk/#comments</comments>
		<pubDate>Mon, 19 Nov 2007 08:05:06 +0000</pubDate>
		<dc:creator>James Wilson</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://ja.meswilson.com/blog/2007/11/19/exposing-php-is-a-security-risk/</guid>
		<description><![CDATA[In php.ini, there is this:
; Misc
;
; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header).  It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
expose_php [...]]]></description>
			<content:encoded><![CDATA[<p>In php.ini, there is this:<br />
<code>; Misc<br />
;<br />
; Decides whether PHP may expose the fact that it is installed on the server<br />
; (e.g. by adding its signature to the Web server header).  It is no security<br />
; threat in any way, but it makes it possible to determine whether you use PHP<br />
; on your server or not.<br />
expose_php = On</code></p>
<p>What this means is that for every request that calls on PHP, it sends an additional header that looks something like this:</p>
<p><code>X-Powered-By: PHP/5.2.3-1ubuntu6</code></p>
<p>Since I installed this via apt-get, it added a 1ubuntu6 to the end, which I think is a slight security risk in and of itself, but that&#039;s not what this is about.</p>
<p>But what it always does, no matter how you installed it, is show the PHP version. In this case, 5.2.3, 2 revisions ago (Hooray <a href="http://packages.ubuntu.com/gutsy/web/php5">outdated repositories</a>! Seriously, it&#039;s from May. <a href="http://packages.debian.org/stable/web/php5">Though you do have Debian beat</a>.). </p>
<p>Now, in the perfect world, this wouldn&#039;t be a security risk, since everyone would have the most updated version of their software, but as everyone knows, that just doesn&#039;t happen. Mine was just installed, and it&#039;s already out of date.</p>
<p>This means that for 80% of the PHP population (98% of statistics are made up on the spot), PHP is advertising itself as an outdated, and probably vulnerable, version. Most likely you aren&#039;t even using any of the vulnerable functions, or even knew they existed, but there&#039;s still a chance you are.  During the month of PHP bugs, there were more than a few functions with vulnerabilities that I used on many occasions.</p>
<p>Wordpress also does something of the same. It gives out your Wordpress version in meta tag on every pageload, with the only way to get rid of it is editing your template. Wordpress is even harder to upgrade than PHP, so expect to find them outdated in a much higher frequency.</p>
<p>Apache, and pretty much every other server out there, does pretty much the same thing with their Server header, but Apache gives you the options on how to display it. Apache/1.3.37 (you have to show all of that from the 1337 though) or Apache/1.3 or Apache/1 or maybe just Apache. </p>
<p>With PHP, it&#039;s all or bust. Not PHP/5 or just PHP. You can overwrite every version by doing something like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;X-Powered-By: Love-Cookies-and-Hamsters/2.4&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Or something similar, but you have to do it manually for every script. There isn&#039;t really a server wide override. </p>
<p>Now, this point can almost be moot, since <a href="http://www.google.com/search?hl=en&#038;safe=off&#038;client=firefox-a&#038;rls=Swiftfox:en-US:unofficial&#038;hs=Z8L&#038;sa=X&#038;oi=spell&#038;resnum=0&#038;ct=result&#038;cd=1&#038;q=intitle:%22phpinfo()%22&#038;spell=1">it&#039;s just so easy to find phpinfo()&#039;s</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ja.meswilson.com/blog/2007/11/19/exposing-php-is-a-security-risk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Yay, Another WordPress Vulnerability</title>
		<link>http://ja.meswilson.com/blog/2007/06/06/yay-another-wordpress-vulnerability/</link>
		<comments>http://ja.meswilson.com/blog/2007/06/06/yay-another-wordpress-vulnerability/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 20:36:30 +0000</pubDate>
		<dc:creator>James Wilson</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://ja.meswilson.com/blog/2007/06/06/yay-another-wordpress-vulnerability/</guid>
		<description><![CDATA[A WordPress 2.2 vulnerability was posted on milw0rm recently, which allows SQL injection via xmlrpc.php. 
Here is the vulnerable function

function wp_suggestCategories&#40;$args&#41; &#123;
        global $wpdb;
&#160;
        $this-&#62;escape&#40;$args&#41;;
&#160;
        $blog_id         [...]]]></description>
			<content:encoded><![CDATA[<p>A WordPress 2.2 vulnerability was <a href="http://www.milw0rm.com/exploits/4039">posted on milw0rm</a> recently, which allows SQL injection via xmlrpc.php. </p>
<p>Here is the vulnerable function</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> wp_suggestCategories<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$blog_id</span>                             <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$username</span>                            <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$password</span>                            <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$category</span>                            <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$max_results</span>            	     <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login_pass_ok</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Only set a limit if one was provided.</span>
        <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max_results</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;LIMIT <span style="color: #006699; font-weight: bold;">{$max_results}</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$category_suggestions</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
                SELECT cat_ID category_id,
                        cat_name category_name
                FROM <span style="color: #006699; font-weight: bold;">{$wpdb-&gt;categories}</span>
                WHERE cat_name LIKE '<span style="color: #006699; font-weight: bold;">{$category}</span>%'
                <span style="color: #006699; font-weight: bold;">{$limit}</span>
        &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_suggestions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Namely this part</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max_results</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;LIMIT <span style="color: #006699; font-weight: bold;">{$max_results}</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Way to not censor or check if the variable is valid. That&#039;s some pretty poor programming practices right there.</p>
<p>It took the whole of 2 seconds to fix it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max_results</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_int</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max_results</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;LIMIT <span style="color: #006699; font-weight: bold;">{$max_results}</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This was fixed in the <a href="http://trac.wordpress.org/ticket/4348">trac</a> by typecasting the variable to an int. Whatever. Both ways work.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$max_results</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The issue was posted in the trac on May 28, and instead of issuing an update or informing people, nothing has been mentioned. Just let it get disclosed, have people try to exploit.</p>
<p>It does, however, not look to be too bad. You have to know the user&#039;s username and password to exploit it, though I&#039;m not sure what user level is need for this (I was too lazy to get the exploit working without C#). If it&#039;s subscriber, shit. If it&#039;s anything other than admin, it&#039;s still not very good.</p>
]]></content:encoded>
			<wfw:commentRss>http://ja.meswilson.com/blog/2007/06/06/yay-another-wordpress-vulnerability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acunetix</title>
		<link>http://ja.meswilson.com/blog/2007/03/28/acunetix/</link>
		<comments>http://ja.meswilson.com/blog/2007/03/28/acunetix/#comments</comments>
		<pubDate>Wed, 28 Mar 2007 23:59:00 +0000</pubDate>
		<dc:creator>James Wilson</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://ja.meswilson.com/blog/2007/03/28/acunetix/</guid>
		<description><![CDATA[I brought out Acunetix to test the script that I&#039;m writing. It&#039;s a pretty noisy web vulnerability scanner that tests for XSS, SQL Injection, server vulnerabilities, and other things that just shouldn&#039;t be around. I&#039;m not going to reveal too much about my script, but it consists of a user system, private messaging, posting with [...]]]></description>
			<content:encoded><![CDATA[<p>I brought out <a href="http://www.acunetix.com/">Acunetix</a> to test the script that I&#039;m writing. It&#039;s a pretty noisy web vulnerability scanner that tests for XSS, SQL Injection, server vulnerabilities, and other things that just shouldn&#039;t be around. I&#039;m not going to reveal too much about my script, but it consists of a user system, private messaging, posting with revision history, threaded replying, completely dependent on mod_rewrite, and some other things, all coded from the ground up with security in mind while doing it. So I was pretty surprised when Acunetix showed 352 &#039;alerts&#039;.</p>
<p><a href="http://ja.meswilson.com/blog/wp-content/uploads/2007/03/acu1.png"><img src="http://ja.meswilson.com/blog/wp-content/uploads/2007/03/acu1.thumbnail.png" alt="Acunetix 1" /></a></p>
<p>First off, SQL Injection. It showed 48 cases of successful SQL Injections. Crap! Luckily, all 48 injections were for one page, the deleting of private messages. These consisted of setting POST variable 5 or 7 or 1 to &#039; or %27 or %2527 or &#034; or &#039;&#034; and so on, and the response it would get would be:</p>
<blockquote><p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;)&#039; at line 1</p></blockquote>
<p>Once this gets out of development, I would change this to email me instead of just showing it, but it was still giving a valid SQL problem. This was kinda confusing, since it only cares if POST variable 5 is set and equal to &#034;on&#034;. If it&#039;s anything else, it just ignores it.</p>
<p>First, I&#039;ll explain how my message deletion system works. The inbox consists of a table of message titles, the sender, time sent, and a little checkbox to delete the message. The checkbox name is equal to the message id. Then there is a hidden input that lists all the message ids seperated by commas, like </p>
<p><code>&lt;input type="hidden" name="messages" value="10,7,5,1" /&gt;</code></p>
<p>So, once the form is submitted, it explodes $_POST['messages'] and runs through each one to check if the POST variable matching the message id is set and equal to &#034;on&#034;. (Note: I could&#039;ve just put the $_POST array in a foreach loop and done it from there, like <code>foreach($_POST as $key => $value) { /* check it */ }</code>, but for some reason I didn&#039;t.</p>
<p>Here&#039;s the code to it. There is also a check to make sure that the POST variable hash is set to what it should be. This is used to protect from someone putting a form to delete a user&#039;s messages in an iframe or something.</p>
<div style="overflow:auto;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'delete'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> AND <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'delete'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Delete Messages&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'messages'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$messages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'messages'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$where</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;sent&quot;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot; WHERE `sender_id` = '<span style="color: #006699; font-weight: bold;">$logged_user_id</span>' AND ( &quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot; WHERE `receiver_id` = '<span style="color: #006699; font-weight: bold;">$logged_user_id</span>'  AND (  &quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$done</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$messages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span> AND <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> AND <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;on&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$done</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$where</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; `msg_id` = '<span style="color: #006699; font-weight: bold;">$message</span>' &quot;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$done</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$where</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; OR `msg_id` = '<span style="color: #006699; font-weight: bold;">$message</span>' &quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$where</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; ) &quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;UPDATE `privmsgs` SET &quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;sent&quot;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;`senderbox` = 'Deleted'&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;`receiverbox` = 'Deleted'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; , `timedeleted` = &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; <span style="color: #006699; font-weight: bold;">$where</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<p>If you notice, the POST variable 5 doesn&#039;t get anywhere near the query. It&#039;s checked to see if it&#039;s set and equal to &#034;on&#034;. The variable from $_POST['messages'] is the one put in the query, and that&#039;s only if it&#039;s also numeric.</p>
<p>So, I launched the attack in it&#039;s HTTP Editor and set the page to just echo the query, and it printed:</p>
<p><code>UPDATE `privmsgs` SET `receiverbox` = 'Deleted' , `timedeleted` = 1175118688 WHERE `receiver_id` = '1' AND (  )</code></p>
<p>Aha! No messages where equal to &#034;on&#034;, but the query still fired. Simple fix. Just enclose the query in the if statement <code>if($done)</code>, and that bug is squashed. There was no possibility of SQL injection though. So even though it was inaccurate, it did help me find a bug.</p>
<p>Next, Blind SQL/XPath Injection. It states that the variables post and posthash are vulnerable. Uh, no? These are never placed into the database, just to make sure the person is posting instead of previewing and prevent people from automatically creating posts just by running a script or the iframe protection like mentioned for the PM&#039;s. It&#039;s never even close to the query.</p>
<p>Apache mod_ssl vulnerabilities. <a href="http://apachefriends.org/">XAMPP</a> problem. It&#039;s not for production anyways.</p>
<p>PHPSESSID session fixation. This means that someone can set the session id using a GET parameter, like </p>
<p><code>http://example.com?PHPSESSID=h4x0redsessionid</code></p>
<p>Now, the attacker knows that value and doesn&#039;t have to steal it at a later time. But since there is no sensitive data being stored using sessions in my script, this isn&#039;t so much a problem. To fix this, set <code>session.use_only_cookies = 1</code> in php.ini.</p>
<p>User credentials sent in clear text. 48 of these. I actually have it built to be able to use a secure login, but probably won&#039;t use it.</p>
<p>The rest were basically all false positives. It says it found sensitive directories, files, ASP.NET files, Access databases, and most anything you can think of. This turns out to just be a simple glitch with mod_rewrite. Here&#039;s the line:</p>
<div style="overflow:auto;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">RewriteRule ^browse<span style="color: #339933;">-</span>posts<span style="color: #339933;">/</span>show<span style="color: #339933;">-</span>sold<span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>category<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #339933;">-</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">/</span>? browse<span style="color: #339933;">.</span>php?show<span style="color: #339933;">=</span>sold<span style="color: #339933;">&amp;</span>category<span style="color: #339933;">=</span>$<span style="color: #cc66cc;">2</span><span style="color: #339933;">&amp;</span>page<span style="color: #339933;">=</span>$<span style="color: #cc66cc;">4</span> <span style="color: #009900;">&#91;</span>L<span style="color: #009900;">&#93;</span></pre></div></div>

</div>
<p>I didn&#039;t put $ behind the match. So, /browse-posts/show-sold/password.txt would be show a page, and /browse-posts/show-sold/Web.config would show the same thing, /browse-posts/show-sold/CVS/Repository same thing. </p>
<p>Even though there was no real problem, just an annoyance, it was an easy fix:</p>
<div style="overflow: auto;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">RewriteRule ^browse<span style="color: #339933;">-</span>posts<span style="color: #339933;">/</span>show<span style="color: #339933;">-</span>sold<span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>category<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #339933;">-</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">/</span>?<span style="color: #339933;">&lt;</span>b<span style="color: #339933;">&gt;</span>$<span style="color: #339933;">&lt;/</span>b<span style="color: #339933;">&gt;</span> browse<span style="color: #339933;">.</span>php?show<span style="color: #339933;">=</span>sold<span style="color: #339933;">&amp;</span>category<span style="color: #339933;">=</span>$<span style="color: #cc66cc;">2</span><span style="color: #339933;">&amp;</span>page<span style="color: #339933;">=</span>$<span style="color: #cc66cc;">4</span> <span style="color: #009900;">&#91;</span>L<span style="color: #009900;">&#93;</span></pre></div></div>

</div>
<p>Now, /browse-posts/show-sold/password.txt sends a 404.</p>
<p>So, if you don&#039;t include the mod_ssl problem, it found 0 vulnerabilities, 1 bug, 1 possible problem, and about 300 false positives, so I&#039;m not really sure of the usefulness of this. If you have an app you want to easily test, it can help, but I don&#039;t see this as a sure fire way to test it. </p>
]]></content:encoded>
			<wfw:commentRss>http://ja.meswilson.com/blog/2007/03/28/acunetix/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
