+++ This bug was initially created as a clone of Bug #591580 +++
The draft advisory from oCERT follows:
The lftp, wget and lwp-download applications are ftp/http clients and file transfer tools supporting various network protocols. The lwp-download script is shipped along with the libwww-perl library.
Unsafe behaviours have been found in lftp and lwp-download handling the Content-Disposition header in conjunction with the 'suggested filename' functionality.
Additionally unsafe behaviours have been found in wget and lwp-download in case of HTTP 3xx redirections during file dowloading. The two applications automatically use the URL's filename portion specified in the Location header.
Implicitly trusting the suggested filenames results in a saved file that differs from the expected one according to the URL specified by the user. This can be used by a malicious attacker to silently write hidden and/or initialization files under the user's current directory (e.g. .login, .bashrc).
The impact of this vulnerability is increased in the case of lftp/lftpget as the default configuration allows file overwrite without prompting confirmation to the user. In case of lftp the get1 command is affected. This command can be invoked directly by the user from lftp's command line interface or indirectly by using the lftpget script, packaged within lftp distribution.
Affected version:
lftp <= 4.0.5 wget <= 1.12 libwww-perl <= 5.834
Fixed version:
lftp >= 4.0.6 wget N/A libwww-perl >= 5.835
Credit:
Vulnerability discovered and reported by Hank Leininger and Solar Designer under the Openwall Project, with further analysis by Daniele Bianco of oCERT.
--- Additional comment from vdanen on 2010-05-15 08:54:02 EDT ---
Florian noted the following as testcases for wget:
$ wget http://www.postbank.de/-snm-0184304830-1273865547-04f6f00001-0000000023-1273866968-enm-privatkunden/fondsboerse.htm (adds ;jsessionied= to the stored file name)
There's yet another case, but that only results in an index.html download.
$ wget http://www.enyo.de/fw
--- Additional comment from vdanen on 2010-05-17 10:51:26 EDT ---
This is now public:
http://www.ocert.org/advisories/ocert-2010-001.html
--- Additional comment from vdanen on 2010-05-18 11:17:25 EDT ---
Florian made a post to oss-security with a preliminary patch for wget. It probably requires some upstream review as it does add a new configuration option:
http://article.gmane.org/gmane.comp.security.oss.general/2908
However, Ludwig Nussel indicates that wget's behaviour is acceptable and probably doesn't require fixing at all, as wget does not overwrite existing files by default (adds suffixes like .1 and .2 to the new file if it already exists), and also prints the file name it used so there are no surprises.
In light of that, I would consider this a non-issue for wget, especially considering how intrusive the patch is for a backport.
A method to bypass SSL certificate name vs. host name verification via NUL ('\0') character embedded in X509 certificate's CommonName or subjectAltName was presented at Black Hat USA 2009:
http://www.blackhat.com/html/bh-usa-09/bh-usa-09-archives.html#Marlinspike
Similar problem affected wget (from a testing and very quick look at the code, subjectAltNames are not supported, hence only CommonName is a vector).
Upstream bug report: http://savannah.gnu.org/bugs/?27183 (currently not public)
Contents of upstream bug report, leaked via wget-notify list: http://addictivecode.org/pipermail/wget-notify/2009-August/001808.html
Upstream fixes: http://hg.addictivecode.org/wget/mainline/rev/2d8c76a23e7d http://hg.addictivecode.org/wget/mainline/rev/f2d2ca32fd1b http://hg.addictivecode.org/wget/mainline/rev/1eab157d3be7