Bug 833831

Summary: When redirected, wget should use the original page name for saving
Product: Red Hat Enterprise Linux 6 Reporter: Petr Šplíchal <psplicha>
Component: wgetAssignee: Tomáš Hozza <thozza>
Status: CLOSED ERRATA QA Contact: Jan Kepler <jkejda>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: jkejda, mnavrati, ohudlick, thoger, vascom2
Target Milestone: rcKeywords: Patch, Security, SecurityTracking
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: wget-1.12-1.11.el6_5 Doc Type: Release Note
Doc Text:
Cause: Consequence: Fix: Result:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-10 17:29:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 602797    
Attachments:
Description Flags
[PATCH] Introduce --trust-server-names option none

Description Petr Šplíchal 2012-06-20 12:54:24 UTC
Description of problem:

When wget fetches a page which is redirected to another page it
uses the redirected page name for file creation which could be
something user is not expecting and could probably present a
security issue. This is correctly fixed in latest wget in RHEL7.

Version-Release number of selected component (if applicable):
wget-1.12-1.4.el6.x86_64

Steps to Reproduce:
1. Set up some redirection on the server
2. wget the redirected page
  
Actual results:

For example:
wget --max-redirect=40 http://localhost/wget/redir/00.html

--2012-06-20 16:39:28--  http://localhost/wget/redir/00.html
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/wget/redir/01.html [following]
--2012-06-20 16:39:28--  http://localhost/wget/redir/01.html
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/wget/redir/02.html [following]
--2012-06-20 16:39:28--  http://localhost/wget/redir/02.html
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/wget/redir/03.html [following]
--2012-06-20 16:39:28--  http://localhost/wget/redir/03.html
...
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/wget/redir/28.html [following]
--2012-06-20 16:39:28--  http://localhost/wget/redir/28.html
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/wget/redir/29.html [following]
--2012-06-20 16:39:28--  http://localhost/wget/redir/29.html
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/wget/redir/30.html [following]
--2012-06-20 16:39:28--  http://localhost/wget/redir/30.html
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15 [text/html]
Saving to: `30.html'

Expected results:
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15 [text/html]
Saving to: `00.html'

Comment 1 RHEL Program Management 2012-07-10 08:29:45 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 2 RHEL Program Management 2012-07-11 02:04:01 UTC
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.

Comment 3 RHEL Program Management 2012-09-07 05:34:00 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 7 Tomáš Hozza 2012-11-20 11:54:48 UTC
Created attachment 648415 [details]
[PATCH] Introduce --trust-server-names option

Comment 8 Tomáš Hozza 2012-11-20 11:57:31 UTC
Wget WITHOUT patch:
$ ./wget http://localhost/wget/00.php
--2012-11-20 12:45:40--  http://localhost/wget/00.php
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/01.php [following]
--2012-11-20 12:45:40--  http://localhost/wget/01.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/02.php [following]
--2012-11-20 12:45:40--  http://localhost/wget/02.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/03.php [following]
--2012-11-20 12:45:40--  http://localhost/wget/03.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/index.html [following]
--2012-11-20 12:45:40--  http://localhost/index.html
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 127 [text/html]
Saving to: `index.html'

100%[==============================================================>] 127         --.-K/s   in 0s      

2012-11-20 12:45:40 (7.76 MB/s) - `index.html' saved [127/127]



Wget WITH patch:
$ ./wget http://localhost/wget/00.php
--2012-11-20 12:51:20--  http://localhost/wget/00.php
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/01.php [following]
--2012-11-20 12:51:20--  http://localhost/wget/01.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/02.php [following]
--2012-11-20 12:51:20--  http://localhost/wget/02.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/03.php [following]
--2012-11-20 12:51:20--  http://localhost/wget/03.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/index.html [following]
--2012-11-20 12:51:20--  http://localhost/index.html
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 127 [text/html]
Saving to: `00.php'

100%[==============================================================>] 127         --.-K/s   in 0s      

2012-11-20 12:51:20 (6.52 MB/s) - `00.php' saved [127/127]


$ ./wget --trust-server-names http://localhost/wget/00.php
--2012-11-20 12:51:38--  http://localhost/wget/00.php
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/01.php [following]
--2012-11-20 12:51:38--  http://localhost/wget/01.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/02.php [following]
--2012-11-20 12:51:38--  http://localhost/wget/02.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/wget/03.php [following]
--2012-11-20 12:51:38--  http://localhost/wget/03.php
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost/index.html [following]
--2012-11-20 12:51:38--  http://localhost/index.html
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 127 [text/html]
Saving to: `index.html'

100%[==============================================================>] 127         --.-K/s   in 0s      

2012-11-20 12:51:38 (8.27 MB/s) - `index.html' saved [127/127]

Comment 9 RHEL Program Management 2013-10-14 00:35:45 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 11 Vasiliy Glazov 2014-01-31 07:34:59 UTC
Same problem when using wget for downloading archives from github.
For example:
wget http://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz

--2014-01-31 11:31:28--  http://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz
Resolving github.com... 192.30.252.130
Connecting to github.com|192.30.252.130|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz [following]
--2014-01-31 11:31:34--  https://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz
Connecting to github.com|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/LibreCAD/LibreCAD/tar.gz/2.0.2 [following]
--2014-01-31 11:31:34--  https://codeload.github.com/LibreCAD/LibreCAD/tar.gz/2.0.2
Resolving codeload.github.com... 192.30.252.146
Connecting to codeload.github.com|192.30.252.146|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15429871 (15M) [application/x-gzip]
Saving to: “2.0.2”

2014-01-31 11:32:17 (414 KB/s) - “2.0.2” saved [15429871/15429871]

But file must be saved as 2.0.2.tar.gz

And same problem when github archive uses as Source0 in rpm package for RHEL6.

Please, update wget.

Comment 17 errata-xmlrpc 2014-02-10 17:29:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2014-0151.html