<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Fuzzing on yomimono - something to read</title>
    <link>http://localhost:1313/tags/fuzzing/</link>
    <description>Recent content in Fuzzing on yomimono - something to read</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 17 Apr 2018 18:00:00 +0000</lastBuildDate>
    <atom:link href="http://localhost:1313/tags/fuzzing/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Whacking the Bitcoin Piñata</title>
      <link>http://localhost:1313/blog/2018/04/17/whacking-the-bitcoin-pinata/</link>
      <pubDate>Tue, 17 Apr 2018 18:00:00 +0000</pubDate>
      <guid>http://localhost:1313/blog/2018/04/17/whacking-the-bitcoin-pinata/</guid>
      <description>&lt;blockquote&gt;&#xA;&lt;p&gt;@yomimono or @hannesm surely know if people have tried crowbar on the BTC Piñata.&#xA;&amp;ndash; &lt;a href=&#34;https://mastodon.social/@Kensan/99536958321475407/&#34;&gt;@kensan@mastodon.social&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;tl;dr - &lt;a href=&#34;https://github.com/yomimono/ocaml-test-x509&#34;&gt;yes&lt;/a&gt;, and it seems that ocaml-x509 is not trivially easy to trick.&lt;/p&gt;&#xA;&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;&#xA;&lt;h3 id=&#34;the-bitcoin-piñata&#34;&gt;The Bitcoin Piñata&lt;/h3&gt;&#xA;&lt;p&gt;In 2015 David Kaloper-Mersinjak and Hannes Mehnert released &lt;a href=&#34;https://github.com/mirleft/ocaml-tls&#34;&gt;ocaml-tls&lt;/a&gt;, an implementation of TLS (formerly known as SSL) written fully in OCaml.  A full writeup of the stack is available in their &lt;a href=&#34;https://usenix15.nqsb.io/&#34;&gt;Usenix Security 2015 paper&lt;/a&gt;, and as &lt;a href=&#34;https://mirage.io/blog/announcing-mirage-25-release&#34;&gt;a series of blog posts on mirage.io&lt;/a&gt;.  To accompany the release they also deployed a fully-automated bug bounty for the security stack &amp;ndash; the &lt;a href=&#34;https://ownme.ipredator.se&#34;&gt;bitcoin piñata&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The piñata will establish TLS connections only with endpoints presenting a certificate signed by its own, undisclosed certificate authority, but allows an attacker to easily listen to the encrypted traffic.  The piñata always sends the same plaintext in such a connection: the private key to a wallet containing approximately 10 bitcoin.  If the attacker can decrypt the ciphertext, or trick the piñata into negotiating a TLS connection with another host and disclosing the key, the information (and therefore the money) is theirs.&lt;/p&gt;&#xA;&lt;h3 id=&#34;crowbar&#34;&gt;Crowbar&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/stedolan/crowbar&#34;&gt;Crowbar&lt;/a&gt; is a library for writing tests.  It combines a property-based API (like QuickCheck) with a coverage-driven generator of test cases (like the fuzzer American Fuzzy Lop).  Crowbar tries to find counterexamples to stated properties by prioritizing the generation of test cases which touch more code.  It is &lt;a href=&#34;https://github.com/stedolan/crowbar/issues/2&#34;&gt;very good at finding counterexamples&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;testing-ocaml-x509&#34;&gt;Testing ocaml-x509&lt;/h2&gt;&#xA;&lt;p&gt;TLS connections are usually authenticated via X509 certificates.  ocaml-tls uses &lt;a href=&#34;https://github.com/mirleft/ocaml-x509&#34;&gt;ocaml-x509&lt;/a&gt; for this purpose, which is written as a standalone library.  There is a clear separation of concerns between ocaml-x509 and ocaml-tls, and a straightforward API for certificate operations in ocaml-x509; both features help tremendously in writing tests for certificate handling.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Posts and Talks Elsewhere</title>
      <link>http://localhost:1313/blog/2017/12/23/posts-talks-2017/</link>
      <pubDate>Sat, 23 Dec 2017 18:00:00 +0000</pubDate>
      <guid>http://localhost:1313/blog/2017/12/23/posts-talks-2017/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve done a lot of stuff in the last half of 2017, but not much of it has made it here.  Here&amp;rsquo;s a roundup of things published/spoken/embroidered/etc in other places:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Crowbar Your Favorite Library for Fun and Bugfixes</title>
      <link>http://localhost:1313/blog/2017/04/26/crowbar-dhcp/</link>
      <pubDate>Wed, 26 Apr 2017 03:14:49 +0000</pubDate>
      <guid>http://localhost:1313/blog/2017/04/26/crowbar-dhcp/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/stedolan/crowbar&#34;&gt;Crowbar&lt;/a&gt; is a tool that combines &lt;a href=&#34;https://github.com/stedolan/ocaml-afl-persistent&#34;&gt;afl-persistent&lt;/a&gt;&amp;rsquo;s instrumentation with &lt;a href=&#34;https://github.com/c-cube/qcheck&#34;&gt;quickcheck&lt;/a&gt;-like property-based testing.  &lt;a href=&#34;http://lcamtuf.coredump.cx/afl&#34;&gt;afl-fuzz&lt;/a&gt; is a great tool for detecting crashes, but Crowbar helps us go a step farther and automatically discover inputs which cause our program to no longer have the properties we expect it to have.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/linuxkit/linuxkit/blob/master/projects/miragesdk/why-dhcp.md&#34;&gt;For reasons that don&amp;rsquo;t need exploring at this juncture&lt;/a&gt;, I first thought to apply Crowbar to &lt;a href=&#34;https://github.com/yomimono/charrua-client&#34;&gt;charrua-client&lt;/a&gt;, a library which implements &lt;a href=&#34;http://www.tcpipguide.com/free/t_TCPIPDynamicHostConfigurationProtocolDHCP.htm&#34;&gt;the DHCP state machine&lt;/a&gt; from a client perspective.  Code snippets below are taken from &lt;a href=&#34;https://github.com/yomimono/somerandompacket/tree/master/dhcp&#34;&gt;the dhcp directory in my somerandompacket repository on GitHub&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Parsers Optional</title>
      <link>http://localhost:1313/blog/2014/07/07/parsers-optional/</link>
      <pubDate>Mon, 07 Jul 2014 12:49:38 +0000</pubDate>
      <guid>http://localhost:1313/blog/2014/07/07/parsers-optional/</guid>
      <description>&lt;p&gt;Friends, I have spoken to you of &lt;a href=&#34;http://localhost:1313/blog/2014/06/03/the-minnesota-goodbye/&#34;&gt;TCP&lt;/a&gt; and of &lt;a href=&#34;http://localhost:1313/blog/2014/05/22/throwing-some-fuzzy-dice/&#34;&gt;fuzzing&lt;/a&gt;.  Next I will speak to you of both, but today, I will speak to you of TCP options.  If you&amp;rsquo;re here for the pwnage, sit tight; it&amp;rsquo;s coming.&lt;/p&gt;&#xA;&lt;h3 id=&#34;what-even-is-tcp-anyway&#34;&gt;What Even Is TCP Anyway&lt;/h3&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s the lazy way of explaining it: TCP is the abstraction layer that allows you to pretend that network communication works in a logical, orderly, reliable fashion when you&amp;rsquo;re writing an application.  Reading data and having it always be in the order it was sent?  TCP.  Being able to know whether a connection is open or closed?  TCP.  Knowing the difference between data coming from two separate processes on the same remote host?  TCP.  (There are other ways to get these guarantees, but the vast majority of Internet traffic that needs them gets them via TCP.)&lt;/p&gt;&#xA;&lt;p&gt;On a less abstract level, TCP is a header (one of several!) that your operating system slaps on your network traffic before shipping it over the wire, on the way to its final destination.  For damn near all the information on TCP you can shake a stick at, you can consult &lt;a href=&#34;http://www.rfc-editor.org/rfc/rfc793.txt&#34;&gt;RFC 793&lt;/a&gt; directly.  The header summary, most relevant for our exploration, is reproduced below:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;0                   1                   2                   3   &#xA;0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 &#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;|          Source Port          |       Destination Port        |&#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;|                        Sequence Number                        |&#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;|                    Acknowledgment Number                      |&#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;|  Data |           |U|A|P|R|S|F|                               |&#xA;| Offset| Reserved  |R|C|S|S|Y|I|            Window             |&#xA;|       |           |G|K|H|T|N|N|                               |&#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;|           Checksum            |         Urgent Pointer        |&#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;|                    Options                    |    Padding    |&#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;|                             data                              |&#xA;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Everything here is a fixed-length field except for &lt;code&gt;Options&lt;/code&gt;, &lt;code&gt;Padding&lt;/code&gt;, and &lt;code&gt;data&lt;/code&gt;, all of which are optional.  &lt;code&gt;Data&lt;/code&gt; is up to the application, when it&amp;rsquo;s present (and is also frequently referred to as &lt;code&gt;payload&lt;/code&gt;).  When you loaded this web page, TCP packets were sent from my server at &lt;code&gt;somerandomidiot.com&lt;/code&gt; to your computer, and the contents of the &lt;code&gt;data&lt;/code&gt; field were these very words that you&amp;rsquo;re reading right now.  TCP is &lt;code&gt;data&lt;/code&gt;-agnostic; it only cares that your payload arrives intact, not what&amp;rsquo;s in it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Options&lt;/code&gt;, on the other hand, are very much TCP&amp;rsquo;s concern.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Throwing Some Fuzzy Dice</title>
      <link>http://localhost:1313/blog/2014/05/22/throwing-some-fuzzy-dice/</link>
      <pubDate>Thu, 22 May 2014 10:42:56 +0000</pubDate>
      <guid>http://localhost:1313/blog/2014/05/22/throwing-some-fuzzy-dice/</guid>
      <description>&lt;p&gt;I mentioned &lt;a href=&#34;http://localhost:1313/blog/2014/04/23/verb-your-own-noun/index.html&#34;&gt;a while ago&lt;/a&gt; that the &lt;a href=&#34;http://www.openmirage.org&#34;&gt;Mirage project&lt;/a&gt; agreed to have me on board, through the &lt;a href=&#34;https://opw.gnome.org&#34;&gt;OPW internship project&lt;/a&gt;, for the summer.  We started on Monday, and I&amp;rsquo;ve already had a lot of fun!&lt;/p&gt;&#xA;&lt;p&gt;Officially, my job for the summer is to help shore up the network stack in Mirage, in part by running the current code through its paces, and in part through implementing some new functionality.  This first week, I continued some work I started at the end of Hacker School - figuring out how to fuzz some strange (and not-so-strange) corners, and how to wrangle the data I got out of doing so.&lt;/p&gt;&#xA;&lt;h2 id=&#34;fuzz-what-now&#34;&gt;Fuzz What Now?&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s step back.  Way, way, way back.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re a computer program, and you have some data that you care about, your data is likely in some kind of structure reflecting an underlying order to that data.  Objects are a common way to organize this stuff; dictionaries, hashmaps, lists, arrays, trees, the list goes on.  That&amp;rsquo;s all well and good when your program is running, keeping all this stuff in memory.  But it happens depressingly often that you need to dump this stuff to permanent storage, or express it in some way to some other program or another computer, or represent it on the screen because something awful has happened, and you can&amp;rsquo;t just say &amp;ldquo;&lt;code&gt;memory address 0x52413abd&lt;/code&gt;, &lt;code&gt;memory address 0x52413cda&lt;/code&gt;, &lt;code&gt;memory address 0x52413ea2&lt;/code&gt;&amp;rdquo; - these things are meaningless outside the context of the current run of that program.&lt;/p&gt;&#xA;&lt;p&gt;So we have &lt;a href=&#34;https://en.wikipedia.org/wiki/Serialization&#34;&gt;serialization&lt;/a&gt;, the high-level concept for the jillion different ways to take that data and put it in a string, or a binary data format, so something else can read that string and reassemble the structure of the data.  That&amp;rsquo;s deserialization, which implies parsing; parsing is &lt;a href=&#34;https://en.wikipedia.org/wiki/Abstract_syntax_tree&#34;&gt;a pretty big deal&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;When the data you&amp;rsquo;re attempting to assemble into a structure is as you expect it and everything is correct, parsing&amp;rsquo;s no problem.  But it frequently happens that everything is not as you expect it, for any number of reasons - the programmer who made the program that made the message made a mistake; the programmer who made the program that reads the message made a mistake; the programs reading and writing the message are using different versions of the specification in the first place; the specification wasn&amp;rsquo;t specific about whether the third byte&amp;rsquo;s range from 0 to 5 was inclusive or exclusive and each programmer made a different decision; both programs agree, but the message was corrupted in transit; the message was corrupted in transit, and one program has implemented a different corruption recovery algorithm than the other&amp;hellip; I&amp;rsquo;ll stop now, but I could keep going for a long time.&lt;/p&gt;&#xA;&lt;p&gt;There are a lot of bad messages out there.  It&amp;rsquo;s hard to make your parser do the right thing when it receives an arbitrary bad message.  It can be hard to even know that your parser does the &lt;em&gt;wrong&lt;/em&gt; thing when it receives an arbitrary bad message - if you thought of a certain kind of bad message to use in testing, of course you fixed your code to deal with it; you thought of it!  But there are almost certainly loads more bad messages out there than the ones you thought of - both by chance, and &lt;a href=&#34;http://insecure.org/sploits/ping-o-death.html&#34;&gt;by design&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If humans can&amp;rsquo;t make enough bad messages, maybe computers can.  Randomly generating a whole mess of bad messages, sending them to your program, and seeing what happens is called fuzz testing, and it&amp;rsquo;s awesome.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
