Bug 1139181 (CVE-2014-4877)

Summary: CVE-2014-4877 wget: FTP symlink arbitrary filesystem access
Product: [Other] Security Response Reporter: Vasyl Kaigorodov <vkaigoro>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: carnil, fcami, gscrivan, johfulto, jrusnack, pmatouse, robatino, ronaldochaves, sauchter, sbeal, scorneli, security-response-team, thozza, tru, zpytela
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=moderate,public=20141027,reported=20140908,source=upstream,cvss2=4.3/AV:N/AC:M/Au:N/C:N/I:P/A:N,rhel-5/wget=wontfix,rhel-6/wget=affected,rhel-7/wget=affected,fedora-all/wget=affected,cwe=CWE-59
Fixed In Version: wget 1.16 Doc Type: Bug Fix
Doc Text:
A flaw was found in the way Wget handled symbolic links. A malicious FTP server could allow Wget running in the mirror mode (using the '-m' command line option) to write an arbitrary file to a location writable to by the user running Wget, possibly leading to code execution.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-10-09 08:51:36 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 1156133, 1156134, 1156135, 1156136, 1157633, 1169860    
Bug Blocks: 1139182    
Attachments:
Description Flags
proposed fix
none
updated fix none

Description Vasyl Kaigorodov 2014-09-08 06:26:03 EDT
It was found that wget was susceptible to a symlink attack which could create arbitrary files, directories or symbolic links and set their permissions when retrieving a directory recursively through FTP.
Comment 1 Giuseppe Scrivano 2014-09-09 04:26:12 EDT
Created attachment 935576 [details]
proposed fix
Comment 5 Stefan Cornelius 2014-09-09 08:20:13 EDT
Acknowledgements:

Red Hat would like to thank the GNU Wget project for reporting this issue. Upstream acknowledges HD Moore of Rapid7, Inc as the original reporter.
Comment 6 Giuseppe Scrivano 2014-09-12 06:40:43 EDT
Created attachment 936905 [details]
updated fix

updated version for the proposed fix
Comment 13 Tomas Hoger 2014-10-23 15:58:42 EDT
Statement:

Red Hat Enterprise Linux 5 is now in Production 3 Phase of the support and maintenance life cycle. This has been rated as having Moderate security impact and is not currently planned to be addressed in future updates. For additional information, refer to the Red Hat Enterprise Linux Life Cycle: https://access.redhat.com/support/policy/updates/errata/.
Comment 15 Tomas Hoger 2014-10-27 07:36:01 EDT
A related commit is:

http://git.savannah.gnu.org/cgit/wget.git/commit/?id=69c45cba4382fcaabe3d86876bd5463dc34f442c

It adds a sanity check for the FTP directory listings to reject duplicate listings of the same file, which is one attack vector against this flaw.
Comment 16 Tomas Hoger 2014-10-27 07:36:28 EDT
This issue was fixed upstream in GNU wget 1.16:

http://lists.gnu.org/archive/html/bug-wget/2014-10/msg00150.html
Comment 17 Tomas Hoger 2014-10-27 07:45:58 EDT
This issue can be mitigated by ensuring that all invocations of wget in the mirror mode also specify --retr-symlinks command line option.  Doing so is equivalent to applying the upstream commit linked in comment 14, which changes the default for the retr-symlinks options from off/no to on/yes, preventing creation of symbolic links locally.

In addition to changing arguments in all scripts or programs that invoke wget, it is possible to enable retr-symlinks option via wget configuration file - either global /etc/wgetrc, or user specific ~/.wgetrc - by adding the following line:

  retr-symlinks=on
Comment 18 Tomas Hoger 2014-10-27 07:48:14 EDT
Created wget tracking bugs for this issue:

Affects: fedora-all [bug 1157633]
Comment 21 errata-xmlrpc 2014-10-30 16:37:51 EDT
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7
  Red Hat Enterprise Linux 6

Via RHSA-2014:1764 https://rhn.redhat.com/errata/RHSA-2014-1764.html
Comment 22 Fedora Update System 2014-11-22 07:34:26 EST
wget-1.16-3.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 23 Fedora Update System 2014-12-01 14:07:28 EST
wget-1.16-3.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 24 Martin Prpič 2014-12-02 12:23:24 EST
IssueDescription:

A flaw was found in the way Wget handled symbolic links. A malicious FTP server could allow Wget running in the mirror mode (using the '-m' command line option) to write an arbitrary file to a location writable to by the user running Wget, possibly leading to code execution.
Comment 25 errata-xmlrpc 2014-12-03 12:21:58 EST
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6.5 EUS - Server and Compute Node Only

Via RHSA-2014:1955 https://rhn.redhat.com/errata/RHSA-2014-1955.html
Comment 26 Fedora Update System 2014-12-06 05:47:34 EST
wget-1.16-3.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 27 Ronaldo 2015-02-05 08:55:21 EST
After update to this version, sssd + ldap + sudo stop working.
Comment 28 Ronaldo 2015-02-05 09:00:00 EST
Sorry, wrong bug.