<?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; tlslite</title>
	<atom:link href="http://www.exploresecurity.com/tag/tlslite/feed/" rel="self" type="application/rss+xml" />
	<link>http://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>Testing for POODLE_TLS Manually</title>
		<link>http://www.exploresecurity.com/testing-for-poodle_tls-manually/</link>
		<comments>http://www.exploresecurity.com/testing-for-poodle_tls-manually/#comments</comments>
		<pubDate>Fri, 13 Mar 2015 12:25:24 +0000</pubDate>
		<dc:creator>Jerome</dc:creator>
				<category><![CDATA[SSL/TLS]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[penetration testing]]></category>
		<category><![CDATA[POODLE]]></category>
		<category><![CDATA[TLS]]></category>
		<category><![CDATA[tlslite]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.exploresecurity.com/?p=362</guid>
		<description><![CDATA[Testing for the original POODLE vulnerability was easy because it was an inherent problem with SSLv3, so if you find SSLv3 enabled then you&#8217;ve found POODLE (although other factors such as cipher suite preference have a role to play &#8211; see my previous post). Like Heartbleed, though, testing for POODLE over TLS is conceptually easy [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Testing for the original POODLE vulnerability was easy because it was an inherent problem with SSLv3, so if you find SSLv3 enabled then you&#8217;ve found POODLE (although other factors such as cipher suite preference have a role to play &#8211; see my previous <a title="Thoughts on Testing for POODLE" href="http://www.exploresecurity.com/thoughts-on-testing-for-poodle/">post</a>). Like Heartbleed, though, testing for POODLE <em>over TLS</em> is conceptually easy but it falls within a class of flaws that requires bespoke tools as an unpatched version of <code>openssl</code>, for example, won&#8217;t do what you want it to do. This article discusses how the Python <em>tlslite</em> library can be used to test for POODLE_TLS &#8211; and so much more.<span id="more-362"></span></p>
<h3>What is <em>tlslite</em>?</h3>
<p>From the <a href="https://github.com/trevp/tlslite">source</a> &#8220;TLS Lite is an open source python library that implements SSL and TLS&#8221;. I&#8217;d seen references to it in the original BEAST <a href="http://vnhacker.blogspot.co.uk/2011/09/beast.html">post</a> written by Thai Duong and an article on <a href="https://vivaldi.net/blogs/entry/what-is-tls-testing-tlsprober-net">TLS Prober</a> by Yngve Pettersen. This gave me some confidence that <em>tlslite</em> would be a good starting point. Obviously it&#8217;s not going to be fast but that doesn&#8217;t matter. With a SSL/TLS implementation in a high level language, it would be much easier to make the changes required for the sorts of tests I wanted to run, and I thought POODLE_TLS would be a good one to try first.</p>
<p>TLS Prober is in fact where I wanted to be heading. It works on a modified version of <em>tlslite</em> to test for various SSL/TLS bugs. However, the public source code hasn&#8217;t been updated since Yngve left Opera in 2013 and thus wouldn&#8217;t cover POODLE_TLS. While I could have added that capability, I decided to ignore TLS Prober (for now) and start afresh with the latest <em>tlslite</em> &#8211; mainly as it would be a good learning experience.</p>
<h3>How to test for POODLE_TLS</h3>
<p>I&#8217;m not going to re-hash theory that&#8217;s already <a href="https://www.imperialviolet.org/2014/10/14/poodle.html">covered</a> <a href="https://www.imperialviolet.org/2014/12/08/poodleagain.html">elsewhere</a>. Suffice to say that implementations of TLS that are faithful to the RFC shouldn&#8217;t be vulnerable to POODLE because the spec states what the contents of the padding bytes should be. Therefore, the way to test for POODLE_TLS is to ignore that rule and see if the connection is terminated by the server. This isn&#8217;t the same as performing a full attack but like all testing you have to compromise between accuracy and aggressiveness. I think this test is a good indication. After some rummaging through the source code and a bit of debugging, I found what I wanted.</p>
<h3>Changes to <em>tlslite</em></h3>
<p>It seemed a bit crazy to fork the <a href="https://github.com/trevp/tlslite">original project</a> as my changes were tiny. I also thought that working through the changes here may be helpful to anyone else who wants to do the same sort of thing.</p>
<p>So to begin with I needed to signal to <em>tlslite</em> that I wanted to send TLS messages with invalid padding. You get things going with <em>tlslite</em> through the <code>TLSConnection</code> class so I changed how that was instantiated. <code>TLSConnection</code> inherits from <code>TLSRecordLayer</code>, which is where the padding code lives, so that needed changing too. Within the &#8220;tlslite&#8221; folder I made the following changes (obviously line numbers will be version dependent so I&#8217;ve added the original code too; my version was 0.4.8):</p>
<p><strong>tlsconnection.py</strong><br />
Line 52 was:<br />
<code>def __init__(self, sock):</code><br />
Now:<br />
<code>def __init__(self, sock, check_poodle_tls=False):</code><br />
# now i can signal whether or not I want to perform the test<br />
# if you already have <em>tlslite</em>, you can change it safely because <code>check_poodle_tls</code> defaults to <code>False</code> so it&#8217;s backward-compatible with any existing code that makes use of <em>tlslite</em></p>
<p>Line 61 was:<br />
<code>TLSRecordLayer.__init__(self, sock)</code><br />
Now:<br />
<code>TLSRecordLayer.__init__(self, sock, check_poodle_tls)</code><br />
# I need to pass that signal on to the parent</p>
<p><strong>tlsrecordlayer.py</strong><br />
Line 102 was:<br />
<code>def __init__(self, sock):</code><br />
Now:<br />
<code>def __init__(self, sock, check_poodle_tls):</code></p>
<p>After line 103 <code>self.sock = sock</code> added new line:<br />
<code>self.check_poodle_tls = check_poodle_tls</code></p>
<p>After line 600 <code>paddingBytes = bytearray([paddingLength] * (paddingLength+1))</code> added new lines:<br />
<code>if self.check_poodle_tls == True:<br />
<span style="padding-left: 30px;">paddingBytes = bytearray(x ^ 42 for x in paddingBytes[0:-1])</span><br />
<span style="padding-left: 30px;">paddingBytes.append(paddingLength)</span></code><br />
# change all but the last of the padding bytes to be invalid (just XOR with 42, the answer to everything)<br />
# make the last byte of padding valid = the number of padding bytes</p>
<p>And that&#8217;s it! Remember, as it&#8217;s Python, that tabs are important and the new code needs to be properly aligned.</p>
<h3>POODLE_TLS test script</h3>
<p>I then created the test script (available <a href="https://github.com/exploresecurity/test_poodle_tls">here</a>), which attempts a normal TLS connection first before testing for POODLE using the invalid padding trick. Place the script within the modified <em>tlslite</em> and run it as <code>test_poodle_tls.py &lt;hostname&gt;</code>. Remember, it only tests for POODLE <em>over TLS, <u>not</u> SSLv3.</em></p>
<p>I&#8217;ve noticed that sometimes the normal connection fails and one of the reasons for this is that the server does not support any of the small number of cipher suites offered by <em>tlslite</em>. In this case no conclusion can be drawn &#8211; and the script catches that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.exploresecurity.com/testing-for-poodle_tls-manually/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
