<?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>troubleshooting &#8211; Fredrik Holmberg</title>
	<atom:link href="/tag/troubleshooting/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Network Consultant</description>
	<lastBuildDate>Thu, 10 Nov 2016 19:39:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.7.3</generator>

<image>
	<url>/wp-content/uploads/2016/04/cropped-2601-32x32.png</url>
	<title>troubleshooting &#8211; Fredrik Holmberg</title>
	<link>/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>App troubleshooting using Wireshark</title>
		<link>/2016/05/app-troubleshooting-using-wireshark/</link>
		<comments>/2016/05/app-troubleshooting-using-wireshark/#respond</comments>
		<pubDate>Wed, 25 May 2016 13:43:13 +0000</pubDate>
		<dc:creator><![CDATA[Fredrik Holmberg]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[tls]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[wireshark]]></category>

		<guid isPermaLink="false">/?p=261</guid>
		<description><![CDATA[Remember those glory days when phones still had buttons? Before the selfie stick era. I used my phone to send SMS messages and call people. Browse the internet using WAP. Send a hi-def 320x240px picture now and then using MMS. The only pieces of software I had to deal with were the pre-installed stock applications (renamed [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Remember those glory days when phones still had buttons? Before the selfie stick era. I used my phone to send SMS messages and call people. Browse the internet using <a href="https://en.wikipedia.org/wiki/Wireless_Application_Protocol">WAP</a>. Send a hi-def 320x240px picture now and then using MMS. The only pieces of software I had to deal with were the pre-installed stock applications (renamed to &#8220;apps&#8221; by Apple in 2008). All other internet activities had to be done on a computer.</p>
<p>Today, the phone is a touch screen that allow you to interact with apps. Everything is done through apps. We use them to buy tickets, share pictures with grandparents, access our bank account, post a picture of today&#8217;s dinner. So what happens when your favorite app stops working all of a sudden? How do you troubleshoot it?</p>
<p><span id="more-261"></span></p>
<p>Once I had an issue with a banking app on my iPhone. After upgrading to iOS 9, logging in using two-factor authentication stopped working. It had persisted for several months and when I asked the company I got the default reply that &#8220;it&#8217;s a known issue and the developers are working a fix&#8221;. Ok great.</p>
<p>This is what greeted me when I tried logging in:</p>
<p><img class="aligncenter wp-image-266" src="/wp-content/uploads/2016/05/err2-169x300.png" alt="err2" width="282" height="500" srcset="/wp-content/uploads/2016/05/err2-169x300.png 169w, /wp-content/uploads/2016/05/err2-577x1024.png 577w, /wp-content/uploads/2016/05/err2.png 640w" sizes="(max-width: 282px) 100vw, 282px" /></p>
<p>You could sit and look at that white square for as long as you wanted. Nothing would happen. No error message or <a href="https://en.wikipedia.org/wiki/Spinning_pinwheel">spinning beach ball</a>.</p>
<h3>Cursed app</h3>
<p>So then I decided to troubleshoot it myself. The same way I troubleshoot applications <a href="/consulting/">professionally</a>. Not the developer way of debugging through Xcode. The network engineer way by looking at packets. Shouldn&#8217;t be too hard, right? <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f4aa.png" alt="💪" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Two hurdles:</p>
<ol>
<li>The app was on my iPhone which meant wireless communication.</li>
<li>The communication was likely using an encrypted channel making eavesdropping impossible*.</li>
</ol>
<p><em>* No, nothing is impossible. You can use <a href="https://mitmproxy.org/">mitmproxy</a> or similar tools.</em></p>
<p>Using a <a href="http://routerboard.com/RB750GL">Mikrotik RB750GL</a> I mirrored all traffic sent and received from my iPhone to my laptop. Got Wireshark up and running hoping to find something that indicated an error.</p>
<p>Filtering the output down to the exact moment when I tapped &#8220;Login&#8221; and the two-factor module was supposed to load:</p>
<p><img class="alignnone size-full wp-image-271" src="/wp-content/uploads/2016/05/err3.png" alt="err3" width="1098" height="251" srcset="/wp-content/uploads/2016/05/err3.png 1098w, /wp-content/uploads/2016/05/err3-300x69.png 300w, /wp-content/uploads/2016/05/err3-768x176.png 768w, /wp-content/uploads/2016/05/err3-1024x234.png 1024w, /wp-content/uploads/2016/05/err3-676x155.png 676w" sizes="(max-width: 1098px) 100vw, 1098px" /></p>
<p>Lots of weird text. Don&#8217;t give up just yet.</p>
<p>There&#8217;s a clue here! On line <strong>#6</strong>, Wireshark is trying to help us by showing an error message &#8220;Handshake Failure&#8221;. A fatal alert. That can&#8217;t be good.</p>
<p>Following the TLS handshake failure the server tears down the TCP connection. Nothing happens in the app UI. So much for error handling.</p>
<p>More on Transport Layer Security (TLS) Protocol Version 1.2 Handshakes <a href="https://tools.ietf.org/html/rfc5246#section-7.3">https://tools.ietf.org/html/rfc5246#section-7.3</a>.</p>
<h3>Failing handshakes</h3>
<p>What does this mean? It means that the client is sending something that the server does not agree with.</p>
<p>Then I compared the authentication and handshake mechanism with another banking app. One that worked. It turned out that the two were sending two different cipher suites in their <a href="https://tools.ietf.org/html/rfc5246#section-7.4.1.2">Client Hello</a>:</p>
<p><strong>Failing app (12 ciphers)</strong></p>
<pre><code>TLS_EMPTY_RENEGOTIATION_INFO_SCSV
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA</code></pre>
<p><strong>Working app (same 12 ciphers + 6 additional)</strong></p>
<pre><code>TLS_EMPTY_RENEGOTIATION_INFO_SCSV
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_AES_256_GCM_SHA384
TLS_RSA_WITH_AES_128_GCM_SHA256
TLS_RSA_WITH_AES_256_CBC_SHA256
TLS_RSA_WITH_AES_256_CBC_SHA
TLS_RSA_WITH_AES_128_CBC_SHA256
TLS_RSA_WITH_AES_128_CBC_SHA</code></pre>
<p>The cipher chosen for the working app was &#8220;TLS_RSA_WITH_AES_256_CBC_SHA&#8221;.</p>
<p>After some research I learned that Apple introduced a new security feature in iOS 9 called <a href="https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html">App Transport Security (ATS)</a>. Even though it killed my app it&#8217;s a great feature forcing the use of Transport Layer Security (TLS) version 1.2, better ciphers, forward secrecy (FS) among other things.</p>
<p>So the theory now was:</p>
<blockquote><p>&#8220;after upgrading to iOS 9 the client is sending ciphers unsupported by the server&#8221;</p></blockquote>
<p>Every theory should be tested so I decided to use the excellent <a href="https://www.ssllabs.com/ssltest/">Qualys SSL Labs SSL Report tool</a>.</p>
<p>Lo and behold, both server endpoints got a grade of <strong>C</strong> because of two things:</p>
<ol>
<li>&#8220;No support for TLS 1.2, which is the only secure protocol version.&#8221;</li>
<li>&#8220;Handshake Simulation: Apple ATS 9 / iOS 9 &#8211; Protocol or cipher suite mismatch &#8211; Fail&#8221;</li>
</ol>
<p>I got the same results using <strong>nscurl</strong> showing that TLS 1.0 was the only supported version:</p>
<blockquote>
<pre><strong>$ /usr/bin/nscurl --ats-diagnostics --verbose https://login.bank.com/"
</strong>
TLSv1.0 with PFS disabled
ATS Dictionary:
{
    NSExceptionDomains =     {
        "login.bank.com" =         {
            NSExceptionMinimumTLSVersion = "TLSv1.0";
            NSExceptionRequiresForwardSecrecy = false;
        };
    };
}
Result : PASS
</pre>
</blockquote>
<p>&nbsp;</p>
<h3>Show me the fix</h3>
<p>The problem had two possible solutions:</p>
<ul>
<li>Enable support of TLS 1.2 and Apple ATS 9 handshakes on the server side &#8211; GOOD</li>
<li>Offer ciphers outside of the Apple ATS 9 scope on the client side &#8211; BAD</li>
</ul>
<p>Based on my findings the app was updated to version 4.1.0 &#8220;authorisation issue on iOS 9 for Norwegian region&#8221;.</p>
<p>Checked again today to see what had changed:</p>
<ul>
<li>The client is now sending 22 ciphers instead of the ATS 9 default of 12.</li>
<li>The server side now get a rating of A and B by Qualys. TLS 1.2 is now supported. Apple ATS 9 is still unsupported.</li>
</ul>
<p>The world is not perfect, but we&#8217;re getting there. Bit by bit <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f4c8.png" alt="📈" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>If you are looking for a troubleshooting expert, have a look at my <a href="/consulting/">Consulting Services</a>.</p>
<p>Have a nice day!</p>
]]></content:encoded>
			<wfw:commentRss>/2016/05/app-troubleshooting-using-wireshark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
