<?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>SecureThoughts.com &#187; Solutions</title>
	<atom:link href="http://securethoughts.com/category/solutions/feed/" rel="self" type="application/rss+xml" />
	<link>http://securethoughts.com</link>
	<description>Inferno&#039;s Blog on Application Security</description>
	<lastBuildDate>Sun, 22 Nov 2009 20:09:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Millions of PDF invisibly embedded with your internal disk paths</title>
		<link>http://securethoughts.com/2009/11/millions-of-pdf-invisibly-embedded-with-your-internal-disk-paths/</link>
		<comments>http://securethoughts.com/2009/11/millions-of-pdf-invisibly-embedded-with-your-internal-disk-paths/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 20:09:21 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[Information Gathering]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WebAppSec]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Information Disclosure]]></category>
		<category><![CDATA[PDF]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=1027</guid>
		<description><![CDATA[I found an interesting privacy issue while analyzing PDF files. This bug occurs when you are using Internet Explorer to print locally saved web pages as PDF and affects all IE versions including IE8. It does not matter which PDF generation software you are using like Adobe Acrobat Professional, CutePDF, PrimoPDF, etc as long as [...]]]></description>
			<content:encoded><![CDATA[<p>I found an interesting privacy issue while analyzing <a href="http://get.adobe.com/reader/">PDF</a> files. This bug occurs when you are using <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Internet Explorer</a> to print locally saved web pages as PDF and affects all IE versions including IE8. It does not matter which PDF generation software you are using like <a href="http://www.adobe.com/products/acrobatpro/">Adobe Acrobat Professional</a>, <a href="http://www.cutepdf.com/">CutePDF</a>, <a href="http://www.primopdf.com">PrimoPDF</a>, etc as long as you are invoking it from inside the IE print function. In Windows, even when your default browser is not IE and if you right click a file to select the PRINT from the context menu, then by default it invokes the IE print handler. So, you will still see this issue in the generated PDF.</p>
<p>This bug is NOT ABOUT the local disk path appearing in the FOOTER of your pdf since it is clearly visible and already known by most people. This is easy enough to hide by just going <strong>File</strong> -> <strong>Page Setup</strong> -> <strong>Change the Footer value from &#8220;URL&#8221; to &#8220;-Empty-&#8221;</strong>. After doing that, you will not expect your internal disk path being put anywhere else. However, that does not happen.</p>
<p>The privacy issue arises from the fact that your local disk path gets invisibly embedded inside your PDF in the title attribute. Only when you open the file in an Editor like Notepad, you will see it. Currently, there is no option in IE to disable it. The only workaround is to manually nullify this value by editing the PDF file. Note that this problem does not occur when using other browsers such as Firefox and Chrome. In fact, Chrome handles the other footer issue intelligently as well by showing your disk path as &#8220;&#8230;&#8221;, rather than exposing it.</p>
<p><strong>Proof of Concept:</strong></p>
<p><em>Steps to reproduce:</em><br />
1. Pick a .HTM or .HTML or .MHT file on your local computer.<br />
2. Open this file in IE and click Ctrl-P.<br />
OR Right-click the file in explorer and select PRINT from context menu.<br />
4. Select any PDF writer as Printer such as Adobe PDF / CutePDF / PrimoPDF / etc.<br />
5. Click Print. When the PDF writer asks for a filename, provide any name.<br />
6. Open the generated pdf in notepad, and search for &#8220;<strong>file://</strong>&#8221; without quotes.</p>
<p><em>Search for this on your favorite search engine (Google/Bing)</em></p>
<blockquote><p>filetype:pdf file c (htm OR html OR mhtml)</p></blockquote>
<p><a href="http://www.google.com/search?hl=en&#038;q=filetype%3Apdf+file+c+%28htm+OR+html+OR+mhtml%29&#038;btnG=Search&#038;aq=f&#038;oq=&#038;aqi=">Google Search 1 (for drive C)</a> &#8211; 4 million results<br />
<a href="http://www.google.com/search?hl=en&#038;q=filetype%3Apdf+file+d+%28htm+OR+html+OR+mhtml%29&#038;btnG=Search&#038;aq=f&#038;oq=&#038;aqi=">Google Search 2 (for drive D)</a> &#8211; 13 million results<br />
and so on&#8230;. (I added till drive letter J and total was more than 50 million&#8230;.)</p>
<p>So, out of <a href="http://www.google.com/search?hl=en&#038;source=hp&#038;fkt=265&#038;fsdt=593&#038;q=filetype%3Apdf&#038;aq=f&#038;oq=&#038;aqi=g10">280 million pdfs</a> accessible on the internet, more than 20% look to be exposing internal disk paths which is a huge number. I have contacted the Microsoft and Adobe Security Teams about this issue. Microsoft has plans to fix this in IE9, while Adobe has opened the case but hasn&#8217;t planned the timelines yet.</p>
<p><strong>Examples:</strong></p>
<p><a href="http://www.eda.gov/PDF/EDA_vol1;%20Issue10.pdf">http://www.eda.gov/PDF/EDA_vol1;%20Issue10.pdf</a></p>
<pre class="brush: xml; wrap-lines: true">
&lt;x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.0-c316 44.253921, Sun Oct 01 2006 17:14:39"&gt;
   &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
      &lt;rdf:Description rdf:about=""
            xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;
         &lt;dc:format&gt;application/pdf&lt;/dc:format&gt;
         &lt;dc:creator&gt;
            &lt;rdf:Seq&gt;
               &lt;rdf:li&gt;LewtasS&lt;/rdf:li&gt;
            &lt;/rdf:Seq&gt;
         &lt;/dc:creator&gt;
         &lt;dc:title&gt;
            &lt;rdf:Alt&gt;
               &lt;rdf:li xml:lang="x-default"&gt;file://C:\Documents and Settings\lewtass\Desktop\eda newsletter&lt;/rdf:li&gt;
            &lt;/rdf:Alt&gt;
         &lt;/dc:title&gt;
      &lt;/rdf:Description&gt;
</pre>
<p><a href="http://www.oregon.gov/OMD/OEM/plans_train/grant_info/fy2009_hsgp_investment_justification.pdf">http://www.oregon.gov/OMD/OEM/plans_train/grant_info/fy2009_hsgp_investment_justification.pdf</a></p>
<pre class="brush: xml; wrap-lines: true">
&lt;x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1-701"&gt;
   &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
      &lt;rdf:Description rdf:about=""
            xmlns:pdf="http://ns.adobe.com/pdf/1.3/"&gt;
         &lt;pdf:Producer&gt;Acrobat Distiller 7.0.5 (Windows)&lt;/pdf:Producer&gt;
      &lt;/rdf:Description&gt;
      &lt;rdf:Description rdf:about=""
            xmlns:xap="http://ns.adobe.com/xap/1.0/"&gt;
         &lt;xap:CreatorTool&gt;PScript5.dll Version 5.2.2&lt;/xap:CreatorTool&gt;
         &lt;xap:ModifyDate&gt;2009-03-18T15:07:10-07:00&lt;/xap:ModifyDate&gt;
         &lt;xap:CreateDate&gt;2009-03-18T15:07:10-07:00&lt;/xap:CreateDate&gt;
      &lt;/rdf:Description&gt;
      &lt;rdf:Description rdf:about=""
            xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;
         &lt;dc:format&gt;application/pdf&lt;/dc:format&gt;
         &lt;dc:title&gt;
            &lt;rdf:Alt&gt;
               &lt;rdf:li xml:lang="x-default"&gt;mhtml:file://O:\fema\shsp_2009\draft ijs\fy 2009 investment jus&lt;/rdf:li&gt;
            &lt;/rdf:Alt&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/11/millions-of-pdf-invisibly-embedded-with-your-internal-disk-paths/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Bypassing OWASP ESAPI XSS Protection inside Javascript</title>
		<link>http://securethoughts.com/2009/08/bypassing-owasp-esapi-xss-protection-inside-javascript/</link>
		<comments>http://securethoughts.com/2009/08/bypassing-owasp-esapi-xss-protection-inside-javascript/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 08:08:53 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[Exploits]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WebAppSec]]></category>
		<category><![CDATA[XSS]]></category>
		<category><![CDATA[esapi]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[owasp]]></category>
		<category><![CDATA[xss prevention cheatsheet]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=722</guid>
		<description><![CDATA[Everyone knows the invaluable XSS cheat sheet maintained by &#8220;RSnake&#8221;. It is all about breaking things and features all the scenarios that can result in XSS. To complement his efforts, there is an excellent XSS prevention cheat sheet created by &#8220;Jeff Williams&#8221; (Founder and CEO, Aspect Security). As far as I have seen, this wiki [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone knows the invaluable <a href="http://ha.ckers.org/xss.html">XSS cheat sheet</a> maintained by <a href="http://ha.ckers.org">&#8220;RSnake&#8221;</a>. It is all about breaking things and features all the scenarios that can result in <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">XSS</a>. To complement his efforts, there is an excellent <a href="http://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet">XSS prevention cheat sheet</a> created by &#8220;Jeff Williams&#8221; (Founder and CEO, <a href="http://www.aspectsecurity.com">Aspect Security</a>). As far as I have seen, this wiki page provides the most comprehensive information on protecting yourself from XSS on the internet. It advises using the <a href="http://www.owasp.org">OWASP</a> <a href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API">ESAPI</a> api to mitigate any XSS arising from untrusted user input.</p>
<p>I was evaluating this ESAPI api and the recommendations given on the wiki to see if there are any potential flaws. Any weakness impacts a very large number of users since many developers are using it to strengthen their web applications throughout the world. This is my way of contributing back to the community, but can never match the immense efforts put by Jeff and other OWASP team members in developing this library.</p>
<p>I want to give you a little bit of background before diving into the real vulnerability. The XSS prevention cheat sheet classifies XSS protections by dividing them into broadly four buckets &#8211; HTML Body injection, HTML Attribute injection, Javascript injection and CSS injection. For each of these four buckets, there is an ESAPI function reference you can use for output escaping/encoding.</p>
<blockquote><p>If you allow any untrusted user input into javascript functions document.write() OR eval(), it can still execute the XSS even after you do the scrubbing using the ESAPI encodeForJavaScript() function. The reason being that hex escaped chars are converted back into normal chars at the time of execution of these functions. </p></blockquote>
<p>Here is the proof of concept jsp code:</p>
<pre class="brush: javascript; wrap-lines: true">
&lt;%@page import="org.owasp.esapi.*"%&gt;

&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd"&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;title&gt;ESAPI XSS Protection Bypass&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;h1&gt;ESAPI XSS Protection Bypass&lt;/h1&gt;
        &lt;p id="tb1"/&gt;&lt;br&gt;
        &lt;p id="tb2"/&gt;
        &lt;script&gt;
            //in real scenario, these three strings come from request.getParameter or user input
            &lt;%
                String vulstr1 = "-1';alert(0);";
                String vulstr2 = "&lt;img src=x onerror=alert(1)&gt;";
                String vulstr3 = "0,x setter=alert,x=2";
            %&gt;   

            // you can safely use it in places like this
            // Ex. vulstr1 is completely encapsulated in a and alert(0) not executed.
            var a='&lt;%= ESAPI.encoder().encodeForJavaScript(vulstr1) %&gt;';
            alert(a);

            // However, you can bypass protection in places like these
            // Ex. vulstr2 gets written to html and alert(1) executes
            document.write("&lt;%= ESAPI.encoder().encodeForJavaScript(vulstr2) %&gt;");
            // Ex. part of vulstr3 get assigned to u, rest alert(2) executes
            eval("u=&lt;%= ESAPI.encoder().encodeForJavaScript(vulstr3) %&gt;");
        &lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Much thanks to <a href="http://jeremiahgrossman.blogspot.com/">Jeremiah Grossman</a> and <a href="http://twitter.com/planetlevel">Jeff Williams</a> for taking the time to review my idea and providing their insights. Jeremiah told me that he has seen such injections from time to time at <a href="http://www.whitehatsec.com">WhiteHat</a> and these do exist in the wild. </p>
<p>Jeff confirmed that some documentation changes will fix this. I agree that no esapi code change is required, because function themselves are not insecure. </p>
<blockquote><p>But, if you are currently using esapi functions inside your javascript code, it is important that you re-review your javascript code and the places where your make calls to esapi functions.</p></blockquote>
<p> If you use the esapi function encodeForJavaScript() inside document.write, it is advised that you change them with other appropriate esapi functions depending on the context where the data is ultimately landing. For example, if you have document.write(&#8220;&lt;script>alert(&#8216;XSS&#8217;)&lt;/script>&#8221;), you know the data is landing in html body context, so it is appropriate to use encodeForHTML() wrapper. Using user input inside eval is less common, but more disastrous. The reason for this is you can still begin another command context using , and  (space) char and it won&#8217;t be encoded by function encodeForHTML(). So, it is better to avoid putting user input inside eval.</p>
<p>Any more suggestions or discussion on fixes is highly welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/08/bypassing-owasp-esapi-xss-protection-inside-javascript/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Hacking CSRF Tokens using CSS History Hack</title>
		<link>http://securethoughts.com/2009/07/hacking-csrf-tokens-using-css-history-hack/</link>
		<comments>http://securethoughts.com/2009/07/hacking-csrf-tokens-using-css-history-hack/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 06:03:53 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[Brute Force]]></category>
		<category><![CDATA[CSRF]]></category>
		<category><![CDATA[Exploits]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WebAppSec]]></category>
		<category><![CDATA[Client Side Attack]]></category>
		<category><![CDATA[Cross Site Request Forgery]]></category>
		<category><![CDATA[CSS History Hack]]></category>
		<category><![CDATA[Jeremiah Grossman]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=581</guid>
		<description><![CDATA[Update: Security researchers Sirdarckcat and Gareth were kind enough to share the code for a pure CSS based CSRF token finder here . This is stealthier than my PoC below, which used a combination of both JS and CSS. So, it will still work even if you disable javascript and you are not safe anymore [...]]]></description>
			<content:encoded><![CDATA[<p><em>Update: Security researchers <a href="http://sirdarckcat.blogspot.com">Sirdarckcat</a> and <a href="http://www.thespanner.co.uk/">Gareth</a> were kind enough to share the code for a pure CSS based CSRF token finder <a href="http://eaea.sirdarckcat.net/css-sib/urlbruteforce.php">here</a> . This is stealthier than my PoC below, which used a combination of both JS and CSS. So, it will still work even if you disable javascript and you are not safe anymore <img src='http://securethoughts.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> . To make this PoC more responsive to the client, you need to use multiple CSS stylesheets using the import command. The only problem I see with this pure CSS based approach is there will be network latency involved with large key spaces because your large CSS stylesheet will need to be downloaded by your browser.</em></p>
<p>I was thinking about the problem of <a href="http://www.cgisecurity.com/csrf-faq.html">Cross Site Request Forgery</a> and current mitigation strategies used in the Industry. In many of the real world applications I have tested so far, I see the use of random tokens appended as part of url. If the request fails to provide any token or provide a token with incorrect value, then the request is rejected. This prevents CSRF or any cross domain unauthorized function execution. </p>
<p>Uptil now, it was considered infeasible for an attacker to discover your CSRF token using <a href="http://en.wikipedia.org/wiki/Brute_force_attack">Brute Force Attacks</a> on the server.</p>
<p>The reasons being:</p>
<ol>
<li>It generates <strong>lot of noise on the network and is slow.</strong> So most probably an IDS or Web App Firewall will pick up the malicious behavior and block your ip. For example, a Base16 CSRF token of length 5 characters (starting with a character) will generate approximately 393,216 requests.</li>
<li>Many applications are programmed to <strong>invalidate your session</strong> after it detects more than a certain number of requests with invalid token values. E.g. 30.</li>
</ol>
<p>I am going to change this belief by showing you a technique to quicky find csrf tokens without generating alerts. This technique is a <strong>client side attack</strong>, so there is almost no network traffic generated and hence, your server and IDS/Web App Firewalls won&#8217;t notice it at all. This attack is based on the popular <a href="http://jeremiahgrossman.blogspot.com/2006/08/i-know-where-youve-been.html">CSS History Hack</a> found by <a href="http://jeremiahgrossman.blogspot.com">Jeremiah Grossman</a> 3 years ago.</p>
<p>In this exploit, we discover the csrf token by brute forcing the various set of urls in browser history. We will try to embed different csrf token values as part of url and check if the user has visited that url. If yes, there is a good chance that the user is either using the same CSRF token in the current active session or might have used that token in a previous session. Once we have a list of all such tokens, we can just try our csrf attack on the server using that small list. Currently this attack is feasible for tokens with length of 5 characters or shorter. I tried it on a base16 string of length 5 and was able to brute force the entire key space in less than 2 minutes.</p>
<p>Some of the prerequisites for this attack to work are either</p>
<ol>
<li>CSRF token remains the same for a particular user session. e.g. csrf token=hash(session_id) OR</li>
<li>CSRF token submitted in older forms for the same session is accepted. Many times, this is the case as it enhances user experience and allows using forward and back browser buttons.</li>
</ol>
<p><strong>Proof of Concept</strong> is available <a href="http://www.securethoughts.com/security/csrfcsshistory/csrfscan.html">here</a>.<br />
Before running the PoC, you need to change the url and csrftoken paramater values. <br/><br />
For testing using the defaults, you need to first visit one of the following urls, e.g. </p>
<ol>
<li><a href="http://securethoughts.com/?param1=val1&#038;csrftoken=b59fe">http://securethoughts.com/?param1=val1&#038;csrftoken=b59fe</a> [change b59fe to any 5-digit base 16 string starting with a character, i.e.greater than a0000] </li>
<li><a href="http://tinyurl.com/l2lwgd">http://tinyurl.com/l2lwgd</a> [which is 301 redirect to previous url].<br/></li>
</ol>
<p><b><u>Note:</u></b> http://www.securethoughts.com and http://securethoughts.com are treated differently while storing in browser history.<br/><br />
A sample run will look like this &#8211; <br/><br />

<a href="http://securethoughts.com/wp-content/gallery/security/csrfcsshistory.jpg" title="" class="shutterset_singlepic14" >
	<img class="ngg-singlepic" src="http://securethoughts.com/wp-content/gallery/cache/14__500x375_csrfcsshistory.jpg" alt="CSRF Token using CSS History Hack" title="CSRF Token using CSS History Hack" />
</a>
<br/></p>
<p>For making this attack unfeasible, </p>
<ol>
<li><b>Server-Side Solution (for developers):</b></li>
<ul>
<li>Make your CSRF tokens long enough (8 or more chars) to be unfeasible for a CLIENT SIDE attack. The ever-increasing processing power will make this attack feasible for longer tokens as well.</li>
<li>Store your CSRF token as part of hidden form field, rather than putting in url.</li>
<li>Use a different random token for every form submission and not accept any obsolete token, even for the same session.</li>
</ul>
<li><b>Client-Side Solution (for your customers/users): </b>
<ul>
<li>Use a browser plugin such as <a href="http://www.safehistory.com/">SafeHistory</a>, which defends against visited-link-based tracking techniques.</li>
<li>Use the private browsing mode in your browser.
</ul>
</ol>
<p>And last, but not the least, XSS obliterates all the CSRF protections possible. So, get rid of XSS first. </p>
<p>I would like to thank <a href="http://jeremiahgrossman.blogspot.com/">Jeremiah</a> for providing his insightful feedback on this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/07/hacking-csrf-tokens-using-css-history-hack/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>HP&#8217;s SWFScan does not find simple XSS in Flash Apps</title>
		<link>http://securethoughts.com/2009/04/hps-swfscan-does-not-find-simple-xss-in-flash-apps/</link>
		<comments>http://securethoughts.com/2009/04/hps-swfscan-does-not-find-simple-xss-in-flash-apps/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 06:48:28 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[WebAppSec]]></category>
		<category><![CDATA[XSS]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[SWFIntruder]]></category>
		<category><![CDATA[SWFScan]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=205</guid>
		<description><![CDATA[This will a short post on my review of the new HP&#8217;s solution for auditing Flash apps &#8211; SWFScan. It has a variety of features, some of which are highlighted on the HP&#8217;s Blog here. 
Before that, I have used Stefano&#8217;s Tool, SWFIntruder. It is a nice tool to audit Actionscript 2 apps, but it [...]]]></description>
			<content:encoded><![CDATA[<p>This will a short post on my review of the new HP&#8217;s solution for auditing Flash apps &#8211; <a href="http://www.hp.com/go/swfscan">SWFScan</a>. It has a variety of features, some of which are highlighted on the HP&#8217;s Blog <a href="http://www.communities.hp.com/securitysoftware/blogs/spilabs/archive/2009/03/20/exposing-flash-application-vulnerabilities-with-swfscan.aspx">here</a>. </p>
<p>Before that, I have used <a href="http://www.wisec.it/">Stefano&#8217;s Tool</a>, <a href="https://www.owasp.org/index.php/Category:SWFIntruder">SWFIntruder</a>. It is a nice tool to audit Actionscript 2 apps, but it only reports XSS issues and does not support Actionscript 3. This time, I was out of luck, since I needed to audit a Actionscript 3 App. Also, I could not decompile and study its source code since the free tool <a href="http://www.nowrap.de/flare.html">Flare</a> does not work on Actionscript 3.</p>
<p>So, I decided to give HP&#8217;s tool a try. I had a lot of expectations from this tool, since HP already has a popular tool WebInspect which is known in the industry for its website and web services auditing capabilities. I ran this tool on my app and it decompiled beautifully the complete source code of the flash app. It has a  useful search feature which can aid in manually studying source code for vulnerabilities. However, I wanted to see some of its automatic auditing capabilities. So, I ran the scan and found it to find some issues like crypto issues(sha0/sha1), stacktraces, etc. Apart from that, it didn&#8217;t report any serious issues like XSS, etc. It also does report a large number of false positives in checks that start with &#8220;Possible/Potentially &#8211; - &#8211; -&#8221;. But i am willing to ignore those as long as the tool can effectively find some important vulnerabilities.</p>
<p>I didn&#8217;t know my app had any XSS issues or not, so I decided to use the free test.swf which is provided as part of SWFIntruder. </p>
<blockquote><p><strong>To my surprise, HP&#8217;s SWFScan tool did not report any of the 5 XSS issues reported by SWFIntruder.</strong></p></blockquote>
<p>If you see the screenshots below, swfscan shows you the vulnerabilities it found and the decompiled source code. Using manual inspection, a penetration tester can easily locate XSS issues in parameters such as _root.obj and _root.sd which are directly written into html without any escaping/filtering. I hope this free SWFScan tool improves in the near future and does not miss auditing such simple vulnerabilities.</p>
<p>
<img src="http://securethoughts.com/security/swfscan/swfscan1.jpg" alt="SWFScan" /><br />
<br />
<img src="http://securethoughts.com/security/swfscan/swfintruder1.jpg" alt="SWFIntruder" /></p>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/04/hps-swfscan-does-not-find-simple-xss-in-flash-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Phishing with Non Scriptable User Input</title>
		<link>http://securethoughts.com/2009/03/phishing-with-non-scriptable-user-input/</link>
		<comments>http://securethoughts.com/2009/03/phishing-with-non-scriptable-user-input/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 05:57:46 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[Phishing]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WebAppSec]]></category>
		<category><![CDATA[HTML Entities]]></category>
		<category><![CDATA[URL Encoding]]></category>
		<category><![CDATA[Whitespace]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=184</guid>
		<description><![CDATA[This week I did pentest of a commercial application. I was frustated to find that most of the user supplied content was sanitized using html entities, before being sent to the browser. So, it was not possible to inject my scripted content to cause XSS.
Just when I was about to give up, I found the [...]]]></description>
			<content:encoded><![CDATA[<p>This week I did pentest of a commercial application. I was frustated to find that most of the user supplied content was sanitized using html entities, before being sent to the browser. So, it was not possible to inject my scripted content to cause XSS.</p>
<p>Just when I was about to give up, I found the possibility of a phishing attack in one of the pages, specifically the error page in the application. The problem was user supplied content from the url paramater list was put directly into the error page, filtered only for XSS characters and the whitespace character.  In a normal scenario, user is redirected to the error page, resulting in:</p>
<pre class="brush: plain; wrap-lines: true">

http://securethoughts.com/security/phishinguserinput/error.cgi?url=/my_app_url&#038;user=jack
</pre>
<p><img src="http://securethoughts.com/security/phishinguserinput/f1.jpg"></p>
<p>Using URL encoding and the &#8216;%09&#8242; ASCII character (horizontal tab), I can phish a user to go evilsite.com. Evilsite.com will have the same inferface looks as the legitimate site and some users might unknowingly fall prey into typing their login credentials.</p>
<pre class="brush: plain; wrap-lines: true">

http://securethoughts.com/security/phishinguserinput/error.cgi?url=/my_app_url&#038;user=%2e%54%68%69%73%09%73%69%74%65%09%69%73%09%63%75%72%72%65%6e%74%6c%79%09%64%6f%77%6e%09%66%6f%72%09%6d%61%69%6e%74%65%6e%61%6e%63%65%2e%09%50%6c%65%61%73%65%09%75%73%65%09%65%76%69%6c%73%69%74%65%2e%63%6f%6d
</pre>
<p><img src="http://securethoughts.com/security/phishinguserinput/f0.jpg"></p>
<p>This class of phishing attack can apply to any page. It does not confine to error pages and is not blocked by filtering and encoding mechanisms. The only requirement is user&#8217;s language characters (including whitespace character like %09, %20, etc) should be injectable in the page output and the rendered page should sound convincing to phish a user into going to evil site. If the user is not convinced and types the domain name directly into the address bar, this attack will fail <img src='http://securethoughts.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> . </p>
<p>A solution to this issue is to use url encoding or html entities for all the special characters [not just XSS chars < > " '] before writing back user&#8217;s input data back to the browser. For links, using url encoding instead of html entities also protects from <a href="http://blog.mindedsecurity.com/search/label/Http%20Parameter%20Pollution">HTTP Parameter Pollution</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/03/phishing-with-non-scriptable-user-input/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Breaking the STEALTH myth of Desktop Locking Softwares</title>
		<link>http://securethoughts.com/2009/02/breaking-the-stealth-myth-of-desktop-locking-softwares/</link>
		<comments>http://securethoughts.com/2009/02/breaking-the-stealth-myth-of-desktop-locking-softwares/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 07:39:46 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[Auth(entication/orization)]]></category>
		<category><![CDATA[Exploits]]></category>
		<category><![CDATA[Information Gathering]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Direct Disk Access]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Folder Guard]]></category>
		<category><![CDATA[Locking Software]]></category>
		<category><![CDATA[WinHex]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=95</guid>
		<description><![CDATA[In this post, I will be talking about the security vulnerabilities in various desktop locking softwares such as Folder Guard, Lock Folder XP, etc. In fact, I will question their claims, one of which is given on their website as:
&#8220;You can even completely hide your private folders from virtually all applications, and such folders would [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, I will be talking about the security vulnerabilities in various desktop locking softwares such as Folder Guard, Lock Folder XP, etc. In fact, I will question their claims, one of which is given on their website as:</p>
<blockquote><p><em>&#8220;You can even completely hide your private folders from virtually all applications, and such folders would remain invisible until you enter a valid password.&#8221;</em></p></blockquote>
<p>Is this really true?? No, not at all. Let&#8217;s see how. Actually, my friend used one of these softwares and challenged me if I can expose his data without the password used to lock the data. So, I decided to give it a try.</p>
<p>I first downloaded and installed a trial copy of Folder Guard software on my computer. Then I created a folder named &#8220;mysecretfiles&#8221; inside directory &#8220;test&#8221; on G: drive. Then, I opened Folder Guard, created a login password and locked this folder. The configuration setting I used for this folder was Access = &#8220;No Access&#8221; and Visibility = &#8220;Hidden&#8221;. You should see a similar screenshot after you lock a folder.</p>
<p><img src="http://www.securethoughts.com/security/locksoftware/f1.jpg" alt="" /></p>
<p>I closed Folder Guard and clicked on &#8220;Yes&#8221; in the &#8220;Start Protecting the System&#8221; dialog box. This caused Folder Guard to enable protection on my folder. As a result, I didn&#8217;t see my locked folder in Windows Explorer.</p>
<p><img src="http://www.securethoughts.com/security/locksoftware/f2.jpg" alt="" /></p>
<p>I tried to understand how these softwares work. Almost all of them placed hooks into the windows device drivers and block access calls to locked files and folders. This model is flawed because an attacker can use the back channel, often referred to as <a href="http://support.microsoft.com/kb/100027">Direct Disk Access Mode</a>.</p>
<p>So, I decided to fire my favorite Disk Editor <a href="http://www.x-ways.net/winhex/">WinHex</a> and I could easily see and browse my locked folder with ease. I could look inside my locked file &#8220;mysensitivedata.txt&#8221; and check its contents with my username, password and SSN <img src='http://securethoughts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The other best part of this disk editor is that I don&#8217;t need to install it, I could just easily run it from a USB pen stick.</p>
<p><img src="http://www.securethoughts.com/security/locksoftware/f3.jpg" alt="" /></p>
<p>So, the best protection to protect your data is still to use industry standard encryption with algorithms such as AES, 3DES, etc. Even if the data falls in wrong hands, the confidentiality of the data won&#8217;t be compromised. Use softwares like TrueCrypt to protect your sensitive data.</p>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/02/breaking-the-stealth-myth-of-desktop-locking-softwares/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>All-In-One HTML + Javascript + CSS Formatter</title>
		<link>http://securethoughts.com/2009/01/all-in-one-html-javascript-css-formatter/</link>
		<comments>http://securethoughts.com/2009/01/all-in-one-html-javascript-css-formatter/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 07:27:04 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Beautifier]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Formatter]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=65</guid>
		<description><![CDATA[I do a lot of pen testing on web applications. From time to time, I have to analyze and understand how the web page code works. However, my task becomes complicated as web applications typically use some sort of source code compression. This makes it very hard to understand the code and hampers the readability [...]]]></description>
			<content:encoded><![CDATA[<p>I do a lot of pen testing on web applications. From time to time, I have to analyze and understand how the web page code works. However, my task becomes complicated as web applications typically use some sort of source code compression. This makes it very hard to understand the code and hampers the readability to a large extent.</p>
<p>A web page is composed of three major content types, namely HTML content, Javascript Code and CSS styling code. I felt the need of a tool that could beautify or format the entire web page source code. I use <a href="http://portswigger.net/suite/">Burp Suite</a>, my favorite web proxy tool. However, it does not have source code formatting feature, it just colors the web page by choosing different colors for html tag names, html attribute values, javascript, css, etc.</p>
<p>I looked on the internet for free alternatives, but I could not find free tools that could format the entire web page. Most of them could only format either one of HTML or Javascript or CSS. So, I decided to write a perl script myself. I used the libraries <a href="http://search.cpan.org/~petdance/HTML-Tidy-1.08/lib/HTML/Tidy.pm">HTML::Tidy</a> by <a href="http://tidy.sourceforge.net/">Dave Raggett</a> and <a href="http://search.cpan.org/dist/JavaScript-Beautifier/lib/JavaScript/Beautifier.pm">Javascript::Beautifier</a> by <a href="http://elfz.laacz.lv">Einars Lielmanis</a>. And I have written my own CSS formatting code.</p>
<p>Example of HTML Formatting</p>
<p><img src="http://www.securethoughts.com/security/formatter/f0.jpg" alt="" /></p>
<p>Example of CSS Formatting</p>
<p><img src="http://www.securethoughts.com/security/formatter/f1.jpg" alt="" /></p>
<p>Example of Javascript Formatting</p>
<p><img src="http://www.securethoughts.com/security/formatter/f2.jpg" alt="" /><br />
In addition, I have done one more improvement by formatting the javascript code in html event handlers. I picked the comprehensive event handlers list from <a href="http://www.amazon.com/XSS-Attacks-Scripting-Exploits-Defense/dp/1597491543/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1233211477&amp;sr=8-1">XSS Attacks Book</a> by <a href="http://ha.ckers.org">RSnake</a>, <a href="http://jeremiahgrossman.blogspot.com">Jeremiah</a>, <a href="http://www.gnucitizen.org">Pdp</a>, Anton Rager and Seth Fogie. Another excellent book to have on your shelf.</p>
<p>Example of Event Handler Code Formatting (see the onload and onclick event handlers)</p>
<p><img src="http://www.securethoughts.com/security/formatter/f3.jpg" alt="" /><br />
And finally the &#8230;</p>
<p><strong>Inferno&#8217;s All-In-One HTML + Javascript + CSS Formatter</strong><br />
Paste your Source Code below</p>
<form action="http://securethoughts.com/security/formatter/formatter.cgi" enctype="application/x-www-form-urlencoded" method="post"><textarea style="width: 100%;" cols="20" rows="15" name="htmlcontent"></textarea></p>
<input name="Submit" type="submit" value="Format the Source" /> </form>
<p>I would advise trying any of the search engines&#8217; source code like google, yahoo, etc. Their code is highly compressed. If you have any problem using the text box above, try using this <a href="http://securethoughts.com/security/formatter/formatter.html">Link</a>.</p>
<p>Plans for future additions include<br />
* Add custom event handlers and variables (e.g. expr variable in Samy Worm Code)<br />
* Javascript Deobfuscation<br />
* More configuration Options<br />
* Burp Proxy Plugin</p>
<p>Please provide your valuable suggestions to improve this tool. This tool is completely free for your use.</p>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/01/all-in-one-html-javascript-css-formatter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easy Server Side Fix for the GIFAR security issue</title>
		<link>http://securethoughts.com/2009/01/easy-server-side-fix-for-the-gifar-security-issue/</link>
		<comments>http://securethoughts.com/2009/01/easy-server-side-fix-for-the-gifar-security-issue/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 22:59:17 +0000</pubDate>
		<dc:creator>Inferno</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[WebAppSec]]></category>
		<category><![CDATA[XSS]]></category>
		<category><![CDATA[GIFAR]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Jar]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://securethoughts.com/?p=35</guid>
		<description><![CDATA[The GIFAR issue was found by security researchers Billy Rios and Nate Mcfeters. To summarize the exploit, an attacker uploads a malicious image with embedded jar content on a target domain. This malicious image opens in any image viewer correctly and so it bypasses any content validation engine used by a web application. Then an [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://xs-sniper.com/blog/2008/12/17/sun-fixes-gifars/">GIFAR issue</a> was found by security researchers <a href="http://xs-sniper.com/blog/">Billy Rios</a> and <a href="http://natemcfeters.blogspot.com">Nate Mcfeters</a>. To summarize the exploit, an attacker uploads a malicious image with embedded jar content on a target domain. This malicious image opens in any image viewer correctly and so it bypasses any content validation engine used by a web application. Then an attacker references this malicious image in the applet code on his or her evil site, establishing a cross-domain communication channel with the target domain. This attack is very serious because it breaks the <a href="http://www.mozilla.org/projects/security/components/jssec.html#sameorigin">Same Origin Policy</a> principle. Also, this problem is not just confined to images, it is applicable to other file types such as doc, etc. Another great writeup on Jar File Issues is on <a href="http://www.gnucitizen.org/blog/java-jar-attacks-and-features/">pdp&#8217;s blog</a>.</p>
<p>In Billy&#8217;s Blog, two solutions have been discussed :-</p>
<p><strong>Solution 1. Update to the latest version of JRE.</strong> This will protect you. However, if I am a web application writer, I cannot ensure that my customers will be protected. The reason is I cannot control the JRE version that my customers will be running on their client machines. The JRE updates don&#8217;t work like Windows Updates. So their obsolete JRE environments will not get automatically updated, which leaves them vulnerable to cross-domain exploits. So, Billy discusses another solution for the application writer.</p>
<p><strong>Solution 2. Serve user controlled files from a &#8220;throw away&#8221; domain.</strong> However, having a separate domain might not be feasible at all times, for reasons such as cost, management issues, etc.</p>
<p><strong>My Solution</strong>. This made me think of some solution that could help an application developer to filter malicious jar content on the server side. If the application is able to restrict the upload of malicious files, it solves the problem on the server side without worrying about which version of JRE the client is running. I found the api <strong>JarFile</strong> in Java library <strong>java.util.jar</strong> to be extremely useful. It takes as input a file parameter, and returns a JarFile object if the input file has jar content. Otherwise, it raises a <strong>java.util.zip.ZipException</strong> exception.</p>
<p>I have constructed Proof of Concept code that tests a input file for malicious jar content.</p>
<pre class="brush: java; wrap-lines: true">
import java.io.*;
import java.util.*;
import java.util.jar.*;

public class DetectGIFAR {
    public static void main (String args[])
         throws IOException {

		if(args.length != 1)
		{
			System.out.println("Usage: java DetectGIFAR image_file");
			System.exit(1);
		}

		try
		{
			JarFile jarFile = new JarFile(args[0]);
			System.out.println("This is a malicious image with embedded jar content.\nFollowing are the contents:-");
			Enumeration jarenum = jarFile.entries();
			while (jarenum.hasMoreElements()) {
				JarEntry jarent = (JarEntry) jarenum.nextElement();
				System.out.println(jarent.getName() + ", " + jarent.getSize() + " bytes");
			}
		}
		catch(java.util.zip.ZipException e)
		{
			System.out.println("This is a benign image file. No jar content detected.");
			System.exit(0);
		}
		catch (Exception e)
		{
			System.out.println("Error occured. Unable to process GIFAR contents.");
		}
	}
}</pre>
<p><a href="http://securethoughts.com/security/gifar/DetectGIFAR.java">DetectGIFAR.java</a>, <a href="http://securethoughts.com/security/gifar/DetectGIFAR.class">DetectGIFAR.class</a>, <a href="http://securethoughts.com/security/gifar/titanic.gif">titanic.gif</a>, <a href="http://securethoughts.com/security/gifar/evil.gif">evil.gif</a></p>
<p>Below is sample output</p>
<p><img src="http://securethoughts.com/security/gifar/gifartest.JPG" alt="" /></p>
<p>And if you are new to the GIFAR exploit, below is example html applet code that loads a malicious gif hosted on my domain. You need to have the vulnerable JRE 1.6 update 10 or lower to see this applet running. You can play with this applet by typing anywhere inside it <img src='http://securethoughts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Let me know your thoughts and opinions on this server side fix. I am always open for discussions.</p>
]]></content:encoded>
			<wfw:commentRss>http://securethoughts.com/2009/01/easy-server-side-fix-for-the-gifar-security-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
