<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tales from the Crypto : TCP/IP</title><link>http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx</link><description>Tags: TCP/IP</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>How FTP Data Connections Work Part 1 (OR: Don’t Open Port 20 in your Firewall!)</title><link>http://msmvps.com/blogs/alunj/archive/2009/07/08/1698917.aspx</link><pubDate>Thu, 09 Jul 2009 06:18:42 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1698917</guid><dc:creator>Alun Jones</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/rsscomments.aspx?PostID=1698917</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/commentapi.aspx?PostID=1698917</wfw:comment><comments>http://msmvps.com/blogs/alunj/archive/2009/07/08/1698917.aspx#comments</comments><description>&lt;p&gt;This will be the first of a couple of articles on FTP, as I’ve been asked to post this information in an easy-to-read format in a public place where it can be referred to. I think my expertise in developing and supporting &lt;a title="WFTPD by Texas Imperial Software" href="http://www.wftpd.com/" target="_blank"&gt;WFTPD&lt;/a&gt; and &lt;a href="http://www.wftpd.com"&gt;WFTPD Pro&lt;/a&gt; allow me to be reliable on this topic. Oh, that and the fact that I’ve contributed to a number of RFCs on the subject.&lt;/p&gt;  &lt;h3&gt;Enough TCP to be dangerous&lt;/h3&gt;  &lt;p&gt;First, a quick refresher on TCP – every TCP connection can be thought of as being associated with a “socket” at each device along the way – from one computer, through routers, to the other computer. The socket is identified by five individual items – the local IP address, the local port, the remote IP address, the remote port, and the protocol (in this case, the protocol is TCP).&lt;/p&gt;  &lt;p&gt;Firewalls are essentially a special kind of router, with rules not only for how to forward data, but also rules on connection requests to drop or allow. Once a connection request is allowed, the entire flow of traffic associated with that connection request is allowed, also – any traffic flow not associated with a previously allowed connection request is discarded.&lt;/p&gt;  &lt;p&gt;When you set up a firewall to allow access to a server, you have to consider the first segment – the “SYN”, or connection request from the TCP client to the TCP server. The rule can refer to any data that would identify the socket to be created, such as “allow any connection request where the source IP address is 10.1.1.something, and the destination port is 54321”.&lt;/p&gt;  &lt;p&gt;Typically, an external-facing firewall will allow all outbound connections, and have rules only for inbound connections. As a result, firewall administrators are used to saying things like “to enable access to the web server, simply open port 80”, whereas what they truly mean is to add a rule that applies to incoming TCP connection requests whose source address and source port could be anything, but whose destination port is 80, and whose destination address is that of the web server.” This is usually written in some short hand, such as “allow tcp 0.0.0.0:0 10.1.2.3:80”, where “0.0.0.0” stands for “any address” and “:0” stands for “any port”.&lt;/p&gt;  &lt;h3&gt;Firewall rules for FTP&lt;/h3&gt;  &lt;p&gt;For an FTP server, firewall rules are known to be a little trickier than for most other servers.&lt;/p&gt;  &lt;p&gt;Sure, you can set up the rule “allow tcp 0.0.0.0:0 10.1.2.3:21”, because the default port for the control connection of FTP is 21. That only allows the control connection, though.&lt;/p&gt;  &lt;p&gt;What other connections are there?&lt;/p&gt;  &lt;p&gt;In the default transfer mode of “Stream”, every file transfer gets its own data connection. Of course, it’d be lovely if this data connection was made on port 21 as well, but that’s not the way the protocol was built. Instead, Stream mode data connections are opened either as “Active” or “Passive” connections.&lt;/p&gt;  &lt;h3&gt;Active and Passive Data Connections&lt;/h3&gt;  &lt;p&gt;The terms &amp;quot;Active&amp;quot; and &amp;quot;Passive&amp;quot; refer to how the FTP server connects. The choice of connection method is initiated by the client, although the server can choose to refuse whatever the client asked for, at which point the client should fail over to using the other method.&lt;/p&gt;  &lt;p&gt;In the Active method, the FTP server connects to the client (the server is the “active” participant, the client just lies back and thinks of England), on a random port chosen by the client. Obviously, that will work if the client&amp;#39;s firewall is configured to allow the connection to that port, and doesn&amp;#39;t depend on the firewall at the server to do anything but allow connections outbound. The Active method is chosen by the client sending a “PORT” command, containing the IP address and port to which the server should connect.&lt;/p&gt;  &lt;p&gt;In the Passive method, the FTP client connects to the server (the server is now the “passive” participant), on a random port chosen by the server. This requires the server&amp;#39;s firewall to allow the incoming connection, and depends on the client&amp;#39;s firewall only to allow outbound connections. The Passive method is chosen by the client sending a “PASV” command, to which the server responds with a message containing the IP address and port at the server that the client should connect to.&lt;/p&gt;  &lt;h3&gt;The ALG comes to the rescue!&lt;/h3&gt;  &lt;p&gt;So in theory, your firewall now needs to know what ports are going to be requested by the PORT and PASV commands. For some situations, this is true, and you need to consider this – we’ll talk about that in part 2. For now, let’s assume everything is “normal”, and talk about how the firewall helps the FTP user or administrator.&lt;/p&gt;  &lt;p&gt;If you use port 21 for your FTP server, and the firewall is able to read the control connection, just about every firewall in existence will recognise the PORT and PASV commands, and open up the appropriate holes. This is because those firewalls have an Application Level Gateway, or ALG, which monitors port 21 traffic for FTP commands, and opens up the appropriate holes in the firewall. We’ve discussed the &lt;a href="http://msmvps.com/blogs/alunj/archive/2008/01/24/1479415.aspx"&gt;FTP ALG in the Windows Vista firewall&lt;/a&gt; before.&lt;/p&gt;  &lt;h3&gt;So why port 20?&lt;/h3&gt;  &lt;p&gt;Where does port 20 come in? A rather simplistic view is that administrators read the “Services” file, and see the line that tells them that port 20 is “ftp-data”. They assume that this means that opening port 20 as a destination port on the firewall will allow FTP data connections to flow. By the “elephant repellant” theory, this is proved “true” when their firewalls allow FTP data connections after they open ports 21 and 20. Nobody bothers to check that it also works if they only open port 21, because of the ALG.&lt;/p&gt;  &lt;p&gt;OK, so if port 20 isn’t needed, why is it associated with “ftp-data”? For that, you’ll have to remember what I said early on in the article – that every socket has five values associated with it – two addresses, two ports, and a protocol. When the data connection is made from the server to the client (remember, that’s an Active data connection, in response to a PORT command), the source port at the server is port 20. It’s totally that simple, and since nobody makes firewall rules that look at source port values, it’s relatively unimportant. That “ftp-data” in the Services file is simply so that the output from “netstat” has a meaningful service name instead of “:20” as a source port.&lt;/p&gt;  &lt;h3&gt;Coming up in part 2…&lt;/h3&gt;  &lt;p&gt;Next time, we’ll expand on this topic, to go into the inability of the ALG to process encrypted FTP control traffic, and the resultant issues and solutions that face encrypted FTP.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1698917" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/alunj/archive/tags/General+Security/default.aspx">General Security</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/FTP/default.aspx">FTP</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/What+my+wife+knows/default.aspx">What my wife knows</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Alun_2700_s+code/default.aspx">Alun's code</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx">TCP/IP</category></item><item><title>Debugging SSTP error -2147023660</title><link>http://msmvps.com/blogs/alunj/archive/2009/01/28/1666579.aspx</link><pubDate>Wed, 28 Jan 2009 14:57:45 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1666579</guid><dc:creator>Alun Jones</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/rsscomments.aspx?PostID=1666579</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/commentapi.aspx?PostID=1666579</wfw:comment><comments>http://msmvps.com/blogs/alunj/archive/2009/01/28/1666579.aspx#comments</comments><description>&lt;p&gt;Setting up an SSTP (Secure Socket Tunneling Protocol) connection earlier, I encountered a vaguely reminiscent problem. [SSTP allows virtual private network – VPN – connections between clients running Vista Service Pack 1 and later and servers running Windows Server 2008 and later, using HTTP over SSL, usually on port 443. Port 443 is the usual HTTPS port, and creating a VPN over just that port and no other allows it to operate over most firewalls.]&lt;/p&gt;  &lt;p&gt;The connection just didn’t seem to want to take, even though I had already followed the step-by-step instructions for setting up the SSTP server. I thought I had resolved the issue originally by ensuring that I installed the certificate (it was self-signed) in the Trusted Roots certificate store. [If the certificate was not self-signed, I would have ensured that the root certificate itself was installed in Trusted Roots]&lt;/p&gt;  &lt;p&gt;The first thing I did was to check the event viewer on the client, where I found numerous entries.&lt;/p&gt;  &lt;p&gt;I found error -2147023660 in the Application event log from RasClient. This translates to 0x800704D4, ERROR_CONNECTION_ABORTED. That was pretty much the same information I already had, that the connection was being prevented from completing. So I visited the server to see if there was more information there.&lt;/p&gt;  &lt;p&gt;On the server, I couldn’t find any entries from the time around when I was trying to connect. Not too good, because of course that’s where you’re going to look. In some cases, particularly errors that Microsoft thinks are going to happen too frequently, the conditions are checked at boot-time, and an error reported then, rather than every time the service is called on to perform an action.&lt;/p&gt;  &lt;p&gt;Fortunately, it hadn’t been that long since I last booted (and I had a hint or two from the RRAS team at Microsoft), so my eyes were quickly drawn to an Event with ID 24 in the System Log, sourced at Microsoft-Windows-RasSstp. The text said:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The certificates bound to the HTTPS listener for IPv4 and IPv6 do not match. For SSTP connections, certificates should be configured for 0.0.0.0:Port for IPv4, and [::]:Port for IPv6. The port is the listener port configured to be used with SSTP.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Note that this happens even if your RRAS server isn’t configured to offer IPv6 addresses to clients.&lt;/p&gt;  &lt;p&gt;So, here’s some documentation on event ID 24 :&lt;/p&gt;  &lt;p&gt;&lt;a title="http://technet.microsoft.com/en-us/library/cc733844.aspx" href="http://technet.microsoft.com/en-us/library/cc733844.aspx"&gt;http://technet.microsoft.com/en-us/library/cc733844.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is one of those nasty areas where there is no user interface other than the command-line. Don’t get me wrong, I love being able to do things using the command line, because it’s easy to script, simple to email to people who need to implement it, and it works well with design-approve-implement processes, where a designer puts a plan together that is approved by someone else and finally implemented by a third party. With command-line or other scripts, you can be sure that if the script didn’t change on its way through the system, then what was designed is what was approved, and is also what was implemented.&lt;/p&gt;  &lt;p&gt;But it’s also easy to get things wrong in a script, whereas a selection in a UI is generally much more intuitive. It’s particularly easy to get long strings of hexadecimal digits wrong, as you will see when you try and follow the instructions above. Make sure to use copy-and-paste when assembling your script, and read the output for any possible errors.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1666579" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/alunj/archive/tags/General+Security/default.aspx">General Security</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Why+is+PKI+so+hard_3F00_/default.aspx">Why is PKI so hard?</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx">TCP/IP</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item><item><title>Kaminsky Black-Hat Webcast: "By Any Other Name: DNS has doomed us all."</title><link>http://msmvps.com/blogs/alunj/archive/2008/07/25/1642098.aspx</link><pubDate>Fri, 25 Jul 2008 09:03:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1642098</guid><dc:creator>Alun Jones</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/rsscomments.aspx?PostID=1642098</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/commentapi.aspx?PostID=1642098</wfw:comment><comments>http://msmvps.com/blogs/alunj/archive/2008/07/25/1642098.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/alunj/Rose1_5F00_2.png"&gt;&lt;img border="0" align="left" width="200" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/alunj/Rose1_5F00_thumb.png" alt="By any other name..." height="200" style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" /&gt;&lt;/a&gt; Okay, so the talk&amp;rsquo;s official title was &amp;ldquo;&lt;em&gt;&lt;a href="http://tinyurl.com/6hr3tw" title="View the webcast"&gt;Dan Kaminsky&amp;rsquo;s DNS Discovery: The Massive, Multi-Vendor Issue and the Massive, Multi-Vendor Fix&lt;/a&gt;&lt;/em&gt;&amp;rdquo;. &lt;/p&gt;
&lt;p&gt;Arcane details of TCP are something of a hobby of mine, so I attended the &lt;a href="http://tinyurl.com/6hr3tw"&gt;webcast&lt;/a&gt; to see what Dan had to say. &lt;/p&gt;
&lt;h3&gt;The Past is Prologue&lt;/h3&gt;
&lt;p&gt;A little history first &amp;ndash; six months ago, Dan Kaminsky found something so horrifying in the bowels of DNS that he actually kept quiet about it. He contacted DNS vendors &amp;ndash; OS manufacturers, router developers, BIND authors, and the like &amp;ndash; and brought them all together in a soundproofed room on the Microsoft campus to tell them all about what he&amp;rsquo;d discovered. &lt;/p&gt;
&lt;p&gt;Everyone was sworn to secrecy, and consensus was reached that the best way to fix the problem would be to give vendors six months to release a coordinated set of patches, and then &lt;a href="http://www.doxpara.com/"&gt;Dan Kaminsky&lt;/a&gt; would tell us all at BlackHat what he&amp;rsquo;d found. &lt;/p&gt;
&lt;p&gt;Until then, he &lt;a href="http://www.doxpara.com/?p=1162" title="An Astonishing Collaboration"&gt;asked the security community&lt;/a&gt;, don&amp;rsquo;t guess in public, and don&amp;rsquo;t release the information if you know it. &lt;/p&gt;
&lt;h3&gt;Now is the winter of our DNS content (A records and the like)&lt;/h3&gt;
&lt;p&gt;Fast forward a few months, and we have a patch. I don&amp;rsquo;t think the patch was reverse-engineered, but there was &lt;a href="http://msmvps.com/blogs/alunj/archive/2008/07/21/1641696.aspx" title="Whoops - Information Wanted to be Free Again"&gt;enough public guessing going on that someone accidentally slipped and leaked the information&lt;/a&gt; &amp;ndash; now the whole world knows. &lt;/p&gt;
&lt;p&gt;Kaminsky confirmed this in today&amp;rsquo;s &lt;a href="http://tinyurl.com/6hr3tw"&gt;webcast&lt;/a&gt;, detailing how the attack works, to forge the address of www.example.com: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Attacker persuades victim to ask for 1.example.com &lt;/li&gt;
&lt;li&gt;Victim&amp;rsquo;s DNS server queries for an A record for 1.example.com &lt;/li&gt;
&lt;li&gt;Attacker forges a response that says &amp;ldquo;I don&amp;rsquo;t know 1.example.com, but the DNS server at www.example.com knows, and it&amp;rsquo;s at 1.2.3.4&amp;rdquo; &lt;/li&gt;
&lt;li&gt;Victim&amp;rsquo;s DNS server accepts this response, queries 1.2.3.4 for 1.example.com, and now the attacker knows that the victim can be directed to www.example.com at 1.2.3.4, allowing the attacker to steal cookies, represent as a trusted web site, etc, etc. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note that this is a simple description of the new behavior that Kaminsky found &amp;ndash; step 3 allows the DNS server&amp;rsquo;s cache to be poisoned with a mapping for www.example.com to 1.2.3.4, even if it was already cached from a previously successful search. &lt;/p&gt;
&lt;p&gt;If that was all that Kaminsky could do, even on an unpatched server, he&amp;rsquo;d have a 1 in 65535 chance of guessing the transaction ID to make his forgery succeed. However, old known behaviours simply make it easier for the attacker to make the forgery work: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Because the attacker tells the victim to search for a site, the attacker controls when the race with the authoritative DNS server starts. &lt;/li&gt;
&lt;li&gt;The attacker can tell the victim to search several times, and can forge several possible responses, using the birthday paradox to be more likely to guess the transaction ID (and source port), so that his forged response is accepted. &lt;/li&gt;
&lt;li&gt;Because this attack overwrites cached entries, the attacker can try again and again (picture a site with a million 1-pixel images each causing a different DNS query) until he is successful. Stuffing the cache won&amp;rsquo;t protect you. &lt;/li&gt;
&lt;li&gt;The attacker can insert an obscenely huge TTL (time-to-live) on the faked entry, so that it remains in cache until the DNS service is flushed or restarted. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Kaminsky&amp;rsquo;s tests indicate that a DNS server&amp;rsquo;s cache can be poisoned in this way in under ten seconds. There are metasploit plugins that &amp;lsquo;demonstrate&amp;rsquo; this&amp;nbsp; (or, as with all things metasploit, can be used to exploit systems). &lt;/p&gt;
&lt;p&gt;The patch, by randomizing the source port of the DNS resolver, raises the difficulty of this attack by a few orders of magnitude. &lt;/p&gt;
&lt;p&gt;The long-term fix, Kaminsky said, is to push for the implementation of DNSSEC, a cryptographically-signed DNS system, wherein you refuse to pass on or accept information that isn&amp;rsquo;t signed by the authoritative host. &lt;/p&gt;
&lt;h3&gt;A port, a port, my domain for a port&lt;/h3&gt;
&lt;p&gt;One novel wrinkle that Kaminsky hadn&amp;rsquo;t anticipated is that even after application of the patch to DNS servers, some NATs apparently remove the randomness in the source port that was added to make the attack harder. To quote Kaminsky &amp;ldquo;whoops, sorry Linksys&amp;rdquo; (although Cisco was one of the companies he notified of the DNS flaw, and they now own Linksys). Such de-randomising NATs essentially remove the usefulness of the patch. &lt;/p&gt;
&lt;p&gt;Patching is not completely without its flaws, however &amp;ndash; Kaminsky didn&amp;rsquo;t mention some of the issues that have been occurring because of these patches: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;ZoneAlarm decided that DNS queries from random source ports must be a sign of attack, and denied all such queries, essentially disconnecting the Internet from users of ZoneAlarm. I guess I can learn to live with that. &lt;/li&gt;
&lt;li&gt;BIND doesn&amp;rsquo;t check when binding to a random port to see if that port is already in use &amp;ndash; as a result, when the named server sends out a DNS query, there&amp;rsquo;s a chance the response packet will come back to a service that isn&amp;rsquo;t expecting it. Because the outgoing query punches a return hole in most firewalls, this could mean that a service blocked by the firewall from receiving Internet traffic is now opened up to the Internet. The workaround is to set the avoid-udp-v4-ports configuration setting, listing any ports that named shouldn&amp;rsquo;t use. &lt;/li&gt;
&lt;li&gt;&lt;a href="http://msmvps.com/blogs/alunj/archive/2008/07/19/1641409.aspx" title="DNS Server Binds to 2500 Ports"&gt;Windows&amp;rsquo; DNS service takes a different tack&lt;/a&gt;, binding to 2500 (the number is configurable) random ports on startup. As with BIND, these ports might conflict with other services; different from BIND, however, is the behavior &amp;ndash; since the ports are already bound by the DNS server, those other services (starting later than DNS, because most IP components require it) are now unable to bind to that port. As with BIND, the workaround is to tell the DNS server which ports not to use. The registry entry &lt;a href="http://support.microsoft.com/kb/812873" title="Microsoft&amp;#39;s KB on reserving UDP ports"&gt;ReservedPorts&lt;/a&gt; will do this. &lt;/li&gt;
&lt;li&gt;Users are being advised to point their DNS server entries to OpenDNS. Single point of failure, anyone? &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Metrics and statistics: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When Kaminsky&amp;rsquo;s &lt;a href="http://www.doxpara.com/" title="Click &amp;quot;Check my DNS&amp;quot;"&gt;vulnerability detection tool&lt;/a&gt; was first made available at doxpara.com, 80+% of all checks indicated that the DNS server was vulnerable. This last week, 52% of all checks showed vulnerable servers. Patches are getting installed. &lt;/li&gt;
&lt;li&gt;The attack is noisy &amp;ndash; output from the metasploit framework showed &amp;ldquo;poisoning successful after 13250 attempts&amp;rdquo; &amp;ndash; that&amp;rsquo;s thirteen thousand DNS queries and 260,000 forged DNS responses. IDS and IPS tools should have signatures for this attack, and may be able to repel boarders. &lt;/li&gt;
&lt;li&gt;Metasploit exploits for this are at &lt;a href="http://www.caughq.org/exploits/CAU-EX-2008-0003.txt"&gt;http://www.caughq.org/exploits/CAU-EX-2008-0003.txt&lt;/a&gt; if you want to research it further. &lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Tomorrow, and tomorrow, and tomorrow...&lt;/h3&gt;
&lt;p&gt;The overall message of the webcast is this: &lt;/p&gt;
&lt;p&gt;This attack is real, and traditional defences of using a high TTL will not protect you. Patching is the way to go. If you can&amp;rsquo;t patch, configure those unpatched DNS servers to forward to a local new (patched) DNS server, or an external patched server like OpenDNS. Scan your site for unexpected DNS servers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1642098" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/alunj/archive/tags/General+Security/default.aspx">General Security</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Vista/default.aspx">Windows Vista</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx">TCP/IP</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item><item><title>Whoops - Information Wanted to be Free Again.</title><link>http://msmvps.com/blogs/alunj/archive/2008/07/21/1641696.aspx</link><pubDate>Tue, 22 Jul 2008 05:09:51 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1641696</guid><dc:creator>Alun Jones</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/rsscomments.aspx?PostID=1641696</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/commentapi.aspx?PostID=1641696</wfw:comment><comments>http://msmvps.com/blogs/alunj/archive/2008/07/21/1641696.aspx#comments</comments><description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;Picture the scene at Security Blogs R Us:&lt;/p&gt; &lt;p&gt;&amp;quot;We&amp;#39;re so freakin&amp;#39; clever, we&amp;#39;ve figured out Dan Kaminsky&amp;#39;s DNS vulnerability&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;Yeah, but what if someone else figures it out - won&amp;#39;t we look stupid if we post second to them?&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;You&amp;#39;re right - but we gave Dan our word we wouldn&amp;#39;t publish.&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;So we won&amp;#39;t publish, but we&amp;#39;ll have a blog article ready to go if someone else spills the beans, so that we can prove that we knew all about it anyway.&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;Yeah, but we&amp;#39;d better be careful not to publish it accidentally.&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;gt;&amp;gt;WHOOP, WHOOP, WHOOP&amp;lt;&amp;lt;&lt;/p&gt; &lt;p&gt;&amp;quot;What was that?&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;The blog alert - someone else is beating us to the punch as we speak.&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;Publish or perish! Damn the torpedoes - false beard ahead!&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;What? Are you downloading those dodgy foreign-dubbed pirated anime series off BitTorrent through the company network again?&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;Yes - I found a way around your filters.&amp;quot;&lt;/p&gt; &lt;p&gt;&amp;quot;Good man.&amp;quot;&lt;/p&gt; &lt;hr /&gt;  &lt;p&gt;It&amp;#39;s true (okay, except for all of the made-up dialog above), a blog at one of the security vulnerability research crews (ahem, Matasano) did the unthinkable and rushed a blog entry out on the basis that they thought someone else (ahem, Halvar Flake) was beating them to it. And now we all know. The genie is out of the bag, the cat has been spilled, and the beans are out of the bottle.&lt;/p&gt; &lt;p&gt;Now we all know how to spoof DNS.&lt;/p&gt; &lt;p&gt;Okay, so Matasano pulled the blog pretty quickly, but by then it had already been copied to server upon server, and some of those copies are held by people who don&amp;#39;t want to take the information off the Internet.&lt;/p&gt; &lt;p&gt;Clearly, Information Wants To Be Free.&lt;/p&gt; &lt;hr /&gt;   &lt;p&gt;There&amp;#39;s an expression I never quite got the hang of - &amp;quot;Information Wants To Be Free&amp;quot;, cry the free software guys (who believe that software is information, rather than expression, which is a different argument entirely) - and the sole argument they have for this is that once information is freed, it&amp;#39;s impossible to unfree it. A secret once told is no longer a secret.&lt;/p&gt; &lt;p&gt;There&amp;#39;s an allusion to the way in which liquid &amp;#39;wants to be at its lowest level&amp;#39; (unless it&amp;#39;s liquid helium, which tends to climb up the sides of the beaker when you&amp;#39;re not looking), in that if you can&amp;#39;t easily put something back to where it used to be, then where it used to be is not where it wants to be.&lt;/p&gt; &lt;p&gt;So, information wants to be free, and Richard Stallmann&amp;#39;s bicycle tyre wants to have a puncture.&lt;/p&gt; &lt;p&gt; &lt;hr /&gt;  But back to the DNS issue.&lt;/p&gt; &lt;p&gt;I can immediately think of only one extra piece of advice I&amp;#39;d have given to the teams patching this on top of what I said in my previous blog, and that&amp;#39;s something that, in testing, I find the Windows Server 2003 DNS server was doing anyway.&lt;/p&gt; &lt;p&gt;So, that&amp;#39;s alright then.&lt;/p&gt; &lt;p&gt;Well, not entirely - I do have some minor misgivings that I hope I&amp;#39;ve raised to the right people.&lt;/p&gt; &lt;p&gt;But in answer to something that was asked on the newsgroups, no I don&amp;#39;t think you should hold off patching - the patch has some manual elements to it, in that you have to make sure the DNS server doesn&amp;#39;t impinge on your existing UDP services (and most of you won&amp;#39;t have that many), but patching is really a whole lot better than the situation you could find yourself in if you don&amp;#39;t patch.&lt;/p&gt; &lt;p&gt;And Dan, if you&amp;#39;re reading this - hi - great job in getting the big players to all work together, and quite frankly, the secrecy lasted longer than I expected it to. Good job, and thanks for trying to let us all get ourselves patched before your moment of glory at BlackHat.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1641696" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/alunj/archive/tags/General+Security/default.aspx">General Security</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Vista/default.aspx">Windows Vista</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx">TCP/IP</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item><item><title>DNS Server Reserves 2500 Ports.</title><link>http://msmvps.com/blogs/alunj/archive/2008/07/19/1641409.aspx</link><pubDate>Sat, 19 Jul 2008 07:02:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1641409</guid><dc:creator>Alun Jones</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/rsscomments.aspx?PostID=1641409</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/commentapi.aspx?PostID=1641409</wfw:comment><comments>http://msmvps.com/blogs/alunj/archive/2008/07/19/1641409.aspx#comments</comments><description>&lt;p&gt;After applying the patch for &lt;a href="http://www.microsoft.com/technet/security/bulletin/ms08-037.mspx" title="Microsoft Security Bulletin MS08-037 - Important: Vulnerabilities in DNS Could Allow Spoofing (953230)"&gt;MS08-037&lt;/a&gt; - &lt;a href="http://support.microsoft.com/default.aspx/kb/953230" title="MS08-037: Vulnerabilities in DNS could allow spoofing"&gt;KB 953230&lt;/a&gt; (the multi-OS DNS flaw found by &lt;a href="http://www.doxpara.com/" title="DoxPara Research - Dan Kaminsky&amp;#39;s blog."&gt;Dan Kaminski&lt;/a&gt;), you may notice your Windows Server 2003 machine gets a little greedy. At least, mine sucks up 2500 - yes, that&amp;#39;s two thousand five hundred - UDP sockets sitting there apparently waiting for incoming packets.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/alunj/Image_2D00_0219_5F00_2.png"&gt;&lt;img border="0" width="515" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/alunj/Image_2D00_0219_5F00_thumb.png" alt="Output of &amp;#39;netstat -bona -p udp&amp;#39; command, showing ports bound by DNS.EXE" height="436" style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is, apparently, one of those behaviours sure to be listed in the knowledge base as &amp;quot;this behavior is by design&amp;quot; - a description that graces some of the more entertaining elements of the Microsoft KB.&lt;/p&gt;
&lt;p&gt;Why does this happen? I can only guess. But here&amp;#39;s my best guess.&lt;/p&gt;
&lt;p&gt;The fix to DNS, implemented across multiple platforms, was to decrease the chance of an attacker faking a DNS response, by increasing the randomness in the DNS requests that has to be copied back in a response.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know how this was implemented on other platforms, but I do know that it&amp;#39;s already been reported that BIND&amp;#39;s implementation is slower than it used to be (hardly a surprise, making random numbers is always slower than simply counting up) - and maybe that&amp;#39;s what Microsoft tried to forestall in the way that they create the random sockets.&lt;/p&gt;
&lt;p&gt;Instead of creating a socket and binding it to a random source port at the time of the request, Microsoft&amp;#39;s patched DNS creates 2500 sockets, each bound to a random source port, at the time that the DNS service is started up. This way, perhaps they&amp;#39;re avoiding the performance hit that BIND has been criticised for.&lt;/p&gt;
&lt;p&gt;There are, of course, other services that also use a UDP port. ActiveSync&amp;#39;s connection to Exchange, IPsec, IAS, etc, etc. Are they affected?&lt;/p&gt;
&lt;p&gt;Sometimes.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/sbs/archive/2008/07/17/some-services-may-fail-to-start-or-may-not-work-properly-after-installing-ms08-037-951746-and-951748.aspx" title="SBS Blog: Some Services May Fail to Start or May Not Work Properly After Installing MS08-037 (951746 and 951748)"&gt;Randomly, and without warning or predictability&lt;/a&gt;. Because hey, the DNS server is picking ports randomly and unpredictably.&lt;/p&gt;
&lt;p&gt;[&lt;strong&gt;Workaround&lt;/strong&gt;: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ReservedPorts is a registry setting that lists multiple port ranges that will not be used when binding an ephemeral socket. The DNS server will obey these reservations, and not bind a socket to ports specified in this list. More explanation in the blog linked above, or at &lt;a href="http://support.microsoft.com/kb/812873"&gt;http://support.microsoft.com/kb/812873&lt;/a&gt;]&lt;/p&gt;
&lt;p&gt;DNS, you see, is a fundamental underpinning of TCP/IP services, and as such needs to start up before most other TCP/IP based services. So if it picks the port you want, it gets first pick, and it holds onto that port, preventing your application from binding to it.&lt;/p&gt;
&lt;p&gt;This just doesn&amp;#39;t seem like a fix written by someone who &amp;#39;gets&amp;#39; TCP/IP. Perhaps I&amp;#39;m missing something that explains why the DNS server in Windows Server 2003 works this way, but I would be inclined to take the performance hit of binding and rebinding in order to find an unused random port number, rather than binding before everyone else in an attempt to pre-empt other applications&amp;#39; need for a port.&lt;/p&gt;
&lt;p&gt;There are a couple of reasons I say this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Seriously, how many Windows Server 2003 users out there have such a high-capacity DNS server that they will notice the performance hit?&lt;/li&gt;
&lt;li&gt;Most Windows Server 2003-based DNS servers are small caching servers for businesses, rather than Internet infrastructure servers responsible for huge numbers of requests per second - even if you implement this port-stealing method, it shouldn&amp;#39;t be the default, because the majority of users just don&amp;#39;t need that performance.&lt;/li&gt;
&lt;li&gt;If you do need the performance, get another server to handle incoming requests. Because the cost of having your DNS server&amp;#39;s cache poisoned is considerably greater than the cost of increasing the number of servers in your pool, if you&amp;#39;re providing major DNS service to that many customers.&lt;/li&gt;
&lt;li&gt;A major DNS service provider will be running fewer services that would pre-empt a DNS server request to bind to a random port, whereas systems running several UDP-based services are going to need less performance on their outgoing DNS requests.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I&amp;#39;d love to know if I&amp;#39;m missing something here, but I really hope that Microsoft produces a new version of the DNS patch soon, that doesn&amp;#39;t fill your netstat -a output with so many bound and idle sockets, each of which takes up a small piece of nonpaged pool memory (that means real memory, not virtual memory).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1641409" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/alunj/archive/tags/General+Security/default.aspx">General Security</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Vista/default.aspx">Windows Vista</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx">TCP/IP</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item><item><title>Vista's Secret Windows Firewall hole</title><link>http://msmvps.com/blogs/alunj/archive/2008/01/24/1479415.aspx</link><pubDate>Fri, 25 Jan 2008 05:19:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1479415</guid><dc:creator>Alun Jones</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/rsscomments.aspx?PostID=1479415</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/commentapi.aspx?PostID=1479415</wfw:comment><comments>http://msmvps.com/blogs/alunj/archive/2008/01/24/1479415.aspx#comments</comments><description>&lt;p&gt;First, the good news - it&amp;#39;s not a flaw in the operation of Windows Firewall on Windows Vista. It&amp;#39;s a design feature, it makes sense, and it fits in with the principle that the firewall should keep out unsolicited traffic. It&amp;#39;s not really a hole, but I thought I&amp;#39;d grab your attention.&lt;/p&gt;
&lt;p&gt;The symptom first came up in a Usenet posting (thanks, Jesper, for bringing me in) about Vista and a third-party FTP client:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When I do a directory listing, and a PORT command is issued, and the &lt;br /&gt;server attempts to connect, it works, but at the same time a dialogue &lt;br /&gt;appears telling me it&amp;#39;s blocked, and I can keep blocking or unblock. &lt;br /&gt;I choose keep blocking but it doesn&amp;#39;t actually block it once.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Here&amp;#39;s how it looks. 
&lt;p&gt;First, if you haven&amp;#39;t got a third-party FTP client let&amp;#39;s fake it, by copying Microsoft&amp;#39;s command-line FTP client from the Windows System32 directory to another directory: 
&lt;blockquote&gt;
&lt;p&gt;C:\users\MyMe&amp;gt; copy %windir%\system32\ftp.exe&lt;br /&gt;1 file(s) copied.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The FTP client will not display prompts to you, but that&amp;#39;s a minor issue - if it upsets you, try downloading a third-party client and trying it. 
&lt;p&gt;Anyway, here we go - let&amp;#39;s try the issue in question: 
&lt;ul&gt;
&lt;li&gt;Type &lt;strong&gt;ftp ftp.microsoft.com&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;After you see the &amp;quot;220&amp;quot; greeting message, enter &lt;strong&gt;ftp&lt;/strong&gt; as the user - press enter.&lt;/li&gt;
&lt;li&gt;Now you&amp;#39;re prompted for a password - enter anything and press enter.&lt;/li&gt;
&lt;li&gt;Once you&amp;#39;re logged on, enter &lt;strong&gt;dir&lt;/strong&gt; - again, press enter.&lt;/li&gt;
&lt;li&gt;You&amp;#39;ll see the directory listing succeed, but you&amp;#39;ll also see a warning that a connection is being blocked:&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/blogs/alunj/WindowsLiveWriter/VistasWindowsFirewallSecret_11770/image-0063_2.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="571" alt="image-0063" src="http://msmvps.com/blogs/alunj/WindowsLiveWriter/VistasWindowsFirewallSecret_11770/image-0063_thumb.png" width="999" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Wow - that&amp;#39;s freaky - at the same time you&amp;#39;re being told that the connection used for the file listing will be blocked, it allows the connection through!&lt;/em&gt; 
&lt;p&gt;What&amp;#39;s more, even if you specify &lt;strong&gt;Keep Blocking&lt;/strong&gt;, and then go issue another &lt;strong&gt;dir&lt;/strong&gt; command, that one succeeds. 
&lt;p&gt;&lt;em&gt;Huh? And why on earth did you make me use a copy of FTP?&lt;/em&gt; 
&lt;p&gt;Let&amp;#39;s go look at the Windows Advanced Firewall Rules for Inbound, and see if this sheds any light: 
&lt;p&gt;[That means click the Start button, type &lt;strong&gt;Firewall&lt;/strong&gt; into the search box, and right-click on &lt;strong&gt;Windows Firewall with Advanced Security&lt;/strong&gt; - select &lt;strong&gt;Run as Administrator&lt;/strong&gt; 
&lt;p&gt;and accept the elevation prompt from UAC. If you don&amp;#39;t have an elevation prompt, then you should really re-enable UAC. Now select &lt;strong&gt;Inbound Rules&lt;/strong&gt; in the left-hand pane]&lt;/p&gt;
&lt;p&gt;Me, I&amp;#39;ve got a few rules labeled &lt;strong&gt;File Transfer Program&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/blogs/alunj/WindowsLiveWriter/VistasWindowsFirewallSecret_11770/Image-0064_2.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="348" alt="Image-0064" src="http://msmvps.com/blogs/alunj/WindowsLiveWriter/VistasWindowsFirewallSecret_11770/Image-0064_thumb.png" width="829" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;That first (and fourth) rule is set to block any listening ports opened by the &lt;strong&gt;File Transfer Program&lt;/strong&gt; in &lt;strong&gt;C:\users\myme\ftp.exe&lt;/strong&gt;, the second two seem to be allowing any listening ports created by the one in &lt;strong&gt;C:\windows\system32\ftp.exe&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Obviously, that&amp;#39;s why I asked you to copy &lt;strong&gt;ftp.exe&lt;/strong&gt; to a new directory, so that any previous allowance by the firewall rules wouldn&amp;#39;t get in the way.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;So what&amp;#39;s happening here? Is the &amp;quot;&lt;strong&gt;Allow&lt;/strong&gt;&amp;quot; rule somehow overriding the &amp;quot;&lt;strong&gt;Block&lt;/strong&gt;&amp;quot; rule, even though it&amp;#39;s not dealing with the same executable?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;We can test that simply by deleting both sets of rules - go ahead and do that, I&amp;#39;ll wait for you.&lt;/p&gt;
&lt;p&gt;Didn&amp;#39;t make a bit of difference, did it? It still allowed the traffic, then prompted you if you wanted to block it. Even if you selected to &amp;quot;&lt;strong&gt;Keep Blocking&lt;/strong&gt;&amp;quot;, the next and subsequent transfers still worked, right?&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Okay - let&amp;#39;s consult the Big Book of Knowledge (alright, what I can vaguely remember after mumbleteen years in the networking world). Some routers and firewalls use an Application Layer Gateway (ALG) to translate FTP commands, and open ports. Is that what&amp;#39;s going on here?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s take a peek at the services on this machine (as an administrator, run &lt;strong&gt;services.msc&lt;/strong&gt;):&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/blogs/alunj/WindowsLiveWriter/VistasWindowsFirewallSecret_11770/Image-0065_2.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="353" alt="Image-0065" src="http://msmvps.com/blogs/alunj/WindowsLiveWriter/VistasWindowsFirewallSecret_11770/Image-0065_thumb.png" width="784" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Bingo - there it is, the &lt;strong&gt;Application Layer Gateway Service&lt;/strong&gt;. And when you have &lt;strong&gt;Internet Connection Sharing&lt;/strong&gt; running, that&amp;#39;s what translates IP addresses in FTP commands for you, and what opens up port mappings and holes in the NAT that ICS hosts.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Oh, but wait a moment - what&amp;#39;s that in the &amp;quot;&lt;strong&gt;Status&lt;/strong&gt;&amp;quot; column?&lt;/p&gt;
&lt;p&gt;That&amp;#39;s right, nothing. This service isn&amp;#39;t running.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Something must be happening to open this port up - it&amp;#39;s not just a case of &amp;quot;port left open&amp;quot;, nor is it an outbound port. Those ports are closed tight until the FTP client starts listening for incoming data connections, and then they&amp;#39;re opened up.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s where I go into MVP-mode, and start searching in all the nooks and crannies of the web and whatever documentation it holds.&lt;/p&gt;
&lt;p&gt;Net result - Windows Firewall in Windows Vista includes something called a &amp;quot;connection inspection engine&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sounds like something from &amp;quot;&lt;/em&gt;&lt;a title="Conjunction junction, what&amp;#39;s your function?" href="http://en.wikipedia.org/wiki/Conjunction_Junction"&gt;&lt;em&gt;Schoolhouse Rock&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&amp;quot;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;No, seriously, there&amp;#39;s a &amp;quot;connection inspection engine&amp;quot; for FTP - if you connect to port 21, the firewall monitors your communications on that channel, looking for PORT commands. When it finds one, it opens up a hole in the firewall for the incoming data connection.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;So why the scary dialog warning that something&amp;#39;s going to block traffic?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Probably because the dialog pops up whenever an application starts listening, whereas the connection inspection engine only opens a hole when it sees a PORT command. And an FTP client can&amp;#39;t actually give the PORT command until it&amp;#39;s started listening.&lt;/p&gt;
&lt;p&gt;So, the process goes something like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start the FTP client.&lt;/li&gt;
&lt;li&gt;Connect to the FTP server on port 21, waking up the connection inspection engine.&lt;/li&gt;
&lt;li&gt;Log on, then type &lt;strong&gt;dir&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;The FTP client knows that it needs to open a data connection.&lt;/li&gt;
&lt;li&gt;To start the data connection, the FTP client binds to port 0, and starts listening.&lt;/li&gt;
&lt;li&gt;The firewall says &amp;quot;Oh no, an unknown program has started listening - better warn them that they won&amp;#39;t get any traffic.&amp;quot;&lt;/li&gt;
&lt;li&gt;The FTP client checks what port it actually got, and sends a matching PORT command.&lt;/li&gt;
&lt;li&gt;The connection inspection engine says &amp;quot;PORT command? That&amp;#39;s my cue!&amp;quot; and opens a hole in the firewall to incoming data connections.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Well, that&amp;#39;s easy, but what if I don&amp;#39;t ever want to do an FTP connection? How do I stop this from becoming a potential hacker tool?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Okay, apart from the obvious - that if a hacker could connect out to a server on port 21, nothing&amp;#39;s stopping that hacker from transferring data in - you might want to cripple this functionality.&lt;/p&gt;
&lt;p&gt;No problem - just set the following DWORD registry value to 1:&lt;/p&gt;
&lt;p&gt;HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ SharedAccess \ Parameters \ FirewallPolicy \ DisableStatefulFTP&lt;/p&gt;
&lt;p&gt;The default setting for this value on Windows Vista is 0. [It remains to be seen what value will be the default on Windows Server 2008]&lt;/p&gt;
&lt;p&gt;&lt;em&gt;How could Microsoft make this better?&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I&amp;#39;d really like to see this documented. Just so that it&amp;#39;s not a surprise to anyone.&lt;/li&gt;
&lt;li&gt;I&amp;#39;d like to know how many other connection inspection engines there are (at least one, judging from the DisableStatefulPPTP value - but I don&amp;#39;t know enough about PPTP to know how that affects operation).&lt;/li&gt;
&lt;li&gt;I&amp;#39;d like to know if I can add my own connection inspection engine to the firewall.&lt;/li&gt;
&lt;li&gt;Above all, I&amp;#39;d like to do away with the rather confusing and clumsy &amp;quot;We&amp;#39;re going to block your incoming ... wait, what just happened?&amp;quot; dialog. If the connection inspection engine is monitoring a command channel, and the process that owns the socket for that command channel starts listening, perhaps we could wait a quarter of a second for a PORT command before calling this a blocked connection?&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Finally, is this a vulnerability, a hole, or anything outside the correct operation of a firewall?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;No, because the firewall is documented as blocking unsolicited incoming connections - and by any reasonable definition, the data connection requested by a PORT command is solicited.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1479415" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/alunj/archive/tags/General+Security/default.aspx">General Security</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/FTP/default.aspx">FTP</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Vista/default.aspx">Windows Vista</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx">TCP/IP</category></item><item><title>Is a NAT a security device?</title><link>http://msmvps.com/blogs/alunj/archive/2007/12/29/1425918.aspx</link><pubDate>Sat, 29 Dec 2007 19:23:12 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1425918</guid><dc:creator>Alun Jones</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/rsscomments.aspx?PostID=1425918</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/alunj/commentapi.aspx?PostID=1425918</wfw:comment><comments>http://msmvps.com/blogs/alunj/archive/2007/12/29/1425918.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve been working lately on a couple of IPv6-related projects. First, there&amp;#39;s a chapter for an upcoming book, and second, there&amp;#39;s the effort to make WFTPD and WFTPD Pro work on IPv6, since it&amp;#39;s enabled by default in Windows Vista and Windows Server 2008 [more on that in a future post].&lt;/p&gt; &lt;p&gt;A big argument to my mind, as an old-school Internet user, for enabling IPv6 is that every one of your hosts becomes a fully-fledged Internet participant, like it used to be with IPv4 back in the &amp;#39;90s.&lt;/p&gt; &lt;p&gt;What do I mean by that?&lt;/p&gt; &lt;p&gt;I mean that every machine is reachable at its own address on every port that it chooses to open, rather than requiring someone to tinker with a NAT to open port mappings for specific applications.&lt;/p&gt; &lt;p&gt;IPv6 removes the need for a NAT at all.&lt;/p&gt; &lt;p&gt;Wow. To a security professional, that&amp;#39;s a shocking statement. It feels rather like saying that living in a tent removes the need for locks. How on earth do you protect your stuff without a NAT?&lt;/p&gt; &lt;p&gt;The answer is that a NAT was never intended to be a security device - it just happened, somewhat accidentally, that requiring address translation and port mapping to be statically configured created a security barrier.&lt;/p&gt; &lt;p&gt;Unfortunately, NATs also killed a lot of protocols (H.323 for webcams, FTP for file transfers - particularly when secured, IPsec) that quote IP addresses in their traffic.&lt;/p&gt; &lt;p&gt;To some extent this was fixed with ALGs - Application Layer Gateways - but never very satisfactorily (particularly in the case of secured FTP). What would be far better is to have a device that had the blocking advantages of a NAT, but didn&amp;#39;t require IP addresses and ports to be altered in transit.&lt;/p&gt; &lt;p&gt;There&amp;#39;s a name for such a device:&lt;/p&gt; &lt;p&gt;A firewall.&lt;/p&gt; &lt;p&gt;[Only if the firewall is configured by default to list all ports as &amp;quot;closed&amp;quot;. An open-by-default firewall is not a firewall, it&amp;#39;s a router.]&lt;/p&gt; &lt;p&gt;And a firewall is a far simpler program than a NAT (even if it&amp;#39;s in hardware, it&amp;#39;s the program&amp;#39;s simplicity that matters most). If it matches incoming traffic to ports that are opened, it allows that traffic in. If outgoing traffic occurs on a port that was closed, the firewall usually opens that port for the reverse traffic, so that clients on the inside of the firewall can get a response.&lt;/p&gt; &lt;p&gt;So, when the time comes that your network is required to transition to IPv6, don&amp;#39;t beg for an IPv6 NAT. I actually hope such a device doesn&amp;#39;t actually exist, and that nobody&amp;#39;s stupid enough to develop one. What you should insist on is an IPv6 firewall.&lt;/p&gt; &lt;p&gt;&amp;quot;But what about the problem that the layout of my network inside of the firewall will be revealed?&amp;quot; you might ask.&lt;/p&gt; &lt;p&gt;It won&amp;#39;t, because IPv6 addresses are sparsely allocated.&lt;/p&gt; &lt;p&gt;&amp;quot;How about machines that won&amp;#39;t ever need to be accessed by, or access out to, anything outside my company? What&amp;#39;s the IPv6 equivalent of an RFC 1918 address?&amp;quot;&lt;/p&gt; &lt;p&gt;No problem - there&amp;#39;s a standard for link-local and site-local (Unique Local Unicast, technically) addressing, which will never be routed outside of your site.&lt;/p&gt; &lt;p&gt;Any other reasons you&amp;#39;re clinging to the idea that a NAT is a security device?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1425918" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/alunj/archive/tags/General+Security/default.aspx">General Security</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Vista/default.aspx">Windows Vista</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/TCP_2F00_IP/default.aspx">TCP/IP</category><category domain="http://msmvps.com/blogs/alunj/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item></channel></rss>