<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>bert hubert finally blogs: Holy cow! 1.3 million additional IP addresses served by PowerDNS</title>
    <link>http://blog.netherlabs.nl/articles/2006/04/14/holy-cow-1-3-million-additional-ip-addresses-served-by-powerdns</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>code, musings and more</description>
    <item>
      <title>Holy cow! 1.3 million additional IP addresses served by PowerDNS</title>
      <description>&lt;p&gt;Went for dinner yesterday with a friend of mine at one of the &lt;a href="http://www.iens.nl/english/restaurantsIn/DenHaag/restaurant.htms?a=Delft&amp;amp;k=26&amp;amp;r=3190"&gt;Indian restaurants&lt;/a&gt; here in Delft. This place is marvelous. It has had a non-working phone number listed on its window for the past 8 years. The music is probably not agreeable even for people from India. The beer tends to taste a bit funny. The entrance is dark, and looks like it has been burgled repeatedly. The staff is clumsy. But the food! Oh my.&lt;/p&gt;

&lt;p&gt;Ate too much and went home a bit sleepy.&lt;/p&gt;

&lt;h2&gt;Surprise email&lt;/h2&gt;

&lt;p&gt;One of the interesting bits about authoring an open source program is that you know both a lot and nearly nothing about your customers. Sometimes PowerDNS users share everything with me and other developers. I&amp;#8217;ve been mailed more root passwords than I care to remember (I have a fully functioning PGP key btw, please use it if you trust me with passwords!).&lt;/p&gt;

&lt;p&gt;On the other hand, there are a lot of &amp;#8216;stealth users&amp;#8217; who don&amp;#8217;t come out of the closet. I tend to hear from them only if they hit a problem - which is rare. &lt;/p&gt;

&lt;p&gt;So imagine my surprise yesterday when one of the larger access providers in Europe, with a double digit market share in their large country, suddenly announced they&amp;#8217;d switched all their nameservers to PowerDNS. 1.3 million additional homes served by my humble code.&lt;/p&gt;

&lt;p&gt;I can tell you, that rattles me. Especially since DNS is absolutely 100% vital to using the internet. &lt;/p&gt;

&lt;p&gt;So, that inspired me to take the last step in attempting to make PowerDNS the best recursor on the planet.&lt;/p&gt;

&lt;h2&gt;Spoofing&lt;/h2&gt;

&lt;p&gt;If you can fool DNS, you can fool a user. DNS is the phone book of the internet, if you manage to give out false data, browsers will head to the wrong servers. Same goes for email. All very bad.&lt;/p&gt;

&lt;p&gt;The worse news is that DNS is a breeze to &amp;#8220;spoof&amp;#8221;, in other words, it is easy to slip in bad data. I set up a somewhat contrived network here today and I was able to spoof both BIND 9 and PowerDNS in less than two seconds. I must admit that the conditions I tested under were highly ideal, but nothing that can&amp;#8217;t be achieved in the real world with concerted effort. &lt;/p&gt;

&lt;p&gt;And given the huge number of people I now feel responsible for, this is unacceptable. &lt;/p&gt;

&lt;p&gt;One of the brightest people I know, &lt;a href="http://cr.yp.to"&gt;Dan J. Bernstein&lt;/a&gt;, also writes &lt;a href="http://cr.yp.to/djbdns.html"&gt;nameservers&lt;/a&gt;. He can be very stubborn and opinionated, but some of his ideas are first rate. You have him to thank (in part) for today&amp;#8217;s &lt;a href="http://cr.yp.to/export.html"&gt;more liberal&lt;/a&gt; cryptography research climate as well. So, I took a lot of inspiration from his work. Read more below. &lt;/p&gt;

&lt;p&gt;To spoof a nameserver, one needs to know three things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Which questions the target nameserver (&amp;#8216;spoofee&amp;#8217;) is asking&lt;/li&gt;
&lt;li&gt;The exact network end-point it is expecting answers on&lt;/li&gt;
&lt;li&gt;The 16-bit ID of the question&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can generally figure out 1) pretty easily, especially if you can force a nameserver to make queries. 2) is easy if the network end-point doesn&amp;#8217;t change. 3) can be dealt with by scanning all 65536 ids.&lt;/p&gt;

&lt;p&gt;I reduced all three factors today:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I made the &lt;a href="http://wiki.powerdns.com/projects/trac/changeset/697"&gt;PowerDNS recursor default to not accepting questions from the internet at large&lt;/a&gt;. This reduces the chances of a spoofer to force questions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I copied Dan J. Bernsteins system of using a new random network end-point for each question, which means you&amp;#8217;ll have to try to guess this end-point too, just like you have to guess the ID. This does put a heavy load on the OS as we now have to listen to perhaps thousands of ports! So I made this optional, but on by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the recursor sees more than 20 failed guesses for the ID, it considers the whole query timed out. I spent a heap of time thinking &lt;a href="http://wiki.powerdns.com/projects/trac/changeset/699"&gt;how to do this elegantly&lt;/a&gt;, I had to lie down at one point and close my eyes briefly. This may look like a sinful mid-day nap but don&amp;#8217;t let appearances fool you! The solution is to only do the accounting once a packet with a proper ID is in, and deal with it then, and not keep a list of failed guesses.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This was literally the last major piece of PowerDNS that was not &amp;#8216;best of breed&amp;#8217;. Now all I need to do is clean up the code a tad and integrate full IPv6 support, and it should be Perfect.&lt;/p&gt;

&lt;p&gt;Wonder what I&amp;#8217;ll do then though :-)&lt;/p&gt;

&lt;h2&gt;Mirjam&lt;/h2&gt;

&lt;p&gt;I haven&amp;#8217;t mentioned my good friend and wife Mirjam enough, and she&amp;#8217;s complained a bit. So for the record, Mirjam has been doing a fine job, or at least making a valliant attempt, at making me leave the computer every once in a while. And I think she still believes me a bit when I say PowerDNS is &amp;#8216;nearly done&amp;#8217;. Now I have to believe it too.&lt;/p&gt;</description>
      <pubDate>Fri, 14 Apr 2006 22:48:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:6caba3ed-df18-411f-b8fc-520e95146d67</guid>
      <author>bert.hubert@netherlabs.nl (bert hubert)</author>
      <link>http://blog.netherlabs.nl/articles/2006/04/14/holy-cow-1-3-million-additional-ip-addresses-served-by-powerdns</link>
      <category>Linux</category>
      <category>PowerDNS</category>
      <category>Netherlabs</category>
      <category>Life</category>
      <trackback:ping>http://blog.netherlabs.nl/articles/trackback/30</trackback:ping>
    </item>
  </channel>
</rss>

