Amit Klein's security corner - FTP http://securitygalore.com/site3/taxonomy/term/1 en Safari FTP PASV manipulation vulnerability http://securitygalore.com/site3/safari-pasv <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p><strong>Release date</strong></p> <p>September 16th, 2015</p> <p> </p> <p><strong>Vulnerability description</strong></p> <p>FTP PASV manipulation attack was first described by <a href="mailto:mark@bindshell.net">mark@bindshell.net</a> in his 2007 paper “Manipulating FTP Clients Using The PASV Command” (originally at <a href="http://bindshell.net/papers/ftppasv">http://bindshell.net/papers/ftppasv</a>, but no longer there; live mirror at <a href="https://web.archive.org/web/20120904163048/http:/bindshell.net/papers/ftppasv/ftp-client-pasv-manipulation.pdf">https://web.archive.org/web/20120904163048/http://bindshell.net/papers/ftppasv/ftp-client-pasv-manipulation.pdf</a>). The reader is encouraged to make himself/herself familiar with that paper, and with the PoC at <a href="https://web.archive.org/web/20111228004729/http:/www.bindshell.net/papers/ftppasv/ftp-pasv-poc-v1.0.zip">https://web.archive.org/web/20111228004729/http://www.bindshell.net/papers/ftppasv/ftp-pasv-poc-v1.0.zip</a>.</p> <p>The impact of the attack is as following (directly quoting from the above paper, with some original references removed for clarity):</p> <p style="margin-left:.5in;">It is possible for malicious FTP servers to cause [the FTP client] to connect to TCP ports on other hosts. This allows us to extend existing JavaScript-based port scan techniques in the follow ways:</p> <p style="margin-left:.5in;">• Scan ports which modern browsers would not normally connect to</p> <p style="margin-left:.5in;">• Fingerprint services which do not send a banner by timing how long the server takes to terminate the connection</p> <p style="margin-left:.5in;">• Perform simple “banner grabbing” to identify services running on other hosts</p> <p>Apple Safari is not vulnerable to the attack as described in 2007. However, it turns out that if the FTP server responds to the CWD command or to the PASV command with a response that ends with LF (instead of CR+LF), then Safari becomes vulnerable, i.e. it will respect a PASV response that points at any IP and any port (instead of the FTP server’s IP address).</p> <p>To demonstrate this, the following changes need to be applied to the original PoC (for simplicity only a single PoC will be demonstrated – that of grabbing banners):</p> <p>In file “ftp-server.pl”, line 193, change from:</p> <p style="margin-left: 40px;"><span style="font-family:courier new,courier,monospace;">sendit("250 Directory successfully changed.\r\n");</span></p> <p>To:</p> <p style="margin-left: 40px;"><span style="font-family:courier new,courier,monospace;">sendit("250 Directory successfully changed.\n");</span></p> <p>And in file “ftp-pasv-demo3.html”, line 25, change from:</p> <p style="margin-left: 40px;"><span style="font-family:courier new,courier,monospace;">status.value += (time / 1000) + ' (t + ' + elapsed_time + '): ' +  message + "\n";</span></p> <p>To</p> <p style="margin-left: 40px;"><span style="font-family:courier new,courier,monospace;">document.getElementById('status').value += (time / 1000) + ' (t + ' + elapsed_time + '): ' +  message + "\n";</span></p> <p>The latter is due to WebKit-based browsers (e.g. Safari) exhibiting different behavior w.r.t. this DOM action – it has nothing to do with the actual vulnerability.</p> <p>On top of these changes, the demonstrator needs to follow the instructions in the PDF paper and in the HTML page comments in order to prepare the PoC.</p> <p> </p> <p><strong>Affected products/libraries</strong></p> <p>Safari for iOS 8.4.1. User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H321 Safari/600.1.4. Earlier versions of Safari for iOS are probably vulnerable.</p> <p>Safari 5.1.7 (7534.57.2) for Windows (latest, but no longer supported). User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2</p> <p>The issue may also apply to Safari for MacOS/X – probably up to and including OS/X 10.10.5.</p> <p>According to Apple, the issue resides in the “CFNetwork FTPProtocol” API/library.</p> <p> </p> <p><strong>CVE</strong></p> <p>Apple obtained the CVE identifier <a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-5912" target="_blank">CVE-2015-5912</a> to denote the issue. Bugtraq has <a href="http://www.securityfocus.com/bid/76764" target="_blank">BID 76764</a> to denote the iOS vulnerability.</p> <p> </p> <p><strong>Fix information</strong></p> <p>According to Apple, the issue fixed at least for the iOS platform in version 9 (iOS 9), immediately available (APPLE-SA-2015-09-16-1 for iOS, and later APPLE-SA-2015-09-30-3 for OS/X). For more information about this security update, please refer to <a href="https://support.apple.com/en-us/HT205212" target="_blank">https://support.apple.com/en-us/HT205212</a> and <a href="https://support.apple.com/en-us/HT205267" target="_blank">https://support.apple.com/en-us/HT205267</a>.</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/site3/taxonomy/term/16" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Safari</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/site3/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">FTP</a></li><li class="taxonomy-term-reference-2" rel="dc:subject"><a href="/site3/taxonomy/term/17" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">PASV</a></li></ul></div> Wed, 16 Sep 2015 16:37:33 +0000 amit 17 at http://securitygalore.com/site3 http://securitygalore.com/site3/safari-pasv#comments The localhosed attack (stealing IE localhost cookies) http://securitygalore.com/site3/localhosed <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>This <a href="/files/localhosed.pdf" target="_blank">extended advisory</a> describes a vulnerability in Microsoft Internet Explorer 11/10/9/8/7 (on Windows Vista and above). The vulnerability allows stealing cookies for local machine domains/IP addresses. Additionally, the local IP address used by IE to communicate to the Internet is exposed (even if behind a NAT or a SOCKS proxy). On Windows XP, IE 8-6 are vulnerable to the IP exposure vulnerability only.</p> <p>Having an HTTP (web) server listening locally on a Windows machine is not too rare, due to a multitude of software installations that do just that, e.g. for administration/control panel. Googling for e.g. Windows “ht​tp://localhost” yields almost 1 million hits. There’s no need to name names, but it suffices to say that there are major players from many software types, from virtual machines, to analytics, and of course content management systems.</p> <p>Of course, such setup may be susceptible to a plain and simple CSRF attack. However, stealing the cookies has several advantages over CSRF:</p> <ol><li>If the server employs anti-CSRF code, having the session cookies (in combination with DNS rebinding) can, in some cases (depending on the exact nature of the anti-CSRF technique) work around this protection.</li> <li>Session cookies (in combination with DNS rebinding) can enable reading data off sensitive pages.</li> <li>Cookies may contain sensitive information in and out of themselves.</li> </ol><p>The attack method can only steal cookies sent with HTTP requests (not HTTPS). Fortunately for the attacker, a web server bound to a local address is unlikely to use SSL.</p> <p>As for local IP address disclosure, this can be used to map an organization behind a NAT, or as a SOCKS proxy piercing (i.e. exposing the real IP address of a client “hiding” behind a SOCKS proxy).</p> <p>The impact of the cookie stealing attacks is summarized in the below table:</p> <table border="1" cellpadding="0" cellspacing="0"><tbody><tr><td style="width:160px;"> <p> </p> </td> <td style="width:160px;"> <p><strong>New window</strong></p> </td> <td style="width:160px;"> <p><strong>Frame</strong></p> </td> <td style="width:160px;"> <p><strong>Self navigation</strong></p> </td> </tr><tr><td style="width:160px;"> <p>Browser affected</p> </td> <td style="width:160px;"> <p>All IE versions on Windows Vista and above</p> </td> <td style="width:160px;"> <p>All IE versions on Windows Vista and above</p> </td> <td style="width:160px;"> <p>IE11</p> </td> </tr><tr><td style="width:160px;"> <p>User interaction?</p> </td> <td style="width:160px;"> <p>Yes (one click)</p> </td> <td style="width:160px;"> <p>No</p> </td> <td style="width:160px;"> <p>No</p> </td> </tr><tr><td style="width:160px;"> <p>Host scope</p> </td> <td style="width:160px;"> <p>Internet, Local Intranet</p> </td> <td style="width:160px;"> <p>Internet</p> </td> <td style="width:160px;"> <p>Local Intranet</p> </td> </tr><tr><td style="width:160px;"> <p>Cookie type</p> </td> <td style="width:160px;"> <p>persistent, session</p> </td> <td style="width:160px;"> <p>session (and any cookies assigned with P3P acceptable compact policy)</p> </td> <td style="width:160px;"> <p>persistent, session</p> </td> </tr><tr><td style="width:160px;"> <p>UAC mode supported</p> </td> <td style="width:160px;"> <p>(all)</p> </td> <td style="width:160px;"> <p>(all – if UAC is off, the scope can also cover Local Intranet, and there, persistent cookies can be stolen as well)</p> </td> <td style="width:160px;"> <p>On (default)</p> </td> </tr><tr><td style="width:160px;"> <p>SmartScreen mode supported</p> </td> <td style="width:160px;"> <p>Medium (default) or below</p> </td> <td style="width:160px;"> <p>(all)</p> </td> <td style="width:160px;"> <p>(all)</p> </td> </tr></tbody></table><p> </p> <p>Full details <a href="/files/localhosed.pdf" target="_blank">here</a>.</p> <p> </p> <p> </p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/site3/taxonomy/term/6" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">IE</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/site3/taxonomy/term/7" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">cookies</a></li><li class="taxonomy-term-reference-2" rel="dc:subject"><a href="/site3/taxonomy/term/8" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">localhost</a></li><li class="taxonomy-term-reference-3" rel="dc:subject"><a href="/site3/taxonomy/term/9" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">127.0.0.1</a></li><li class="taxonomy-term-reference-4" rel="dc:subject"><a href="/site3/taxonomy/term/10" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Internet Explorer</a></li><li class="taxonomy-term-reference-5" rel="dc:subject"><a href="/site3/taxonomy/term/11" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">NAT</a></li><li class="taxonomy-term-reference-6" rel="dc:subject"><a href="/site3/taxonomy/term/12" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">SOCKS</a></li><li class="taxonomy-term-reference-7" rel="dc:subject"><a href="/site3/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">FTP</a></li><li class="taxonomy-term-reference-8" rel="dc:subject"><a href="/site3/taxonomy/term/13" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">proxy</a></li><li class="taxonomy-term-reference-9" rel="dc:subject"><a href="/site3/taxonomy/term/14" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">proxy piercing</a></li><li class="taxonomy-term-reference-10" rel="dc:subject"><a href="/site3/taxonomy/term/15" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">PORT</a></li></ul></div> Sun, 21 Jun 2015 18:40:09 +0000 amit 16 at http://securitygalore.com/site3 http://securitygalore.com/site3/localhosed#comments Filezilla FTP server is vulnerable to FTP PORT bounce attack and PASV connection theft http://securitygalore.com/site3/filezilla_ftp_server_advisory <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Filezilla FTP server is vulnerable to FTP PORT bounce attack and PASV connection theft</p> <p>Date: May 6th, 2015</p> <p>Filezilla FTP server (affected versions: 0.8.0 - 0.9.50) is vulnerable to PORT bounce attack and to PASV connection theft. The attack concepts are very old. FTP PORT bounce attack is described e.g. in Hobbit’s 1995 writeup “<a href="http://nmap.org/hobbit.ftpbounce.txt" target="_blank">The FTP Bounce Attack</a>” and in CERT’s 1998 tech tip “Problems With The FTP PORT Command or Why You Don't Want Just Any PORT in a Storm” (originally at <a href="http://www.cert.org/tech_tips/ftp_port_attacks.html">http://www.cert.org/tech_tips/ftp_port_attacks.html</a>, that page is no longer responsive; mirrored at <a href="http://web.archive.org/web/20131105191347/http:/www.cert.org/tech_tips/ftp_port_attacks.html">http://web.archive.org/web/20131105191347/http:/www.cert.org/tech_tips/ftp_port_attacks.html</a>). Among the first descriptions of the PASV connection theft attack are David Sacerdote’s 1996 paper “<a href="http://web.textfiles.com/hacking/ftp-paper.txt" target="_blank">Some problems with the File Transfer Protocol, a failure of common implementations, and suggestions for repair</a>”, Jeffrey R. Gerber’s 1999 paper “FTP PASV ‘Pizza Thief’ Exploit” (originally at <a href="http://www.infowar.com/iwftp/iw_sec/iw_sec_01.txt">http://www.infowar.com/iwftp/iw_sec/iw_sec_01.txt</a> but no longer available there; mirrored at <a href="https://web.archive.org/web/20000303212433/http:/www.infowar.com/iwftp/iw_sec/iw_sec_01.txt">https://web.archive.org/web/20000303212433/http://www.infowar.com/iwftp/iw_sec/iw_sec_01.txt</a>), and Daniel J. Bernstein’s 1999 paper “<a href="http://cr.yp.to/ftp/security.html" target="_blank">PASV security and PORT security</a>”, which names the attack and discusses effective and ineffective defense mechanisms. This advisory will refer to Bernstein’s work for terminology.</p> <p>Filezilla FTP server was designed to protect against these attacks chiefly by verifying that the data channel remote IP address is identical (in “strict mode”) or at least from the same class C (in the more relaxed mode, which is the default) to the control channel remote IP address. See the Filezilla Server Interface (GUI) screenshot:</p> <p> </p> <p><img src="/files/gui2.png" /></p> <p>Unfortunately, due to a bug in Filezilla FTP server (introduced in version 0.8.0, <a href="http://sourceforge.net/p/filezilla/news/2003/01/filezilla-server-080-has-been-released/" target="_blank">released January 1<sup>st</sup>, 2003</a>), it is not the remote IP address of the channels which is subject to these tests, but rather the local IP address. This means that as long as the control channel and the data channel are established to the same IP address (that of the Filezilla server, naturally), the security test is passed, regardless of the remote addresses. In other words, practically there’s no IP address restriction, no matter what settings are chosen in the Filezilla server GUI.</p> <p>For the (PORT) bounce attack, the net result is that the attack can proceed without hindrance.</p> <p>For PASV connection theft, Filezilla FTP server offers an additional de-facto security layer in the form of a weak variant of “PASV SYN protection”, namely “Closing a socket as soon as accept() succeeds”. From experiments, Filezilla doesn’t verify that there’s only a single TCP connection established to the data port. It does close the listening port for the data channel almost immediately after the first connection is established (this is done after the accept() call returns). However, as Bernstein mentions, this defense is inadequate. It is still possible to have two (or even more) connections established to the data port (the first one is the attacker’s and the second one is the legitimate client’s), with the extra connections being sent RST by the Windows server soon after they’re established (in experiments, this was around 0.2-0.4 milliseconds after the first connection is established) due to the application (Filezilla FTP server) not accepting them and closing the listening socket (after the first accept()). Moreover, on Windows 8 the port number is used by Filezilla for the passive connection is predictable (it increments by 1 on each incoming connection, if there’s no additional port-consuming activity on the server).</p> <p>This means that it is possible to mount a “PASV connection theft” attack against Filezilla FTP server from any IP address. Such attack requires accurate timing on behalf of the attacker (to both win the race condition, and yet allow the legitimate client to momentarily establish a connection), and a bit of guesswork or enumeration (to get the port guessing right). First the attacker needs to predict the port Filezilla server will use for the data channel. If the attacker has access to the FTP service (i.e. has an account, or can use a public account), the attacker can obtain a port number sent by the server in a PASV response, and presume that the next port to be assigned is the port he/she received, incremented by 1 (the attacker can of course try increments by other small numbers to compensate for additional port consuming activities taking place in the meanwhile). Next, the attacker waits for the legitimate client’s session to reach the point where Filezilla opens a data port. The attacker then needs to carefully time his/her actions: the attacker needs to establish a 3-way TCP handshake to that port such that the final ACK packet will reach the Filezilla server just before the ACK packet of the 3-way TCP handshake established by the legitimate client. If the attacker manages to establish the TCP connection before the legitimate client, but in such timing that the legitimate client’s TCP connection is established before the port is closed, then the attacker’s TCP connection will be used by Filezilla server as the data connection, while the legitimate client’s TCP connection is established successfully, thus allowing the FTP logic on the legitimate client to proceed, issuing e.g. RETR/STOR/LIST, resulting in the data being sent or received via the data channel open between Filezilla server and the attacker. The end result is data theft (RETR – file, LIST – directory) or data spoofing (STOR – file).</p> <p>The attack was simulated successfully over a switched LAN with the legitimate FTP client being Internet Explorer 11 (RETR scenario).</p> <p>FXP transfers are also possible (again, regardless of the GUI settings) and trivial to mount because the PASV additional hurdle is irrelevant – the FTP servers are coordinated and hence there’s no race condition.</p> <p>A new version of Filezilla FTP server (0.9.51) is available for immediate download at <a href="https://filezilla-project.org/download.php?type=server">https://filezilla-project.org/download.php?type=server</a></p> <p>I would like to thank the vendor (Tim Kosse) for his prompt response and highly professional and friendly conduct.</p> <p>BugTraq ID: <a href="http://www.securityfocus.com/bid/74535" target="_blank">74535</a></p> <p> </p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/site3/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">FTP</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/site3/taxonomy/term/2" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Filezilla</a></li><li class="taxonomy-term-reference-2" rel="dc:subject"><a href="/site3/taxonomy/term/3" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">advisory</a></li></ul></div> Wed, 06 May 2015 15:40:04 +0000 amit 5 at http://securitygalore.com/site3 http://securitygalore.com/site3/filezilla_ftp_server_advisory#comments